HTML5 Tracker

Diff (omit for latest revision)
Filter

Short URL: http://html5.org/r/5817

SVNBugCommentTime (UTC)
581711295[Authors] [Gecko] [Internet Explorer] [Opera] [Webkit] Make script-inserted external scripts that have .async=false execute in the insertion order, default to true2011-02-03 05:34
Index: source
===================================================================
--- source	(revision 5816)
+++ source	(revision 5817)
@@ -15760,7 +15760,18 @@
   elements they insert and affects the processing of those
   elements.</p>
 
-  <p>The third is a flag indicating whether or not the script block is
+  <p>The third is a flag indicating whether the element will
+  <dfn>"force-async"</dfn>. Initially, <code>script</code> elements
+  must have this flag set. It is unset by the <span>HTML parser</span>
+  and the <span>XML parser</span> on <code>script</code> elements they
+  insert. In addition, whenever a <code>script</code> element whose
+  <span>"force-async"</span> flag is set has a <code
+  title="attr-script-async">async</code> content attribute added, the
+  element's <span>"force-async"</span> flag must be unset.</p> <!--
+  there's no need to unset it when the attribute is removed since you
+  can't have the attribute and the flag set at once. -->
+
+  <p>The fourth is a flag indicating whether or not the script block is
   <dfn>"ready to be parser-executed"</dfn>. Initially,
   <code>script</code> elements must have this flag unset (script
   blocks, when created, are not "ready to be parser-executed"). This
@@ -15827,6 +15838,22 @@
 
    </li>
 
+   <li>
+
+    <p>If <var title="">was-parser-inserted</var> is true and the
+    element does not have an <code
+    title="attr-script-async">async</code> attribute, then set the
+    element's <span>"force-async"</span> flag to true.</p>
+
+    <p class="note">This is done so that if a parser-inserted
+    <code>script</code> element fails to run when the parser tries to
+    run it, but it is later executed after a script dynamically
+    updates it, it will execute asynchronously even if the
+    <code title="attr-script-async">async</code> attribute isn't
+    set.</p>
+
+   </li>
+
    <li id="script-processing-empty">
 
     <p>If the element has no <code title="attr-script-src">src</code>
@@ -15902,17 +15929,18 @@
 
    </li>
 
-   <li id="script-processing-start">
+   <li>
 
-    <p>The user agent must set the element's <span>"already
-    started"</span> flag.</p>
+    <p>If <var title="">was-parser-inserted</var> is true, then flag
+    the element as <span>"parser-inserted"</span> again, and set the
+    element's <span>"force-async"</span> flag to false.</p>
 
    </li>
 
-   <li>
+   <li id="script-processing-start">
 
-    <p>If <var title="">was-parser-inserted</var> is true, then flag
-    the element as <span>"parser-inserted"</span> again.</p>
+    <p>The user agent must set the element's <span>"already
+    started"</span> flag.</p>
 
    </li>
 
@@ -16013,6 +16041,9 @@
 
    </li>
 
+   <!-- at this point if the element is "parser-inserted" then we know
+   it is not "force-async". -->
+
    <li>
 
     <p>Then, the first of the following options that describes the
@@ -16088,6 +16119,50 @@
      </dd>
 
 
+     <dt id="script-processing-src-sync">If the element has a <code
+     title="attr-script-src">src</code> attribute, does not have an
+     <code title="attr-script-async">async</code> attribute, and does
+     not have the <span>"force-async"</span> flag set</dt>
+
+     <dd>
+
+      <p>The element must be added to the end of the <dfn>list of
+      scripts that will execute in order as soon as possible</dfn>
+      associated with the <code>Document</code> of the
+      <code>script</code> element at the time the <span>running a
+      script</span> algorithm started.</p>
+
+      <p>The <span title="concept-task">task</span> that the
+      <span>networking task source</span> places on the <span>task
+      queue</span> once the <span title="fetch">fetching
+      algorithm</span> has completed must run the following steps:</p>
+
+      <ol>
+
+       <li><p>If the element is not now the first element in the
+       <span>list of scripts that will execute in order as soon as
+       possible</span> to which it was added above, then mark the
+       element as ready but abort these steps without executing the
+       script yet.</p></li>
+
+       <li><p><i>Execution</i>: <span title="executing a script
+       block">Execute the script block</span> corresponding to the
+       first script element in this <span>list of scripts that will
+       execute in order as soon as possible</span>.</p></li>
+
+       <li><p>Remove the first element from this <span>list of scripts
+       that will execute in order as soon as possible</span>.</p></li>
+
+       <li><p>If this <span>list of scripts that will execute in order
+       as soon as possible</span> is still not empty and the first
+       entry has already been marked as ready, then jump back to the
+       step labeled <i>execution</i>.</p></li>
+
+      </ol>
+
+     </dd>
+
+
      <dt id="script-processing-src">If the element has a <code
      title="attr-script-src">src</code> attribute</dt>
 
@@ -16354,12 +16429,23 @@
   <p>The IDL attributes <dfn
   title="dom-script-src"><code>src</code></dfn>, <dfn
   title="dom-script-type"><code>type</code></dfn>, <dfn
-  title="dom-script-charset"><code>charset</code></dfn>, <dfn
-  title="dom-script-async"><code>async</code></dfn>, and <dfn
+  title="dom-script-charset"><code>charset</code></dfn>, and <dfn
   title="dom-script-defer"><code>defer</code></dfn>, each must
   <span>reflect</span> the respective content attributes of the same
   name.</p>
 
+  <p>The <dfn title="dom-script-async"><code>async</code></dfn> IDL
+  attribute controls whether the element will execute asynchronously
+  or not. If the element's <span>"force-async"</span> flag is set,
+  then, on getting, the <code title="dom-script-async">async</code>
+  IDL attribute must return true, and on setting, the
+  <span>"force-async"</span> flag must first be unset, and then the
+  content attribute must be removed if the IDL attribute's new value
+  is false, and must be set to the empty string if the IDL attribute's
+  new value is true. If the element's <span>"force-async"</span> flag
+  is <em>not</em> set, the IDL attribute must <span>reflect</span> the
+  <code title="attr-script-async">async</code> content attribute.</p>
+
   </div>
 
   <dl class="domintro">
@@ -91728,7 +91814,8 @@
 
      <li>
 
-      <p>Mark the element as being <span>"parser-inserted"</span>.</p>
+      <p>Mark the element as being <span>"parser-inserted"</span> and
+      unset the element's <span>"force-async"</span> flag.</p>
 
       <p class="note">This ensures that, if the script is external,
       any <code title="dom-document-write">document.write()</code>
@@ -95099,11 +95186,14 @@
    <code>Document</code>.</p></li>
 
    <li><p><span>Spin the event loop</span> until the <span>set of
-   scripts that will execute as soon as possible</span> is
-   empty.</p></li> <!-- this step is redundant with the next one,
-   really, since all those scripts also delay the load event. It's
-   here in case we add an event between this step and the next or if
-   we move the previous step (DOMContentLoaded) down again. -->
+   scripts that will execute as soon as possible</span> and the
+   <span>list of scripts that will execute in order as soon as
+   possible</span> are empty.</p></li> <!-- this step is not redundant
+   with the next one, since <script> nodes delay the load event of the
+   document they are in, but they might change document between being
+   added to one document's set/list and executing those scripts, so
+   they might be delaying another document but still be in this
+   document's set/list. -->
 
    <li><p><span>Spin the event loop</span> until there is nothing that
    <dfn title="delay the load event">delays the load event</dfn> in
@@ -96255,13 +96345,14 @@
 
   <p id="scriptTagXML">When an <span>XML parser</span> creates a
   <code>script</code> element, it must be marked as being
-  <span>"parser-inserted"</span>.  If the parser was originally
-  created for the <span>XML fragment parsing algorithm</span>, then
-  the element must be marked as <span>"already started"</span>
-  also. When the element's end tag is parsed, the user agent must
-  <span title="running a script">run</span> the <code>script</code>
-  element. If this causes there to be a <span>pending parsing-blocking
-  script</span>, then the user agent must run the following steps:</p>
+  <span>"parser-inserted"</span> and its <span>"force-async"</span>
+  flag must be unset. If the parser was originally created for the
+  <span>XML fragment parsing algorithm</span>, then the element must
+  be marked as <span>"already started"</span> also. When the element's
+  end tag is parsed, the user agent must <span title="running a
+  script">run</span> the <code>script</code> element. If this causes
+  there to be a <span>pending parsing-blocking script</span>, then the
+  user agent must run the following steps:</p>
 
   <ol>
 

|