<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>24318</bug_id>
          
          <creation_ts>2014-01-17 11:51:53 +0000</creation_ts>
          <short_desc>Define the Realm of objects</short_desc>
          <delta_ts>2016-03-14 14:40:00 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>blocked on IDL</status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>24652</dependson>
          <blocked>25099</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Anne">annevk</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>cam</cc>
    
    <cc>mike</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>98695</commentid>
    <comment_count>0</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-01-17 11:51:53 +0000</bug_when>
    <thetext>Selective quote from Boris http://lists.w3.org/Archives/Public/www-tag/2014Jan/0112.html below:

&gt; Here&apos;s what WebIDL says:
&gt;
&gt;   Every platform object is associated with a global environment, just
&gt;   as the initial objects are. It is the responsibility of
&gt;   specifications using Web IDL to state which global environment
&gt;   (or, by proxy, which global object) each platform object is
&gt;   associated with.
&gt;
&gt; Here&apos;s an example not involving promises that&apos;s currently underspecified, I
&gt; believe:
&gt;
&gt;   window1.document.createElement.call(window2.document, &quot;span&quot;);
&gt;
&gt; I&apos;ve put the relevant testcase at
&gt; http://web.mit.edu/bzbarsky/www/testcases/multiple-realms/createElement-1.html
&gt; if you want to take a look. Browsers consistently create the element in the
&gt; realm of window2 in this case, but the DOM spec doesn&apos;t seem to actually
&gt; define the behavior right now, unless I&apos;m totally missing something. It
&gt; should do so, for example by defining that an element is associated with the
&gt; global environment of its owner document and then defining the global
&gt; environment for documents as needed. DOMParser and XMLHttpRequest make that
&gt; last bit slightly exciting.

I guess I&apos;ll file follow up bugs once I fix this in DOM.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98699</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-01-17 13:09:38 +0000</bug_when>
    <thetext>Anne, thank you.  I should have filed this.  :(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100425</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-02-12 19:03:10 +0000</bug_when>
    <thetext>Events are associated with the global environment of their interface object (better term?).

Nodes are associated with the global environment of their node document. Documents are associated with the global environment of &quot;depends&quot;.

Ranges are associates with the global environment of the context object of the method that created them or their interface object in case of constructors.

NodeIterator and TreeWalker are associated with the global environment of the context object of the method that created them.

Attr and DOMTokenList need to inherit from their associated element.

Collections probably need to inherit from the context object of the method that creates them.


I wonder if some of the inheriting should be expressed using IDL. That would make it easier for people to define new APIs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100431</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-02-12 19:58:46 +0000</bug_when>
    <thetext>(In reply to Anne from comment #2)
&gt; I wonder if some of the inheriting should be expressed using IDL. That would
&gt; make it easier for people to define new APIs.

E.g. if an interface has [Constructor] its associated global will be the one of its interface object. If an object is returned by a member of another object its associated global will be the same as that other object (with some kind of exception for &lt;iframe&gt; I suppose). Or am I completely wrong here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100438</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-02-12 21:12:07 +0000</bug_when>
    <thetext>&gt; Events are associated with the global environment of their interface object 

Except for events directly created via |new FooEvent|, that just moves the question to &quot;well, which interface object is the relevant one&quot;?

The rest sound reasonable to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100440</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-02-12 21:22:26 +0000</bug_when>
    <thetext>&gt; Or am I completely wrong here?

You&apos;re not.

What Gecko implements is that a particular implementation object can specify which global it should live in by returning some other object whose global should be used.  For example, nodes return their owner document; documents return a global stashed on them when they&apos;re created.

If an object in Gecko does not specify a global to use, the global that&apos;s used is the global of the getter/method that&apos;s returning the object to JS.  So if you do:

  var r = windowA.document.createRange.call(windowB.document);

we create &quot;r&quot; in the global of window A.

There&apos;s one complication here if JS reflections don&apos;t have the same lifetime as the underlying object and the object can be returned from various different getters/methods.  But that might just be an implementation detail.  Not sure.  The basic question is what should happen if a preexisting object is stashed somewhere and then retrieved.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125462</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2016-03-14 13:09:45 +0000</bug_when>
    <thetext>Given https://github.com/w3c/web-platform-tests/pull/1381 this is entirely an IDL problem. Resolving WONTFIX for DOM.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125465</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2016-03-14 13:13:58 +0000</bug_when>
    <thetext>I&apos;m not sure I see what that pull request for wpt has to do with this bug.  How is this entirely an IDL problem?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125471</commentid>
    <comment_count>8</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2016-03-14 13:56:17 +0000</bug_when>
    <thetext>That pull request was about demonstrating to you whether this could be done predictably, and defined by IDL. Bug 24652, which this bug depends on, is the actual IDL bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125472</commentid>
    <comment_count>9</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2016-03-14 14:40:00 +0000</bug_when>
    <thetext>Ah, I see.  It&apos;s still not clear to me whether we can entirely define this in IDL, but we can try... we just need to do it, because right now browsers are basically doing whatever the heck they want for new APIs.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>