This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 16457 - IDL exceptions as platform objects
Summary: IDL exceptions as platform objects
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
Depends on:
Reported: 2012-03-20 19:15 UTC by Marcos Caceres
Modified: 2012-03-27 00:17 UTC (History)
2 users (show)

See Also:


Description Marcos Caceres 2012-03-20 19:15:37 UTC
I'm a bit confused as to why "objects representing IDL exceptions" are considered "platform objects". It is possible to construct and throw such IDL exceptions in ECMAscript without it being a platform object. This makes IDL exceptions indistinguishable from platform objects. 

I'll also note that the whole notion of platform objects and that they can only be distinguished by  a magical inaccessible internal property shuts out JavaScript only implementations (which seems to go a bit against the spirit of ECMAScript, which exposes most of its guts to developers). That seems bad :( If this is the case, then there should be a isPlatformObject() method defined on Object. 

var foo = Object.isPlatformObject(Node)
Comment 1 Marcos Caceres 2012-03-20 19:19:58 UTC
FYI... this is my hacky checker for platform objects:

//check platform object
if(ECMAScript.Type(O) === "Function"){
   var name =; 
   var nativeString = "function " + name + "() { [native code] }";  
   if(O.toString() === nativeString){
	   classType = "platform object"; 
	    return classType; 
Comment 2 Cameron McCormack 2012-03-21 23:12:24 UTC
Most (all?) behaviours of platform objects you should be able to implement using Proxies.

Note that platform objects do not necessarily have to be ECMAScript host objects, so you could very well use a native object to implement them, especially since they don't need any special behaviour that you would need Proxies for.

You will need to track some internal state for them though, to "know" that they are platform objects.  This is because:

* Object.prototype.toString needs to return "[object DOMException]" say for the DOMException IDL exception.  Object.prototype.toString is defined to look at the object's class string, if it is a platform object.

* Platform objects cannot be passed to something expecting a dictionary type, or a callback interface type.

* The accessor property get/set functions for exception fields inspect their this object to ensure they are a platform object of the right type (and if not, throw).
Comment 3 Cameron McCormack 2012-03-27 00:17:15 UTC
NEEDSINFO awaiting concrete suggestions for text improvements.