<?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>23942</bug_id>
          
          <creation_ts>2013-11-29 14:50:52 +0000</creation_ts>
          <short_desc>&apos;load&apos; is fired twice per spec for http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2668</short_desc>
          <delta_ts>2013-12-03 15:40:36 +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>INVALID</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#the-iframe-element</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>ian</cc>
    
    <cc>james</cc>
    
    <cc>mike</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>96935</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-11-29 14:50:52 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#the-iframe-element
Complete: http://www.whatwg.org/c#the-iframe-element
Referrer: 

Comment:
&apos;load&apos; is fired twice per spec for
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2668

Posted from: 90.230.218.37
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.48 Safari/537.36 OPR/18.0.1284.26 (Edition Next)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96936</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2013-11-29 15:10:26 +0000</bug_when>
    <thetext>var iframe = document.createElement(&apos;iframe&apos;);
document.body.appendChild(iframe);

[[
When an iframe element is inserted into a document, the user agent must create a nested browsing context, and then process the iframe attributes for the &quot;first time&quot;.
]]
http://www.whatwg.org/specs/web-apps/current-work/#the-iframe-element

[[
Otherwise, if the element has no src attribute specified, and the user agent is processing the iframe&apos;s attributes for the &quot;first time&quot;
Queue a task to run the iframe load event steps.
]]
http://www.whatwg.org/specs/web-apps/current-work/#process-the-iframe-attributes

OK so now we have &apos;iframe load event steps&apos; on the event queue, and continue the script:

var doc = iframe.contentDocument;
doc.write(&apos;x&apos;);

This implies open() which, among other things, says...

[[
If the Document&apos;s iframe load in progress flag is set, set the Document&apos;s mute iframe load flag.
]]
http://www.whatwg.org/specs/web-apps/current-work/#dom-document-open

The iframe load in progress flag is not set, so we don&apos;t set the mute iframe load flag here.

Moving on...

doc.close();

This inserts EOF and runs the tokenizer, which I think will cause a &apos;load&apos; event to be fired as part of http://www.whatwg.org/specs/web-apps/current-work/#stop-parsing

Next we spin the event loop and do this:

[[
The iframe load event steps are as follows:

Let child document be the active document of the iframe element&apos;s nested browsing context.

If child document has its mute iframe load flag set, abort these steps.

Set child document&apos;s iframe load in progress flag.

Fire a simple event named load at the iframe element.

Unset child document&apos;s iframe load in progress flag.
]]
http://www.whatwg.org/specs/web-apps/current-work/#iframe-load-event-steps

Which also fires a &apos;load&apos; event.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96937</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2013-11-29 15:15:48 +0000</bug_when>
    <thetext>(In reply to Simon Pieters from comment #1)
&gt; doc.close();
&gt; 
&gt; This inserts EOF and runs the tokenizer, which I think will cause a &apos;load&apos;
&gt; event to be fired as part of
&gt; http://www.whatwg.org/specs/web-apps/current-work/#stop-parsing

Hmm, that fires &apos;load&apos; on the window, not on the iframe. So maybe there&apos;s no spec bug here...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96981</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-12-02 20:09:38 +0000</bug_when>
    <thetext>As far as I can tell, this matches browsers.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>