<?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>12635</bug_id>
          
          <creation_ts>2011-05-08 23:56:11 +0000</creation_ts>
          <short_desc>calling Functions corresponding to IDL operations/attributes on unexpected objects should throw</short_desc>
          <delta_ts>2011-06-28 04:59:46 +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>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>12320</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Cameron McCormack">cam</reporter>
          <assigned_to name="Cameron McCormack">cam</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>hsteen</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>public-script-coord</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>48338</commentid>
    <comment_count>0</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-05-08 23:56:11 +0000</bug_when>
    <thetext>Bug 11857 comment 6 brings up the cases like `window.alert.call(document, &apos;Do you see this alert?&apos;)`.  We should make this throw a TypeError.

Another case is getters/setters for IDL attributes, like `Object.getOwnPropertyDescriptor(document, &quot;nodeType&quot;).get.call(window)`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48340</commentid>
    <comment_count>1</comment_count>
    <who name="Hallvord R. M. Steen">hsteen</who>
    <bug_when>2011-05-09 00:29:15 +0000</bug_when>
    <thetext>(Was the summary supposed to say &quot;*un*expected objects&quot; - or is it just me not understanding WebIDL terminology yet? :-))</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48341</commentid>
    <comment_count>2</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-05-09 00:34:11 +0000</bug_when>
    <thetext>I do try to keep the terminology as confusing as possible. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48342</commentid>
    <comment_count>3</comment_count>
    <who name="Hallvord R. M. Steen">hsteen</who>
    <bug_when>2011-05-09 00:43:29 +0000</bug_when>
    <thetext>Another way to hit the same problem is of course to do 

document.alert=window.alert;
document.alert(&apos;If a document pops up an alert and nobody sees it, does it still pop up?&apos;);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48344</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-05-09 01:12:41 +0000</bug_when>
    <thetext>The other case where this come up is this:

  function f() {
  }
  f.prototype = document;
  var d = new f();
  d.write(&quot;What happens here?&quot;);

Some UAs throw in this situation; some actually invoke the native write function on the document.  I would prefer throwing, as the represetative of one of the UAs which currently does NOT throw here but would like to change that behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48345</commentid>
    <comment_count>5</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-05-09 03:06:59 +0000</bug_when>
    <thetext>I&apos;ve added back the check (which I am sure used to be in there) for calling Functions that correspond to IDL operations so that it throws a TypeError if the &apos;this&apos; object is not an object that implements the relevant interface.  (This check was already present for most of the other Function cases, like getter/setter Functions.)  Whether an object &quot;implements&quot; a given interface is still kinda hand-wavey, but the intention is to throw for cases like comment 4.  I&apos;ll try to come up with a rigorous definition of &quot;implements&quot; as part of bug 12320.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48465</commentid>
    <comment_count>6</comment_count>
    <who name="Hallvord R. M. Steen">hsteen</who>
    <bug_when>2011-05-11 05:19:05 +0000</bug_when>
    <thetext>Noticed 

apf.setZeroTimeout=(apf.isIE&amp;&amp;apf.isIE&lt;9)||apf.isO3||apf.isAIR?setTimeout:(function(){ . .

in cloud9ide&apos;s source. Now, this might simply be breaking browsers they don&apos;t bother testing in..but if this is actually tested code, it seems having a pointer to setTimeout on another object will work in some browsers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50384</commentid>
    <comment_count>7</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-06-28 03:40:11 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; Noticed 
&gt; 
&gt; apf.setZeroTimeout=(apf.isIE&amp;&amp;apf.isIE&lt;9)||apf.isO3||apf.isAIR?setTimeout:(function(){
&gt; . .
&gt; 
&gt; in cloud9ide&apos;s source. Now, this might simply be breaking browsers they don&apos;t
&gt; bother testing in..but if this is actually tested code, it seems having a
&gt; pointer to setTimeout on another object will work in some browsers.

That doesn&apos;t appear to work today:
http://people.mozilla.org/~cmccormack/tests/settimeout-this.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50387</commentid>
    <comment_count>8</comment_count>
    <who name="Hallvord R. M. Steen">hsteen</who>
    <bug_when>2011-06-28 04:59:46 +0000</bug_when>
    <thetext>I&apos;ve reached the same conclusion - site is probably simply broken..</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>