<?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>18547</bug_id>
          
          <creation_ts>2012-08-13 12:13:49 +0000</creation_ts>
          <short_desc>Make all IDL methods/attributes have [ImplicitThis] behavior, and then get rid of [ImplicitThis]</short_desc>
          <delta_ts>2016-09-08 20:54:40 +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>WebIDL</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Windows 3.1</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>[v1]</status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ms2ger">Ms2ger</reporter>
          <assigned_to name="Cameron McCormack">cam</assigned_to>
          <cc>allen</cc>
    
    <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>cam</cc>
    
    <cc>d</cc>
    
    <cc>mike</cc>
    
    <cc>public-script-coord</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>72118</commentid>
    <comment_count>0</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2012-08-13 12:13:49 +0000</bug_when>
    <thetext>window.addEventListener.call(null, &quot;a&quot;, function (e) { w(e) })

seems to work, while it isn&apos;t allowed per WebIDL.

I&apos;m not actually sure what [ImplicitThis] is good for, and why we don&apos;t always turn null/undefined into the window; maybe Cameron can explain.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72155</commentid>
    <comment_count>1</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2012-08-14 07:59:20 +0000</bug_when>
    <thetext>In ES3, Function.prototype.call would treat a first argument value of undefined or null as the global object instead, which would make the call you wrote work.  ES5 removed this:

  http://people.mozilla.org/~jorendorff/es5.html#sec-15.3.4.4

[LenientThis] is for if you need to work around that.  But I&apos;d like to know if it&apos;s really needed before adding it to addEventListener.  Or if we could even remove [LenientThis] from the spec.  It used to be used somewhere in HTML but I can&apos;t see it in use now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72156</commentid>
    <comment_count>2</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2012-08-14 08:37:39 +0000</bug_when>
    <thetext>We chatted about this:

http://logbot.glob.com.au/?c=mozilla%23developers&amp;s=14%20Aug%202012&amp;e=14%20Aug%202012#c326654</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74188</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-09-21 10:07:42 +0000</bug_when>
    <thetext>Anyone thought about this some more? Are the problems raised with HTML fixed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78838</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-11-26 16:26:15 +0000</bug_when>
    <thetext>This isn&apos;t about [LenientThis]; [LenientThis] doesn&apos;t do what&apos;s needed here.

Gecko&apos;s WebIDL bindings effectively implement the ES3 behavior, for what it&apos;s worth: they always compute &quot;this&quot; to an object, just like non-strict-mode functions do in ES5...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79286</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-12-03 14:08:50 +0000</bug_when>
    <thetext>Is there a black-box-detectable difference between putting [ImplicitThis] on all interfaces implemented by the global object (which may not be a Window) and simply having [ImplicitThis] on all interfaces?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79593</commentid>
    <comment_count>6</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2012-12-07 00:59:04 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; Is there a black-box-detectable difference between putting [ImplicitThis] on
&gt; all interfaces implemented by the global object (which may not be a Window)
&gt; and simply having [ImplicitThis] on all interfaces?

No, there would be no difference, because when calling a function from some [ImplicitThis]-annotated not-implemented-by-Window interface, you will get a TypeError thrown from step 1 of http://dev.w3.org/2006/webapi/WebIDL/#es-operations, and if it wasn&apos;t [ImplicitThis]-annotated then you would get a TypeError because http://es5.github.com/#x10.4.3 would turn the null into the global object, and this wouldn&apos;t be the right kind of object to call the function on.

One of the problems mentioned in the IRC log was that without [ImplicitThis],

  interface WindowProxy {
    readonly attribute WindowProxy window;
  };

you can&apos;t actually evaluate `window` in strict mode.  And anyway [ImplicitThis] is currently only defined to work on operations, not attributes.

So we obviously need it for that attribute.  And comment 0 says we need it for window.addEventListener.call().  Do we need it for a specific set of functions, or just for everything on window?  I&apos;m wondering if doing it for everything on window defeats (some of) the purpose of strict mode.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79596</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-12-07 01:23:17 +0000</bug_when>
    <thetext>&gt;  interface WindowProxy {
&gt;    readonly attribute WindowProxy window;
&gt;  };

That seems nonsensical.  Shouldn&apos;t that attribute be on Window?  There is no actual WindowProxy interface....  (Or no actual Window interface; pick your poison.)

But yes, the getter for that attribute needs to have something like [ImplicitThis].

My gut reaction is that every single thing on Window should have it so we don&apos;t break the web, but it&apos;s worth checking with the ES folks for what they want here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79597</commentid>
    <comment_count>8</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2012-12-07 01:30:03 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; &gt;  interface WindowProxy {
&gt; &gt;    readonly attribute WindowProxy window;
&gt; &gt;  };
&gt; 
&gt; That seems nonsensical.  Shouldn&apos;t that attribute be on Window?  There is no
&gt; actual WindowProxy interface....  (Or no actual Window interface; pick your
&gt; poison.)

Er, yep.

&gt; But yes, the getter for that attribute needs to have something like
&gt; [ImplicitThis].
&gt; 
&gt; My gut reaction is that every single thing on Window should have it so we
&gt; don&apos;t break the web, but it&apos;s worth checking with the ES folks for what they
&gt; want here.

Allen, can you tell us about the intentions of strict mode&apos;s &quot;not converting null/undefined to the global object&quot; and whether that was intended to apply to everything on the window object, or more for user defined functions?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124913</commentid>
    <comment_count>9</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2016-02-08 19:33:23 +0000</bug_when>
    <thetext>Per the thread starting at https://lists.w3.org/Archives/Public/public-script-coord/2015JanMar/0109.html, and concluding around https://lists.w3.org/Archives/Public/public-script-coord/2015JanMar/0122.html, we decided on an alternate plan, which I&apos;ve now updated the title of the bug to reflect:

- All IDL-defined methods should have the [ImplicitThis]-like behavior, where if `this` is undefined, it becomes the global of the realm of the function involved. (Or, the corresponding WindowProxy? ugh).

- This will cause brand check failures immediately when doing things like `Node.prototype.insertBefore.call(undefined, ...)` since a Window is not a Node. So this is good; a TypeError will be thrown as expected.

- Once this is done we can remove [ImplicitThis] from everywhere.

See also https://github.com/whatwg/html/issues/643.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124914</commentid>
    <comment_count>10</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2016-02-08 19:36:52 +0000</bug_when>
    <thetext>&gt; (Or, the corresponding WindowProxy? ugh).

I would vastly prefer it becoming the actual global.  That&apos;s what happens for bareword getters, after all, and it would be good to be consistent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127346</commentid>
    <comment_count>11</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2016-09-08 20:54:40 +0000</bug_when>
    <thetext>https://github.com/heycam/webidl/pull/155</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>