<?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>27204</bug_id>
          
          <creation_ts>2014-10-31 08:11:22 +0000</creation_ts>
          <short_desc>Provide guidance on entry vs incumbent settings objects</short_desc>
          <delta_ts>2016-06-15 19:28:43 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>Unwelcome</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://www.w3.org/Bugs/Public/show_bug.cgi?id=26603</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          <blocked>27203</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Anne">annevk</reporter>
          <assigned_to name="Michael[tm] Smith">mike</assigned_to>
          <cc>arun</cc>
    
    <cc>bobbyholley</cc>
    
    <cc>bobowencode</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>d</cc>
    
    <cc>ian</cc>
    
    <cc>josh</cc>
    
    <cc>mike</cc>
          
          <qa_contact>sideshowbarker+unwelcome</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>114306</commentid>
    <comment_count>0</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-31 08:11:22 +0000</bug_when>
    <thetext>According to bz for anything new we should use incumbent for origin checks and entry for base URL and Referrer. It might be good to stipulate that clearly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114309</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-10-31 08:16:56 +0000</bug_when>
    <thetext>It&apos;s not clear that we want to use incumbent for origin checks, except when operating on cross-origin Window and Location, which are their own special kettle of fish.  I think we should seriously think about using the current Realm for origin checks in normal cases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114310</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-31 08:20:05 +0000</bug_when>
    <thetext>So there&apos;s three set of objects in play? Entry, incumbent, and current Realm? Current Realm seems fine, but that would require some kind of IDL hook, right? And again, people will need guidance as this is hard.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114311</commentid>
    <comment_count>3</comment_count>
    <who name="Bob Owen">bobowencode</who>
    <bug_when>2014-10-31 08:51:40 +0000</bug_when>
    <thetext>(In reply to Anne from comment #0)
&gt; According to bz for anything new we should use incumbent for origin checks
&gt; and entry for base URL and Referrer. It might be good to stipulate that
&gt; clearly.

For navigation, I think the referrer is generally supposed to come from the Source Browsing Context, see [1].
This can be a variety of things, including coming from the incumbent settings object.
I&apos;m not sure it is ever specified as coming from the entry settings object, although it could of course end up being the same thing.

[1] https://html.spec.whatwg.org/multipage/infrastructure.html#processing-model</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114314</commentid>
    <comment_count>4</comment_count>
    <who name="Bobby Holley (:bholley)">bobbyholley</who>
    <bug_when>2014-10-31 10:15:37 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #1)
&gt; It&apos;s not clear that we want to use incumbent for origin checks

Agreed. See bug 26603.

&gt; except when
&gt; operating on cross-origin Window and Location, which are their own special
&gt; kettle of fish.

Yeah. And even for that it&apos;s not really using the origin for a security check per se, but rather for determining the &quot;Caller-Appropriate Cross-Origin Representation&quot; of the various methods and accessors. See the current draft of the spec for this stuff: https://etherpad.mozilla.org/html5-cross-origin-objects

&gt; I think we should seriously think about using the current
&gt; Realm for origin checks in normal cases.

Definitely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114323</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-10-31 14:51:23 +0000</bug_when>
    <thetext>&gt; So there&apos;s three set of objects in play? Entry, incumbent, and current Realm? 

Yes.

&gt; but that would require some kind of IDL hook, right?

That&apos;s a good question.

Per ES, every function object (and this includes the getters/setters/methods IDL generates) has an associated Realm and that Realm becomes the current Realm when the function is called.

We may need a mechanism to go from a Realm to a settings object or an origin, but that doesn&apos;t seem like an IDL thing.  Rather, that seems like something that&apos;s part of the prose defining a global object, right?

&gt; And again, people will need guidance as this is hard.

Yes, I agree.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114324</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-31 14:57:02 +0000</bug_when>
    <thetext>The IDL hook is needed for the prose written in specifications as that typically does not deal with the JavaScript environment (nor theoretically has access to it I suppose). Currently it can use &quot;entry settings object&quot; or &quot;incumbent settings object&quot;. And XMLHttpRequest uses something different again: https://xhr.spec.whatwg.org/#dom-xmlhttprequest</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114325</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-10-31 15:13:26 +0000</bug_when>
    <thetext>&gt; nor theoretically has access to it I suppose

That&apos;s flat-out impossible, because it needs to be able to create JS objects like typed arrays and promises.  IDL describes how to do the type conversions, but all it does is &quot;return the same object&quot;.  _Creating_ the thing requires access to a JS global environment.

Right now specs sweep this under the hood, which is actually pretty confusing, because it doesn&apos;t make it clear which JS global environment is getting used.  I&apos;m 99% sure this leads to observable behavior differences between browsers in edge cases (some of which may be somewhat covered up by IDL instanceof operating on cross-global objects).  Just like the failure of most specs to specify which global environment their 

If we want to have the polite fiction that IDL is language-agnostic, we need to seriously rework how these objects work in IDL.

One other note.  IDL defines a &quot;perform a security check&quot; operation, or rather a hook for performing such a check that gets passed the things to check against each other.  This explicitly uses the current Realm to get the global and then passes that to &quot;perform a security check&quot;.  See &lt;http://heycam.github.io/webidl/#es-security&gt;.  Sadly, HTML doesn&apos;t actually define what it means to &quot;perform a security check&quot;.  :(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114328</commentid>
    <comment_count>8</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-10-31 15:24:48 +0000</bug_when>
    <thetext>&gt; I&apos;m 99% sure this leads to observable behavior differences

For example, try https://web.mit.edu/bzbarsky/www/testcases/global-object-association/webcrypto-parent.html in Firefox and Chrome.

&gt; we need to seriously rework how these objects work in IDL.

Or at least provide IDL hooks for creating Promise and typed array objects... and decide whether these hooks use some implicit global (which one?) or have to be handed an explicit global, together with a hook for getting the current realm global or something.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114373</commentid>
    <comment_count>9</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-31 17:48:04 +0000</bug_when>
    <thetext>Filed bug 27212 on HTML to define that security check.

I would be happy for IDL to remove the language agnostic stuff and just be JavaScript.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114389</commentid>
    <comment_count>10</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-31 18:20:24 +0000</bug_when>
    <thetext>Bug 24652 is the IDL bug on defining the associated Realm.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114469</commentid>
    <comment_count>11</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-04 00:44:16 +0000</bug_when>
    <thetext>If this is asking for spec writing guidance, shouldn&apos;t that be in the wiki?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114472</commentid>
    <comment_count>12</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-04 08:23:05 +0000</bug_when>
    <thetext>I don&apos;t know. In my experience people write specs the same way they write code. By copy and pasting others and then changing the bits they don&apos;t like until it looks &quot;reasonable&quot;. This argues for some short clarifying notes if concepts are particularly tricky.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115074</commentid>
    <comment_count>13</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-11-18 21:00:00 +0000</bug_when>
    <thetext>Something like this: http://www.w3.org/2001/tag/doc/promises-guide

would be good, but applied to Realm as well, as mentioned in Bug 26603.

Currently, Blob URLs use this to define origin.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117258</commentid>
    <comment_count>14</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2015-01-15 23:42:23 +0000</bug_when>
    <thetext>I&apos;m all for people writing spec writing advice, guides, wiki pages, and so on. I don&apos;t have the bandwidth to do it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126781</commentid>
    <comment_count>15</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2016-06-15 19:28:43 +0000</bug_when>
    <thetext>I believe this is taken care of by https://html.spec.whatwg.org/multipage/webappapis.html#realms-settings-objects-global-object</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>