[html5] r5157 - [giow] (2) An attempt at making non-parser scripts inserted while the parser is [...]

whatwg at whatwg.org whatwg at whatwg.org
Tue Jul 13 19:02:42 PDT 2010


Author: ianh
Date: 2010-07-13 19:02:41 -0700 (Tue, 13 Jul 2010)
New Revision: 5157

Modified:
   complete.html
   index
   source
Log:
[giow] (2) An attempt at making non-parser scripts inserted while the parser is running fail at document.write() rather than blowing away the document.
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=9767

Modified: complete.html
===================================================================
--- complete.html	2010-07-14 00:45:45 UTC (rev 5156)
+++ complete.html	2010-07-14 02:02:41 UTC (rev 5157)
@@ -11245,6 +11245,14 @@
 
    <li>
 
+    <p>If the <a href=#insertion-point>insertion point</a> is undefined and the
+    <code><a href=#document>Document</a></code> has the <a href=#write-neutralised>"write-neutralised"</a>
+    flag set, then abort these steps.</p>
+
+   </li>
+
+   <li>
+
     <p>If the <a href=#insertion-point>insertion point</a> is undefined, the <code title=dom-document-open><a href=#dom-document-open>open()</a></code> method must be called
     (with no arguments) on the <code title=Document><a href=#document>document</a></code>
     object. If the user <a href=#refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be
@@ -13811,7 +13819,16 @@
   <a href=#parser-inserted>"parser-inserted"</a>, to let the parser know when to
   execute the script.</p>
 
-  <p>The fourth and fifth pieces of state are <dfn id="the-script-block's-type"><var>the script
+  <p>The fourth is a flag indicating whether or not the script block
+  is <dfn id=write-neutralised>"write-neutralised"</dfn>. Initially, <code><a href=#script>script</a></code>
+  elements must have this flag unset (script blocks, when created, are
+  not "write-neutralised"). This flag is used to ensure that scripts
+  <em>not</em> inserted by the parser but inserted while a parser is
+  active do not blow away the document if they use the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code>
+  API. <code><a href=#document>Document</a></code> objects can also have this flag set; it's
+  propagated to the <code><a href=#document>Document</a></code> when the script runs.</p>
+
+  <p>The fifth and sixth pieces of state are <dfn id="the-script-block's-type"><var>the script
   block's type</var></dfn> and <dfn id="the-script-block's-character-encoding"><var>the script block's character
   encoding</var></dfn>. They are determined when the script is run,
   based on the attributes on the element at that time.</p>
@@ -13930,6 +13947,16 @@
 
    </li>
 
+   <li>
+
+    <p>If the element's <code><a href=#document>Document</a></code> has an <a href=#active-parser>active
+    parser</a>, and the parser's <a href=#script-nesting-level>script nesting level</a>
+    is non-zero, but this <code><a href=#script>script</a></code> element does not have
+    the <a href=#parser-inserted>"parser-inserted"</a> flag set, the user agent must
+    set the element's <a href=#write-neutralised>"write-neutralised"</a> flag.</p>
+
+   </li>
+
    <li id=script-processing-src-prepare>
 
     <p>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code>
@@ -14172,6 +14199,23 @@
 
      <li>
 
+      <p>If the <code><a href=#script>script</a></code> element's
+      <a href=#write-neutralised>"write-neutralised"</a> flag is set, then flag the
+      <code><a href=#document>Document</a></code> the <code><a href=#script>script</a></code> element was in
+      when the <a href=#write-neutralised>"write-neutralised"</a> flag was set as being
+      itself <a href=#write-neutralised>"write-neutralised"</a>. Let <var title="">neutralised doc</var> be that
+      <code><a href=#document>Document</a></code>.</p>
+
+      <!-- theorem: this can only happen when the parser nesting
+      levels of all parsers on this thread are zero, so any scripts
+      inserted while this is true will not themselves have the flag
+      said, so we don't have to worry about this being a counter
+      instead of just a boolean. -->
+
+     </li>
+
+     <li>
+
       <p><a href=#create-a-script-from-a-node title="create a script from a node">Create a
       script</a> from the <code><a href=#script>script</a></code> element node, using
       <var><a href="#the-script-block's-source">the script block's source</a></var> and <var><a href="#the-script-block's-type">the script
@@ -14184,6 +14228,13 @@
 
      <li>
 
+      <p>Remove the <a href=#write-neutralised>"write-neutralised"</a> flag from <var title="">neutralised doc</var>, if it was set in the earlier
+      step.</p>
+
+     </li>
+
+     <li>
+
       <p>If the script is from an external file, <a href=#fire-a-simple-event>fire a simple
       event</a> named <code title=event-load>load</code> at the
       <code><a href=#script>script</a></code> element.</p>

Modified: index
===================================================================
--- index	2010-07-14 00:45:45 UTC (rev 5156)
+++ index	2010-07-14 02:02:41 UTC (rev 5157)
@@ -11169,6 +11169,14 @@
 
    <li>
 
+    <p>If the <a href=#insertion-point>insertion point</a> is undefined and the
+    <code><a href=#document>Document</a></code> has the <a href=#write-neutralised>"write-neutralised"</a>
+    flag set, then abort these steps.</p>
+
+   </li>
+
+   <li>
+
     <p>If the <a href=#insertion-point>insertion point</a> is undefined, the <code title=dom-document-open><a href=#dom-document-open>open()</a></code> method must be called
     (with no arguments) on the <code title=Document><a href=#document>document</a></code>
     object. If the user <a href=#refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be
@@ -13735,7 +13743,16 @@
   <a href=#parser-inserted>"parser-inserted"</a>, to let the parser know when to
   execute the script.</p>
 
-  <p>The fourth and fifth pieces of state are <dfn id="the-script-block's-type"><var>the script
+  <p>The fourth is a flag indicating whether or not the script block
+  is <dfn id=write-neutralised>"write-neutralised"</dfn>. Initially, <code><a href=#script>script</a></code>
+  elements must have this flag unset (script blocks, when created, are
+  not "write-neutralised"). This flag is used to ensure that scripts
+  <em>not</em> inserted by the parser but inserted while a parser is
+  active do not blow away the document if they use the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code>
+  API. <code><a href=#document>Document</a></code> objects can also have this flag set; it's
+  propagated to the <code><a href=#document>Document</a></code> when the script runs.</p>
+
+  <p>The fifth and sixth pieces of state are <dfn id="the-script-block's-type"><var>the script
   block's type</var></dfn> and <dfn id="the-script-block's-character-encoding"><var>the script block's character
   encoding</var></dfn>. They are determined when the script is run,
   based on the attributes on the element at that time.</p>
@@ -13854,6 +13871,16 @@
 
    </li>
 
+   <li>
+
+    <p>If the element's <code><a href=#document>Document</a></code> has an <a href=#active-parser>active
+    parser</a>, and the parser's <a href=#script-nesting-level>script nesting level</a>
+    is non-zero, but this <code><a href=#script>script</a></code> element does not have
+    the <a href=#parser-inserted>"parser-inserted"</a> flag set, the user agent must
+    set the element's <a href=#write-neutralised>"write-neutralised"</a> flag.</p>
+
+   </li>
+
    <li id=script-processing-src-prepare>
 
     <p>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code>
@@ -14096,6 +14123,23 @@
 
      <li>
 
+      <p>If the <code><a href=#script>script</a></code> element's
+      <a href=#write-neutralised>"write-neutralised"</a> flag is set, then flag the
+      <code><a href=#document>Document</a></code> the <code><a href=#script>script</a></code> element was in
+      when the <a href=#write-neutralised>"write-neutralised"</a> flag was set as being
+      itself <a href=#write-neutralised>"write-neutralised"</a>. Let <var title="">neutralised doc</var> be that
+      <code><a href=#document>Document</a></code>.</p>
+
+      <!-- theorem: this can only happen when the parser nesting
+      levels of all parsers on this thread are zero, so any scripts
+      inserted while this is true will not themselves have the flag
+      said, so we don't have to worry about this being a counter
+      instead of just a boolean. -->
+
+     </li>
+
+     <li>
+
       <p><a href=#create-a-script-from-a-node title="create a script from a node">Create a
       script</a> from the <code><a href=#script>script</a></code> element node, using
       <var><a href="#the-script-block's-source">the script block's source</a></var> and <var><a href="#the-script-block's-type">the script
@@ -14108,6 +14152,13 @@
 
      <li>
 
+      <p>Remove the <a href=#write-neutralised>"write-neutralised"</a> flag from <var title="">neutralised doc</var>, if it was set in the earlier
+      step.</p>
+
+     </li>
+
+     <li>
+
       <p>If the script is from an external file, <a href=#fire-a-simple-event>fire a simple
       event</a> named <code title=event-load>load</code> at the
       <code><a href=#script>script</a></code> element.</p>

Modified: source
===================================================================
--- source	2010-07-14 00:45:45 UTC (rev 5156)
+++ source	2010-07-14 02:02:41 UTC (rev 5157)
@@ -11569,6 +11569,14 @@
 
    <li>
 
+    <p>If the <span>insertion point</span> is undefined and the
+    <code>Document</code> has the <span>"write-neutralised"</span>
+    flag set, then abort these steps.</p>
+
+   </li>
+
+   <li>
+
     <p>If the <span>insertion point</span> is undefined, the <code
     title="dom-document-open">open()</code> method must be called
     (with no arguments) on the <code title="Document">document</code>
@@ -14508,7 +14516,17 @@
   <span>"parser-inserted"</span>, to let the parser know when to
   execute the script.</p>
 
-  <p>The fourth and fifth pieces of state are <dfn><var>the script
+  <p>The fourth is a flag indicating whether or not the script block
+  is <dfn>"write-neutralised"</dfn>. Initially, <code>script</code>
+  elements must have this flag unset (script blocks, when created, are
+  not "write-neutralised"). This flag is used to ensure that scripts
+  <em>not</em> inserted by the parser but inserted while a parser is
+  active do not blow away the document if they use the <code
+  title="dom-document-write">document.write()</code>
+  API. <code>Document</code> objects can also have this flag set; it's
+  propagated to the <code>Document</code> when the script runs.</p>
+
+  <p>The fifth and sixth pieces of state are <dfn><var>the script
   block's type</var></dfn> and <dfn><var>the script block's character
   encoding</var></dfn>. They are determined when the script is run,
   based on the attributes on the element at that time.</p>
@@ -14665,6 +14683,16 @@
 
    </li>
 
+   <li>
+
+    <p>If the element's <code>Document</code> has an <span>active
+    parser</span>, and the parser's <span>script nesting level</span>
+    is non-zero, but this <code>script</code> element does not have
+    the <span>"parser-inserted"</span> flag set, the user agent must
+    set the element's <span>"write-neutralised"</span> flag.</p>
+
+   </li>
+
    <li id="script-processing-src-prepare">
 
     <p>If the element has a <code title="attr-script-src">src</code>
@@ -14940,6 +14968,24 @@
 
      <li>
 
+      <p>If the <code>script</code> element's
+      <span>"write-neutralised"</span> flag is set, then flag the
+      <code>Document</code> the <code>script</code> element was in
+      when the <span>"write-neutralised"</span> flag was set as being
+      itself <span>"write-neutralised"</span>. Let <var
+      title="">neutralised doc</var> be that
+      <code>Document</code>.</p>
+
+      <!-- theorem: this can only happen when the parser nesting
+      levels of all parsers on this thread are zero, so any scripts
+      inserted while this is true will not themselves have the flag
+      said, so we don't have to worry about this being a counter
+      instead of just a boolean. -->
+
+     </li>
+
+     <li>
+
       <p><span title="create a script from a node">Create a
       script</span> from the <code>script</code> element node, using
       <var>the script block's source</var> and <var>the script
@@ -14952,6 +14998,14 @@
 
      <li>
 
+      <p>Remove the <span>"write-neutralised"</span> flag from <var
+      title="">neutralised doc</var>, if it was set in the earlier
+      step.</p>
+
+     </li>
+
+     <li>
+
       <p>If the script is from an external file, <span>fire a simple
       event</span> named <code title="event-load">load</code> at the
       <code>script</code> element.</p>




More information about the Commit-Watchers mailing list