Skip to content

Commit

Permalink
[giow] (2) An attempt at making non-parser scripts inserted while the…
Browse files Browse the repository at this point in the history
… 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

git-svn-id: http://svn.whatwg.org/webapps@5157 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jul 14, 2010
1 parent 1db83ad commit ed34f61
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 3 deletions.
53 changes: 52 additions & 1 deletion complete.html
Expand Up @@ -11243,6 +11243,14 @@ <h4 id=document.write()><span class=secno>3.5.3 </span><code title=dom-document-

</li>

<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
Expand Down Expand Up @@ -13811,7 +13819,16 @@ <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn>
<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>
Expand Down Expand Up @@ -13930,6 +13947,16 @@ <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn>

</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>
Expand Down Expand Up @@ -14170,6 +14197,23 @@ <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn>

</dl></li>

<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
Expand All @@ -14182,6 +14226,13 @@ <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn>

</li>

<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
Expand Down
53 changes: 52 additions & 1 deletion index
Expand Up @@ -11167,6 +11167,14 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0

</li>

<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
Expand Down Expand Up @@ -13735,7 +13743,16 @@ c-end = "--&gt;"</pre>
<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>
Expand Down Expand Up @@ -13854,6 +13871,16 @@ c-end = "--&gt;"</pre>

</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>
Expand Down Expand Up @@ -14094,6 +14121,23 @@ c-end = "--&gt;"</pre>

</dl></li>

<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
Expand All @@ -14106,6 +14150,13 @@ c-end = "--&gt;"</pre>

</li>

<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
Expand Down
56 changes: 55 additions & 1 deletion source
Expand Up @@ -11567,6 +11567,14 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0

</li>

<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
Expand Down Expand Up @@ -14508,7 +14516,17 @@ c-end = "-->"</pre>
<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>
Expand Down Expand Up @@ -14665,6 +14683,16 @@ c-end = "-->"</pre>

</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>
Expand Down Expand Up @@ -14938,6 +14966,24 @@ c-end = "-->"</pre>

</li>

<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
Expand All @@ -14950,6 +14996,14 @@ c-end = "-->"</pre>

</li>

<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
Expand Down

0 comments on commit ed34f61

Please sign in to comment.