Skip to content

Commit

Permalink
[e] (0) Update some examples in line with spec changes.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@6141 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed May 16, 2011
1 parent 04cab94 commit 6e3a0e7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 62 deletions.
37 changes: 17 additions & 20 deletions complete.html
Original file line number Diff line number Diff line change
Expand Up @@ -88895,38 +88895,35 @@ <h5 id=misnested-tags:-b-i-/b-/i><span class=secno>13.2.8.1 </span>Misnested tag
is inserted <em>into the outer <code><a href=#document>Document</a></code>
object</em>.</p>

<p>This also means that the <a href="#script's-global-object">script's global object</a> is
the outer <a href=#browsing-context>browsing context</a>'s <code><a href=#window>Window</a></code>
object, <em>not</em> the <code><a href=#window>Window</a></code> object inside the
<code><a href=#the-iframe-element>iframe</a></code>.</p>

<p class=note>This isn't a security problem since the script that
moves the <code><a href=#the-div-element>div</a></code> into the outer <code><a href=#document>Document</a></code> can
only do so because the two <code><a href=#document>Document</a></code> object have the
same <a href=#origin>origin</a>.</p>

<p>Thus, the first alert says "http://example.com/outer".</p>
<p>This parsed into different <code><a href=#document>Document</a></code>s than the one
the parser was created for do not execute, so the first alert does
not show.</p>

<p>Once the <code><a href=#the-div-element>div</a></code> element's end tag is parsed, the
<code><a href=#the-div-element>div</a></code> element is popped off the stack, and so the next
<code><a href=#the-script-element>script</a></code> element is in the inner <code><a href=#document>Document</a></code>:</p>

<ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This second alert will say "http://example.com/inner".</p>
<ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This script does execute, resulting in an alert that says "http://example.com/inner".</p>


<h5 id=the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>13.2.8.5 </span>The execution of scripts that are moving across multiple documents</h5>

<p><i>This section is non-normative.</i></p>

<p>Elaborating on the example in the previous section, consider a
case where a <code><a href=#the-script-element>script</a></code> element with a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is parsed, but while
the external script is being downloaded, the element is moved to
another document.</p>
<p>Elaborating on the example in the previous section, consider the
case where the second <code><a href=#the-script-element>script</a></code> element is an external
script (i.e. one with a <code title=attr-script-src><a href=#attr-script-src>src</a></code>
attribute). Since the element was not in the parser's
<code><a href=#document>Document</a></code> when it was created, that external script is
not even downloaded.</p>

<p>In a case where a <code><a href=#the-script-element>script</a></code> element with a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is parsed normally into
its parser's <code><a href=#document>Document</a></code>, but while the external script is
being downloaded, the element is moved to another document, the
script continues to download, but does not execute.</p>

<p>In this case, the <a href="#script's-global-object">script's global object</a> is that
second document's <a href=#browsing-context>browsing context</a>'s
<code><a href=#window>Window</a></code> object, not the <code><a href=#window>Window</a></code> object of
the document into which the element was parsed.</p>
<p class=note>In general, moving <code><a href=#the-script-element>script</a></code> elements
between <code><a href=#document>Document</a></code>s is considered a bad practice.</p>



Expand Down
37 changes: 17 additions & 20 deletions index
Original file line number Diff line number Diff line change
Expand Up @@ -84868,38 +84868,35 @@ document.body.appendChild(text);
is inserted <em>into the outer <code><a href=#document>Document</a></code>
object</em>.</p>

<p>This also means that the <a href="#script's-global-object">script's global object</a> is
the outer <a href=#browsing-context>browsing context</a>'s <code><a href=#window>Window</a></code>
object, <em>not</em> the <code><a href=#window>Window</a></code> object inside the
<code><a href=#the-iframe-element>iframe</a></code>.</p>

<p class=note>This isn't a security problem since the script that
moves the <code><a href=#the-div-element>div</a></code> into the outer <code><a href=#document>Document</a></code> can
only do so because the two <code><a href=#document>Document</a></code> object have the
same <a href=#origin>origin</a>.</p>

<p>Thus, the first alert says "http://example.com/outer".</p>
<p>This parsed into different <code><a href=#document>Document</a></code>s than the one
the parser was created for do not execute, so the first alert does
not show.</p>

<p>Once the <code><a href=#the-div-element>div</a></code> element's end tag is parsed, the
<code><a href=#the-div-element>div</a></code> element is popped off the stack, and so the next
<code><a href=#the-script-element>script</a></code> element is in the inner <code><a href=#document>Document</a></code>:</p>

<ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This second alert will say "http://example.com/inner".</p>
<ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This script does execute, resulting in an alert that says "http://example.com/inner".</p>


<h5 id=the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>11.2.8.5 </span>The execution of scripts that are moving across multiple documents</h5>

<p><i>This section is non-normative.</i></p>

<p>Elaborating on the example in the previous section, consider a
case where a <code><a href=#the-script-element>script</a></code> element with a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is parsed, but while
the external script is being downloaded, the element is moved to
another document.</p>
<p>Elaborating on the example in the previous section, consider the
case where the second <code><a href=#the-script-element>script</a></code> element is an external
script (i.e. one with a <code title=attr-script-src><a href=#attr-script-src>src</a></code>
attribute). Since the element was not in the parser's
<code><a href=#document>Document</a></code> when it was created, that external script is
not even downloaded.</p>

<p>In a case where a <code><a href=#the-script-element>script</a></code> element with a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is parsed normally into
its parser's <code><a href=#document>Document</a></code>, but while the external script is
being downloaded, the element is moved to another document, the
script continues to download, but does not execute.</p>

<p>In this case, the <a href="#script's-global-object">script's global object</a> is that
second document's <a href=#browsing-context>browsing context</a>'s
<code><a href=#window>Window</a></code> object, not the <code><a href=#window>Window</a></code> object of
the document into which the element was parsed.</p>
<p class=note>In general, moving <code><a href=#the-script-element>script</a></code> elements
between <code><a href=#document>Document</a></code>s is considered a bad practice.</p>



Expand Down
41 changes: 19 additions & 22 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -100885,41 +100885,38 @@ document.body.appendChild(text);
is inserted <em>into the outer <code>Document</code>
object</em>.</p>

<p>This also means that the <span>script's global object</span> is
the outer <span>browsing context</span>'s <code>Window</code>
object, <em>not</em> the <code>Window</code> object inside the
<code>iframe</code>.</p>

<p class="note">This isn't a security problem since the script that
moves the <code>div</code> into the outer <code>Document</code> can
only do so because the two <code>Document</code> object have the
same <span>origin</span>.</p>

<p>Thus, the first alert says "http://example.com/outer".</p>
<p>This parsed into different <code>Document</code>s than the one
the parser was created for do not execute, so the first alert does
not show.</p>

<p>Once the <code>div</code> element's end tag is parsed, the
<code>div</code> element is popped off the stack, and so the next
<code>script</code> element is in the inner <code>Document</code>:</p>

<ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>script</code><ul><li class="t3"><code>#text</code>: <span title="">alert(document.URL);</span></li></ul></li></ul></li></ul></li></ul>

<p>This second alert will say "http://example.com/inner".</p>
<p>This script does execute, resulting in an alert that says "http://example.com/inner".</p>


<h5>The execution of scripts that are moving across multiple documents</h5>

<!--END dev-html--><p><i>This section is non-normative.</i></p><!--START dev-html-->

<p>Elaborating on the example in the previous section, consider a
case where a <code>script</code> element with a <code
title="attr-script-src">src</code> attribute is parsed, but while
the external script is being downloaded, the element is moved to
another document.</p>

<p>In this case, the <span>script's global object</span> is that
second document's <span>browsing context</span>'s
<code>Window</code> object, not the <code>Window</code> object of
the document into which the element was parsed.</p>
<p>Elaborating on the example in the previous section, consider the
case where the second <code>script</code> element is an external
script (i.e. one with a <code title="attr-script-src">src</code>
attribute). Since the element was not in the parser's
<code>Document</code> when it was created, that external script is
not even downloaded.</p>

<p>In a case where a <code>script</code> element with a <code
title="attr-script-src">src</code> attribute is parsed normally into
its parser's <code>Document</code>, but while the external script is
being downloaded, the element is moved to another document, the
script continues to download, but does not execute.</p>

<p class="note">In general, moving <code>script</code> elements
between <code>Document</code>s is considered a bad practice.</p>



Expand Down

0 comments on commit 6e3a0e7

Please sign in to comment.