Re: [promises] Guidance on the usage of promises for API developers

On 1/16/14 1:29 PM, Domenic Denicola wrote:
> Hmm, I don't quite understand the concern.

You're creating new objects using things like Promise.cast().  That will 
create an object whose prototype is Promise.prototype.  But which 
realm's Promise is it using in this case?  That needs to be specified, 

> What is special about promises that makes using them require specifying the realm


> whereas other web specs don't seem to need to? Or do other specs specify realms too, and I just haven't noticed?

Here's what WebIDL says [1]:

   Every platform object is associated with a global environment, just
   as the initial objects are. It is the responsibility of
   specifications using Web IDL to state which global environment
   (or, by proxy, which global object) each platform object is
   associated with.

so web specs do in fact need to do it.  To the extent that they don't, 
they're not actually defining the behavior and need to be fixed. 
There's probably a lot of fixing to do, and I apologize on Mozilla's 
behalf for not bringing up issues on this more proactively as we've been 
converting objects to WebIDL bindings.  :(

Similarly, ES6 builtin functions need to specify the realm for objects 
they're creating.  All the ones I've spot checked in fact do that, so 
ES6 is way ahead of web specs here.

 > An example underspecified scenario would be helpful, I think.

Here's an example not involving promises that's currently 
underspecified, I believe:, "span");

I've put the relevant testcase at 
if you want to take a look.  Browsers consistently create the element in 
the realm of window2 in this case, but the DOM spec doesn't seem to 
actually define the behavior right now, unless I'm totally missing 
something.  It should do so, for example by defining that an element is 
associated with the global environment of its owner document and then 
defining the global environment for documents as needed.  DOMParser and 
XMLHttpRequest make that last bit slightly exciting.

Does that help illustrate the issue?

I do agree that this is a more wide-ranging problem than for promises, 
by the way.  At least in the createElement case we have compat across 
UAs do right now; for other cases I'm not sure we necessarily do.  :(



Received on Thursday, 16 January 2014 18:56:41 UTC