<?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>11838</bug_id>
          
          <creation_ts>2011-01-23 02:16:56 +0000</creation_ts>
          <short_desc>In Gecko, Opera, and IE, the &quot;name&quot; property on Window is replaceable</short_desc>
          <delta_ts>2011-08-04 05:03:01 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>LC1 HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#the-window-object</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ayg</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>cam</cc>
    
    <cc>hsteen</cc>
    
    <cc>ian</cc>
    
    <cc>jackalmage</cc>
    
    <cc>mike</cc>
    
    <cc>mounir</cc>
    
    <cc>pecoraro</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>w3c</cc>
    
    <cc>w3c</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>44622</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-01-23 02:16:56 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html
Section: http://www.whatwg.org/specs/web-apps/current-work/#the-window-object

Comment:
In Gecko and Opera, at least, the &quot;name&quot; property on Window is replaceable. 
Should that be specced, or is it web-compatible enough to not make it
replaceable?

Posted from: 71.184.125.56</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44623</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-01-23 02:22:57 +0000</bug_when>
    <thetext>Testcase is:

  &lt;script&gt;
    alert(typeof(name));
  &lt;/script&gt;
  &lt;script&gt;
    var name = 5;
    alert(typeof(name));
  &lt;/script&gt;
   
That alerts &quot;string&quot; and then &quot;string&quot; in Safari/Chrome, and alerts &quot;string&quot; and then &quot;number&quot; in Gecko, Opera, IE8, and IE9 previews.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44665</commentid>
    <comment_count>2</comment_count>
    <who name="Joseph Pecoraro">pecoraro</who>
    <bug_when>2011-01-24 16:50:38 +0000</bug_when>
    <thetext>I agree, I raised this on the whatwg list 7/2010:
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-July/027002.html

The response by the editor was:
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-August/027831.html

&gt; I am told IE says &quot;string,string,string&quot; (thanks to Tab and Aryeh).
&gt;
&gt; This argues that we should not make it replaceable unless it breaks pages.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44666</commentid>
    <comment_count>3</comment_count>
    <who name="Joseph Pecoraro">pecoraro</who>
    <bug_when>2011-01-24 16:53:55 +0000</bug_when>
    <thetext>Given Boris&apos;s comment that IE8 and IE9 make this replaceable, then maybe it is just WebKit that is an outlier now. The WebKit bug on this is:
&lt;http://webkit.org/b/19967&gt; Variables named &quot;name&quot; become strings

Still, I would like to see this specced one way or the other!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44668</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-01-24 17:29:14 +0000</bug_when>
    <thetext>&gt; I am told IE says &quot;string,string,string&quot; (thanks to Tab and Aryeh).

ccing them.  It looks like in IE the presence or absence of |var| there is key.  If it&apos;s present, then a new property is presumably created on the global object which shadows the property on the prototype, which is why you end up with &quot;number&quot; alerted for the second alert in my testcase.

If I change the testcase in http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-July/027002.html to say &quot;var name = 1&quot; and not use a function wrapper around the code, then IE alerts &quot;undefined,number,number&quot;, Gecko alerts &quot;string,string,number&quot;, Safari and Chrome alert &quot;string,string,string&quot;, Opera alerts &quot;undefined,number,number&quot;.

So maybe the |name| property doesn&apos;t need to be replaceable if it actually lives on the prototype instead of the window itself and if |var| introduces a new property of that name on the window itself?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44742</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2011-01-26 10:03:39 +0000</bug_when>
    <thetext>window.name assignments usually survive same-origin navigations and browser restarts. Does this work for non-strings too?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44757</commentid>
    <comment_count>6</comment_count>
    <who name="Adam Barth">w3c</who>
    <bug_when>2011-01-26 18:34:28 +0000</bug_when>
    <thetext>Moving non-strings (e.g., objects) across origin boundaries is bad times for security.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45834</commentid>
    <comment_count>7</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-02-18 22:55:20 +0000</bug_when>
    <thetext>Given window.name&apos;s rather complicated magic, if we _can_ make it non-replaceable, we should, IMHO.

Is there evidence that this needs to be replaceable for compat?

The difference in behaviour with &apos;var&apos; vs no-&apos;var&apos; seems unsupported by the JS spec; am I misreading the spec?

I really have no idea what I should be speccing here if window.name is to be replaceable and if WebIDL and the JS spec don&apos;t make the stuff about the prototype that bz describes in comment 4 automatically work. If that is indeed what should happen, some advice as to how to spec it would be very welcome.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45853</commentid>
    <comment_count>8</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-02-19 01:30:39 +0000</bug_when>
    <thetext>&gt; The difference in behaviour with &apos;var&apos; vs no-&apos;var&apos; seems unsupported by the JS
&gt; spec; am I misreading the spec?

I believe &apos;var&apos; vs no-&apos;var&apos; should in fact behave differently.  See &lt;https://bugzilla.mozilla.org/show_bug.cgi?id=632003#c1&gt;.  Whether that erratum has made it to the official drafts, I don&apos;t know.

So it sounds like we could just make &apos;name&apos; live on Window.prototype and be a regular getter/setter pair there.  It would mean that doing |name = &quot;foo&quot;| at global scope without declaring |var name| beforehand would actually rename the window, which seems somewhat undesirable for authors.  But maybe that&apos;s ok.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45854</commentid>
    <comment_count>9</comment_count>
    <who name="Kyle Simpson">w3c</who>
    <bug_when>2011-02-19 01:39:35 +0000</bug_when>
    <thetext>Sounds like it could also cause other patterns for accidental overwrite, such as:

    var obj = {};
    with(obj) {
       name = &quot;blah&quot;;
    }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45855</commentid>
    <comment_count>10</comment_count>
    <who name="Kyle Simpson">w3c</who>
    <bug_when>2011-02-19 01:44:05 +0000</bug_when>
    <thetext>At least in IE, I believe this will also overwrite/replace window.name with a var called `name`:

    try {
       nonexistent();
    }
    catch (name) { }

As in IE, the variable in the catch-clause gets created as a variable in the containing scope.

Also, what about:

    function name() {}

And (again, in IE, bug with NFE&apos;s):

    var a = function name(){};

And: 

    eval(&quot;var name = 12;&quot;);

And:

    var a = name = 12;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45856</commentid>
    <comment_count>11</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-02-19 01:56:48 +0000</bug_when>
    <thetext>&gt;    eval(&quot;var name = 12;&quot;);

This would just add a prop on the window, I think.  I&apos;d have to double-check.

&gt;    var a = name = 12;

This is the same as |name = 12|, sure.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>47994</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-05-04 23:26:51 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Rejected
Change Description: no spec change
Rationale: 

If I understand the above correctly, the conclusion here is that |name| doesn&apos;t have to be replaceable, and thus this should be WONTFIX. I&apos;m not 100% sure I understood all the subtleties above, though, so if I&apos;m wrong please reopen the bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52605</commentid>
    <comment_count>13</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:03:01 +0000</bug_when>
    <thetext>mass-moved component to LC1</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>