Skip to content
Permalink
Browse files

[giow] (2) Make a parser-inserted script not run if it is moved to an…

…other document before it executes (and not even fetch if it is parsed into another document than its parser's document).

Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=11323

git-svn-id: http://svn.whatwg.org/webapps@5883 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
Hixie committed Feb 14, 2011
1 parent b23d30a commit 7c52fca3722ede5d22c9de19356c5d5495640b2a
Showing with 486 additions and 388 deletions.
  1. +154 −123 complete.html
  2. +154 −123 index
  3. +178 −142 source

</li>

<li>

<p>If the element is flagged as <a href=#parser-inserted>"parser-inserted"</a>,
but the element's <code><a href=#document>Document</a></code> is not the
<code><a href=#document>Document</a></code> of the parser that created the element, then
abort these steps.</p>

</li>

<li id=script-processing-noscript>

<p>If <a href=#concept-n-noscript title=concept-n-noscript>scripting is
style sheets are blocking which scripts -->

<p>When the user agent is required to <dfn id=execute-the-script-block title="execute the script
block">execute a script block</dfn>, it must act as follows:</p>
block">execute a script block</dfn>, it must run the following
steps:</p>

<dl class=switch><dt>If the load resulted in an error (for example a DNS error, or
an HTTP 404 error)</dt>
<ol><li>

<dd><p>Executing the script block must just consist of <a href=#fire-a-simple-event title="fire a simple event">firing a simple event</a> named
<code title=event-error>error</code> at the element.</dd>
<p>If the element is flagged as <a href=#parser-inserted>"parser-inserted"</a>,
but the element's <code><a href=#document>Document</a></code> is not the
<code><a href=#document>Document</a></code> of the parser that created the element, then
abort these steps.</p>

<dt>If the load was successful</dt>
</li>

<!-- SCRIPT EXEC -->
<dd>
<li>

<p>Executing the script block must consists of running the
following steps. For the purposes of these steps, the script is
considered to be from an <i>external file</i> if, while the
<a href=#prepare-a-script>prepare a script</a> algorithm above was running for this
script, the <code><a href=#script>script</a></code> element had a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute specified.</p>
<p>Jump to the appropriate set of steps from the list below:</p>

<ol><li id=establish-script-block-source>
<dl class=switch><dt>If the load resulted in an error (for example a DNS error, or
an HTTP 404 error)</dt>

<p>Initialize <dfn id="the-script-block's-source"><var>the script block's source</var></dfn> as
follows:</p>
<dd><p>Executing the script block must just consist of <a href=#fire-a-simple-event title="fire a simple event">firing a simple event</a> named
<code title=event-error>error</code> at the element.</dd>

<dl class=switch><dt>If the script is from an external file and <var><a href="#the-script-block's-type">the script block's type</a></var> is a text-based language</dt>
<dt>If the load was successful</dt>

<dd>
<!-- SCRIPT EXEC -->
<dd>

<p>The contents of that file, interpreted as string of
Unicode characters, are the script source.</p>

<p>To obtain the string of Unicode characters, the user agent
run the following steps:</p>

<ol><li><p>If the resource's <a href=#content-type title=Content-Type>Content
Type metadata</a>, if any, specifies a character encoding,
and the user agent supports that encoding, then let <var title="">character encoding</var> be that encoding, and jump
to the bottom step in this series of steps.</li>

<li><p>If the algorithm above set <var><a href="#the-script-block's-character-encoding">the script block's
character encoding</a></var>, then let <var title="">character
encoding</var> be that encoding, and jump to the bottom step
in this series of steps.</li>

<li><p>For each of the rows in the following table, starting
with the first one and going down, if the file has as many or
more bytes available than the number of bytes in the first
column, and the first bytes of the file match the bytes given
in the first column, then set <var title="">character
encoding</var> to the encoding given in the cell in the
second column of that row, and jump to the bottom step in
this series of steps:</p>

<!-- this table is present in several forms in this file; keep them in sync -->
<table id=table-script-bom><thead><tr><th>Bytes in Hexadecimal
<th>Encoding
<tbody><!-- nobody uses this
<tr>
<td>00 00 FE FF
<td>UTF-32BE
<tr>
<td>FF FE 00 00
<td>UTF-32LE
--><tr><td>FE FF
<td>Big-endian UTF-16
<tr><td>FF FE
<td>Little-endian UTF-16
<tr><td>EF BB BF
<td>UTF-8
<!-- nobody uses this
<tr>
<td>DD 73 66 73
<td>UTF-EBCDIC
-->
</table><p class=note>This step looks for Unicode Byte Order Marks
(BOMs).</p>
<p>Executing the script block must consists of running the
following steps. For the purposes of these steps, the script is
considered to be from an <i>external file</i> if, while the
<a href=#prepare-a-script>prepare a script</a> algorithm above was running for
this script, the <code><a href=#script>script</a></code> element had a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute specified.</p>

</li>
<ol><li id=establish-script-block-source>

<li><p>Let <var title="">character encoding</var> be <var><a href="#the-script-block's-fallback-character-encoding">the
script block's fallback character encoding</a></var>.</li>
<p>Initialize <dfn id="the-script-block's-source"><var>the script block's source</var></dfn>
as follows:</p>

<li><p>Convert the file to Unicode using <var>character
encoding</var>, following the rules for doing so given by the
specification for <var><a href="#the-script-block's-type">the script block's
type</a></var>.</li>
<dl class=switch><dt>If the script is from an external file and <var><a href="#the-script-block's-type">the
script block's type</a></var> is a text-based language</dt>

</ol></dd>
<dd>

<dt>If the script is from an external file and <var><a href="#the-script-block's-type">the script block's type</a></var> is an XML-based language</dt>
<p>The contents of that file, interpreted as string of
Unicode characters, are the script source.</p>

<p>To obtain the string of Unicode characters, the user
agent run the following steps:</p>

<ol><li><p>If the resource's <a href=#content-type title=Content-Type>Content
Type metadata</a>, if any, specifies a character
encoding, and the user agent supports that encoding, then
let <var title="">character encoding</var> be that
encoding, and jump to the bottom step in this series of
steps.</li>

<li><p>If the algorithm above set <var><a href="#the-script-block's-character-encoding">the script block's
character encoding</a></var>, then let <var title="">character
encoding</var> be that encoding, and jump to the bottom
step in this series of steps.</li>

<li><p>For each of the rows in the following table,
starting with the first one and going down, if the file has
as many or more bytes available than the number of bytes in
the first column, and the first bytes of the file match the
bytes given in the first column, then set <var title="">character encoding</var> to the encoding given in
the cell in the second column of that row, and jump to the
bottom step in this series of steps:</p>

<!-- this table is present in several forms in this file; keep them in sync -->
<table id=table-script-bom><thead><tr><th>Bytes in Hexadecimal
<th>Encoding
<tbody><!-- nobody uses this
<tr>
<td>00 00 FE FF
<td>UTF-32BE
<tr>
<td>FF FE 00 00
<td>UTF-32LE
--><tr><td>FE FF
<td>Big-endian UTF-16
<tr><td>FF FE
<td>Little-endian UTF-16
<tr><td>EF BB BF
<td>UTF-8
<!-- nobody uses this
<tr>
<td>DD 73 66 73
<td>UTF-EBCDIC
-->
</table><p class=note>This step looks for Unicode Byte Order
Marks (BOMs).</p>

<dd>
</li>

<p>The external file is the script source. When it is later
executed, it must be interpreted in a manner consistent with
the specification defining the language given by <var><a href="#the-script-block's-type">the
script block's type</a></var>.</p>
<li><p>Let <var title="">character encoding</var> be
<var><a href="#the-script-block's-fallback-character-encoding">the script block's fallback character
encoding</a></var>.</li>

</dd>
<li><p>Convert the file to Unicode using <var>character
encoding</var>, following the rules for doing so given by
the specification for <var><a href="#the-script-block's-type">the script block's
type</a></var>.</li>

<dt>If the script is inline and <var><a href="#the-script-block's-type">the script block's type</a></var> is a text-based language</dt>
</ol></dd>

<dd>
<dt>If the script is from an external file and <var><a href="#the-script-block's-type">the
script block's type</a></var> is an XML-based language</dt>

<p>The value of the <code title=dom-script-text><a href=#dom-script-text>text</a></code>
IDL attribute at the time the element's <a href=#already-started>"already
started"</a> flag was last set is the script source.</p>
<dd>

</dd>
<p>The external file is the script source. When it is later
executed, it must be interpreted in a manner consistent with
the specification defining the language given by <var><a href="#the-script-block's-type">the
script block's type</a></var>.</p>

<dt>If the script is inline and <var><a href="#the-script-block's-type">the script block's type</a></var> is an XML-based language</dt>
</dd>

<dd>
<dt>If the script is inline and <var><a href="#the-script-block's-type">the script block's
type</a></var> is a text-based language</dt>

<p>The child nodes of the <code><a href=#script>script</a></code> element at the
time the element's <a href=#already-started>"already started"</a> flag was
last set are the script source.</p>
<dd>

</dd>
<p>The value of the <code title=dom-script-text><a href=#dom-script-text>text</a></code> IDL attribute at the
time the element's <a href=#already-started>"already started"</a> flag was
last set is the script source.</p>

</dl></li>
</dd>

<li>
<dt>If the script is inline and <var><a href="#the-script-block's-type">the script block's
type</a></var> is an XML-based language</dt>

<p>If the script is from an external file, then increment the
<a href=#ignore-destructive-writes-counter>ignore-destructive-writes counter</a> of the
<code><a href=#script>script</a></code> element's <code><a href=#document>Document</a></code>. Let <var title="">neutralized doc</var> be that
<code><a href=#document>Document</a></code>.</p>
<dd>

</li>
<p>The child nodes of the <code><a href=#script>script</a></code> element at the
time the element's <a href=#already-started>"already started"</a> flag was
last set are the script source.</p>

<li>
</dd>

<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
block's type</a></var>.</p>
</dl></li>

<p class=note>This is where the script is compiled and
actually executed.</p>
<li>

</li>
<p>If the script is from an external file, then increment the
<a href=#ignore-destructive-writes-counter>ignore-destructive-writes counter</a> of the
<code><a href=#script>script</a></code> element's <code><a href=#document>Document</a></code>. Let <var title="">neutralized doc</var> be that
<code><a href=#document>Document</a></code>.</p>

<li>
</li>

<p>Decrement the <a href=#ignore-destructive-writes-counter>ignore-destructive-writes counter</a>
of <var title="">neutralized doc</var>, if it was incremented in
the earlier step.</p>
<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
block's type</a></var>.</p>

<li>
<p class=note>This is where the script is compiled and
actually executed.</p>

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

<p>Otherwise, the script is internal; <a href=#queue-a-task>queue a task</a>
to <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>
<p>Decrement the <a href=#ignore-destructive-writes-counter>ignore-destructive-writes
counter</a> of <var title="">neutralized doc</var>, if it
was incremented in the earlier step.</p>

</li>
</li>

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

<p>Otherwise, the script is internal; <a href=#queue-a-task>queue a
task</a> to <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>

</li>

</ol></dd>

</dl></li>

</dl><p>The IDL attributes <dfn id=dom-script-src title=dom-script-src><code>src</code></dfn>, <dfn id=dom-script-type title=dom-script-type><code>type</code></dfn>, <dfn id=dom-script-charset title=dom-script-charset><code>charset</code></dfn>, and <dfn id=dom-script-defer title=dom-script-defer><code>defer</code></dfn>, each must
</ol><p>The IDL attributes <dfn id=dom-script-src title=dom-script-src><code>src</code></dfn>, <dfn id=dom-script-type title=dom-script-type><code>type</code></dfn>, <dfn id=dom-script-charset title=dom-script-charset><code>charset</code></dfn>, and <dfn id=dom-script-defer title=dom-script-defer><code>defer</code></dfn>, each must
<a href=#reflect>reflect</a> the respective content attributes of the same
name.</p>

0 comments on commit 7c52fca

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