Skip to content
Permalink
Browse files

[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

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 ed34f6184f378ff5f67e3dea765ccc94065533b4
Showing with 159 additions and 3 deletions.
  1. +52 −1 complete.html
  2. +52 −1 index
  3. +55 −1 source

</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
<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>

</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>

</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

</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
53 index

</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
<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>

</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>

</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

</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
56 source
@@ -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
<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>

</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>

</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

</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

0 comments on commit ed34f61

Please sign in to comment.
You can’t perform that action at this time.