<?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>21946</bug_id>
          
          <creation_ts>2013-05-07 03:45:20 +0000</creation_ts>
          <short_desc>Ignoring non-null values of opener does not seem to be web-compatible</short_desc>
          <delta_ts>2014-05-29 19:49:44 +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>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#dom-opener</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>cam</cc>
    
    <cc>ian</cc>
    
    <cc>jwalden+w3</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>87303</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-05-07 03:45:20 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html
Multipage: http://www.whatwg.org/C#dom-opener
Complete: http://www.whatwg.org/c#dom-opener
Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/

Comment:
Ignoring non-null values of opener does not seem to be web-compatible

Posted from: 98.110.194.206 by bzbarsky@mit.edu
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:23.0) Gecko/20130503 Firefox/23.0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87304</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-05-07 03:52:13 +0000</bug_when>
    <thetext>The Magento CMS, which is pretty widely used, has this bit:

    getTargetElement: function() {
        if (typeof(tinyMCE) != &apos;undefined&apos; &amp;&amp; tinyMCE.get(this.targetElementId)) {
            if ((opener = this.getMediaBrowserOpener())) {
                var targetElementId = tinyMceEditors.get(this.targetElementId).getMediaBrowserTargetElementId();
                return opener.document.getElementById(targetElementId);

note the assignment to &quot;opener&quot;.  When Gecko implemented what the spec currently says for opener, this code broke.  See https://bugzilla.mozilla.org/show_bug.cgi?id=868996

I just tested, and this script:

    opener = 20; alert(opener);

alerts 20 in Firefox 19, Chrome, Safari, Opera, and IE9.  This one:

  opener = window; alert(opener);

alerts the window in older IE versions too...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87360</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-05-07 17:18:25 +0000</bug_when>
    <thetext>But note that there are probably complications in terms of what happens to the opener value on navigation....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87458</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-05-08 19:46:12 +0000</bug_when>
    <thetext>So what I will be implementing in Gecko is to make this setter behave just like replaceable properties if called with a non-null Window argument.  We will still restrict to Window arguments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88941</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-06-07 22:58:36 +0000</bug_when>
    <thetext>heycam, any chance you can make [Replaceable] apply to non-readonly attributes, and have it behave as needed here, namely, as for [Replaceable] on readonly properties if the value is one that would normally throw TypeError, and as a regular attribute otherwise?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88967</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-06-08 02:36:12 +0000</bug_when>
    <thetext>Note that comment 3 and comment 4 are saying very different things.

The basic web compat requirements here, as far as I know them, are:

1) Setting opener to null should set it to null on the navigation context.
2) Setting opener to any other Window value should set it to that value for the
   lifetime of the current page.

UA behavior ... differs.  Some UAs allow setting opener to any value.  Some UAs persist that setting across page loads depending on the value even for some non-null values.

I strongly believe that non-null values should NOT be persisted across page loads, for what it&apos;s worth.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88969</commentid>
    <comment_count>6</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-06-08 04:29:23 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; Note that comment 3 and comment 4 are saying very different things.
&gt; 
&gt; The basic web compat requirements here, as far as I know them, are:
&gt; 
&gt; 1) Setting opener to null should set it to null on the navigation context.
&gt; 2) Setting opener to any other Window value should set it to that value for
&gt; the
&gt;    lifetime of the current page.

Can we handle this not as a [Replaceable] thing in the IDL actually, but just the behaviour of the opener IDL attribute?  So have a flag on the browsing context that represents whether a (null or Window) value has been assigned to opener, and also a thing that stores that value, and have the opener IDL attribute return that value if the flag is set.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88970</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-06-08 04:33:40 +0000</bug_when>
    <thetext>The point is that when something non-null is set it needs to not be stored on the browsing context.

It could be stored on the Window, of course; then the opener getter would be a lot more complicated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88971</commentid>
    <comment_count>8</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-06-08 04:35:55 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; It could be stored on the Window, of course; then the opener getter would be
&gt; a lot more complicated.

I guess that&apos;s what I was suggesting.  I&apos;m just not sure it&apos;s great to make [Replaceable] even more complicated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88972</commentid>
    <comment_count>9</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-06-08 04:37:21 +0000</bug_when>
    <thetext>Right.  Fwiw, in this case we do the replaceable-like thing entirely in the code equivalent of &quot;spec prose&quot;, not in bindings.  I don&apos;t think it&apos;s worth adding this to WebIDL since this seems like a one-off case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89326</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-06-14 18:35:33 +0000</bug_when>
    <thetext>Roger. Will do it in prose.

Just to make sure I understand this:

- 1. make window.opener:
       attribute any opener;

- 2. define a Window-specific (not Document-specific, so it survives the case when 
     Window is reused for a same-origin Document replacing about:blank) internal
     value that can hold any value, and that is initially null.

- 3. on getting, if the internal value is not null, return that. Otherwise, return 
     the actual opener value.

- 4. on setting, if the new value is &quot;null&quot;, set the actual opener value to null.
     Otherwise, set the internal value to the new value.

Is that right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89327</commentid>
    <comment_count>11</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-06-14 18:37:42 +0000</bug_when>
    <thetext>It could be done that way, yes.

Why do we want &apos;any&apos; as opposed to just allowing &apos;Window&apos;?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89714</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-06-21 16:19:56 +0000</bug_when>
    <thetext>If the value isn&apos;t &quot;any&quot;, then WebIDL will coerce the values or throw an exception, before we see them in the prose.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89722</commentid>
    <comment_count>13</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-06-21 18:22:56 +0000</bug_when>
    <thetext>Sure.  Why is that a problem?  Again, what Gecko is currently shipping is that the value is a Window in the IDL, and if it&apos;s non-null we redefine the property in a [Replaceable]-like way.  But we only do that for Windows; we have found no one depending on setting opener to non-Window things so far.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90167</commentid>
    <comment_count>14</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-02 22:53:45 +0000</bug_when>
    <thetext>I don&apos;t understand what you mean by &quot;redefine the property in a [Replaceable]-like way&quot; if you don&apos;t mean &quot;allow it to be set to any arbitrary value&quot;. Isn&apos;t what you&apos;re describing just &quot;the property can be set&quot;? What&apos;s &quot;[Replaceable]-like&quot; about it, exactly?

Based on my best guess of what you&apos;re describing, a revised proposal:

- 1. define a Window-specific (not Document-specific, so it survives the
     case when Window is reused for a same-origin Document replacing
     about:blank) internal value that can hold a WindowProxy, and that is
     set, when the Window is created, to the actual opener value&apos;s WindowProxy.

- 2. on getting, .opener returns the internal value.

- 3. on setting, .opener sets the internal value to the new value, and, if
     the new value is &quot;null&quot;, also set the actual opener value to null.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90169</commentid>
    <comment_count>15</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-07-02 22:57:14 +0000</bug_when>
    <thetext>What Gecko currently implements is that when you set .opener we check that you&apos;re setting it to a Window or null and throw if you aren&apos;t (this is all done by the WebIDL layer).  Then if you&apos;re not setting it to null, we Object.defineProperty a new property on the &quot;this&quot; object, which is a value property whose value is the thing that was passed in.  This is handled by the &quot;prose&quot; part of the algorithm.

This is not quite identical to your proposal, though your proposal seems like it would be fine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90272</commentid>
    <comment_count>16</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-03 22:04:57 +0000</bug_when>
    <thetext>Actually what I described wouldn&apos;t work because if you go to a page, then go to another that resets the opener to null, then come back, it should remain reset. My proposal would have the first window still pointing to the real opener.

I don&apos;t mind doing the property-setting thing, but I&apos;ve no idea what the right prose to do that is. heycam, can you help me out with the right terminology?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90273</commentid>
    <comment_count>17</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-07-03 22:15:53 +0000</bug_when>
    <thetext>Make the type of the attribute &quot;Window?&quot;, and then in the prose write something like (where /value/ is the new value):

  If /value/ is null, then ...
  Otherwise, call the [[DefineOwnProperty]] method of the Window object, passing property name &quot;opener&quot;, Property Descriptor { [[Value]]: /value/, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }, and false.

(That ignores the difference between IDL values an ECMAScript values, though in this case there&apos;s not enough of a difference to really worry about it.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95107</commentid>
    <comment_count>18</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-10-22 18:15:06 +0000</bug_when>
    <thetext>I couldn&apos;t work out what the &quot;and false&quot; bit was for. I left it out, since it didn&apos;t seem to map to anything in the JS spec.

Let me know if the new text is ok!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95108</commentid>
    <comment_count>19</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-10-22 18:15:30 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8235.
Check-in comment: Try to make window.opener more compatible
http://html5.org/tools/web-apps-tracker?from=8234&amp;to=8235</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95116</commentid>
    <comment_count>20</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2013-10-22 19:46:34 +0000</bug_when>
    <thetext>(In reply to Ian &apos;Hixie&apos; Hickson from comment #18)
&gt; I couldn&apos;t work out what the &quot;and false&quot; bit was for. I left it out, since
&gt; it didn&apos;t seem to map to anything in the JS spec.

In ES5, [[DefineOwnProperty]] takes three arguments (P, Desc, Throw); in ES6, just two (P, Desc).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95123</commentid>
    <comment_count>21</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-10-22 21:21:10 +0000</bug_when>
    <thetext>Ah. Was the third argument just always ignored or always false or something?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95148</commentid>
    <comment_count>22</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-10-22 23:21:48 +0000</bug_when>
    <thetext>Neither.  They just have totally different signatures/contracts.

In ES5, [[DefineOwnProperty]] is supposed to throw if it fails in cases when the Throw argument is true, and silently do nothing when it&apos;s false.  The caller is responsible for calling in the correct value of Throw.

In ES6, [[DefineOwnProperty]] just returns a boolean indicating whether it succeeded; the callers then throw in some cases but not others in failure cases, depending on what the callee is, exactly.

So if you&apos;re speccing this in ES6 terms, you just want to make sure to handle the return value without throwing; I think the spec text your wrote is ok, since it does exactly that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95221</commentid>
    <comment_count>23</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-10-23 19:09:26 +0000</bug_when>
    <thetext>I really want this to be targetting tomorrow&apos;s most up to date draft, whatever that is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95240</commentid>
    <comment_count>24</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-10-23 20:17:49 +0000</bug_when>
    <thetext>Yeah, targeting ES6 makes sense here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96471</commentid>
    <comment_count>25</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-18 23:22:17 +0000</bug_when>
    <thetext>Ok. So the text in the spec is ok then? Maybe I should add a reference to the current ES draft or something?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96493</commentid>
    <comment_count>26</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-11-19 01:23:04 +0000</bug_when>
    <thetext>I think the text in the spec right now is ok, yes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96537</commentid>
    <comment_count>27</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-19 21:05:14 +0000</bug_when>
    <thetext>Okie dokie.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96539</commentid>
    <comment_count>28</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-11-19 21:23:08 +0000</bug_when>
    <thetext>Wait, I meant just the ES bits.  I&apos;m still not sure why we&apos;re allowing all values here instead of just window-or-null.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96544</commentid>
    <comment_count>29</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-19 21:40:00 +0000</bug_when>
    <thetext>Where does it allow all values?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96548</commentid>
    <comment_count>30</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-11-19 21:43:15 +0000</bug_when>
    <thetext>Oh, sorry.  I misread the bug and failed to read what the spec actually says now.  We&apos;re good here, and my apologies for the noise!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106998</commentid>
    <comment_count>31</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-05-29 19:49:44 +0000</bug_when>
    <thetext>&gt; we have found no one depending on setting opener to non-Window things so far.

That was because we had it on the proto chain, so

  var opener = {};

shadowed instead of setting.  But global props are supposed to go on the global, and sites depend on the above to work (e.g. see https://bugzilla.mozilla.org/show_bug.cgi?id=989584 ).  I filed bug 25917 to change to &quot;any&quot; here.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>