Skip to content

Commit

Permalink
[giow] (3) Fix an infinite loop. There's no interop here, really, so …
Browse files Browse the repository at this point in the history
…I tried to find a compromise between what browsers do and keeping the requirements sane and simple. Tests at: http://www.hixie.ch/tests/adhoc/dom/level0/document/open/unload/ -- See also IRC ranting starting at http://krijnhoetmer.nl/irc-logs/whatwg/20120831#l-67 and ending at http://krijnhoetmer.nl/irc-logs/whatwg/20120901#l-140

Affected topics: HTML, HTML Syntax and Parsing

git-svn-id: http://svn.whatwg.org/webapps@7304 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Aug 31, 2012
1 parent bf9f7d3 commit f8c7a29
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 53 deletions.
72 changes: 54 additions & 18 deletions complete.html
Expand Up @@ -246,7 +246,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 30 August 2012</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 31 August 2012</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
Expand Down Expand Up @@ -13988,7 +13988,14 @@ <h4 id=opening-the-input-stream><span class=secno>3.4.1 </span>Opening the input

</dl><div class=impl>

<p>When called with two or fewer arguments, the method must act as
<p><code><a href=#document>Document</a></code> objects have an
<dfn id=ignore-opens-during-unload-counter>ignore-opens-during-unload counter</dfn>, which is used to
prevent scripts from invoking the <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> method (directly or
indirectly) while the document is <a href=#unload-a-document title="unload a
document">being unloaded</a>. Initially, the counter must be set
to zero.</p> <!-- http://www.hixie.ch/tests/adhoc/dom/level0/document/open/unload/ -->

<p>When called with two or fewer arguments, the <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> method must act as
follows:</p>

<ol><li>If the <code><a href=#document>Document</a></code> object is not flagged as an <a href=#html-documents title="HTML documents">HTML document</a>, throw an
Expand All @@ -14005,13 +14012,13 @@ <h4 id=opening-the-input-stream><span class=secno>3.4.1 </span>Opening the input

<li>

<p>If the document has an <a href=#active-parser>active parser</a> that isn't a
<a href=#script-created-parser>script-created parser</a>, and the <a href=#insertion-point>insertion
point</a> associated with that parser's <a href=#input-stream>input
stream</a> is not undefined (that is, it <em>does</em> point to
somewhere in the input stream), then the method does
nothing. Abort these steps and return the <code><a href=#document>Document</a></code>
object on which the method was invoked.</p>
<p>If the <code><a href=#document>Document</a></code> has an <a href=#active-parser>active parser</a>
that isn't a <a href=#script-created-parser>script-created parser</a>, and the
<a href=#insertion-point>insertion point</a> associated with that parser's
<a href=#input-stream>input stream</a> is not undefined (that is, it
<em>does</em> point to somewhere in the input stream), then the
method does nothing. Abort these steps and return the
<code><a href=#document>Document</a></code> object on which the method was invoked.</p>

<p class=note>This basically causes <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> to be ignored
when it's called in an inline script found during the parsing of
Expand All @@ -14021,6 +14028,20 @@ <h4 id=opening-the-input-stream><span class=secno>3.4.1 </span>Opening the input

</li>

<li>

<p>Similarly, if the <code><a href=#document>Document</a></code>'s
<a href=#ignore-opens-during-unload-counter>ignore-opens-during-unload counter</a> is greater than
zero, then the method does nothing. Abort these steps and return
the <code><a href=#document>Document</a></code> object on which the method was
invoked.</p>

<p class=note>This basically causes <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> to be ignored
when it's called from a <code title=event-beforeunload>beforeunload</code> <code title=event-pagehide><a href=#event-pagehide>pagehide</a></code>, or <code title=event-unload>unload</code> event handler while the
<code><a href=#document>Document</a></code> is being unloaded.</p>

</li>

<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

<li><p>Set the <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state to
Expand All @@ -14029,7 +14050,8 @@ <h4 id=opening-the-input-stream><span class=secno>3.4.1 </span>Opening the input
<li><p><a href=#prompt-to-unload-a-document title="prompt to unload a document">Prompt to
unload</a> the <code><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 unloaded</a>, then
these steps must be aborted.</li>
abort these steps and return the <code><a href=#document>Document</a></code> object on
which the method was invoked.</li>

<li><p><a href=#unload-a-document title="unload a document">Unload</a> the
<code><a href=#document>Document</a></code> object, with the <var title="">recycle</var>
Expand Down Expand Up @@ -14279,9 +14301,11 @@ <h4 id=document.write()><span class=secno>3.4.3 </span><code title=dom-document-

<li>

<p>If the <a href=#insertion-point>insertion point</a> is undefined and the
<code><a href=#document>Document</a></code>'s <a href=#ignore-destructive-writes-counter>ignore-destructive-writes
counter</a> is greater than zero, then abort these steps.</p>
<p>If the <a href=#insertion-point>insertion point</a> is undefined and either the
<code><a href=#document>Document</a></code>'s <a href=#ignore-opens-during-unload-counter>ignore-opens-during-unload
counter</a> is greater than zero or the <code><a href=#document>Document</a></code>'s
<a href=#ignore-destructive-writes-counter>ignore-destructive-writes counter</a> is greater than
zero, abort these steps.</p>

</li>

Expand Down Expand Up @@ -71451,6 +71475,9 @@ <h4 id=unloading-documents><span class=secno>6.6.11 </span>Unloading documents</
<ol><li><p>Increase the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination
nesting level</a> by one.</li>

<li><p>Increase the <code><a href=#document>Document</a></code>'s
<a href=#ignore-opens-during-unload-counter>ignore-opens-during-unload counter</a> by one.</li>

<li><p>Let <var title="">event</var> be a new
<code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> event object with the name <code title=event-beforeunload>beforeunload</code>, which does not
bubble but is cancelable.</li>
Expand Down Expand Up @@ -71491,7 +71518,7 @@ <h4 id=unloading-documents><span class=secno>6.6.11 </span>Unloading documents</
<li><p>If this algorithm was invoked by another instance of the
"prompt to unload a document" algorithm (i.e. through the steps
below that invoke this algorithm for all descendant browsing
contexts), then abort these steps here.</li>
contexts), then jump to the step labeled <i>end</i>.</li>

<li><p>Let <var title="">descendants</var> be the <a href=#list-of-the-descendant-browsing-contexts>list of the
descendant browsing contexts</a> of the
Expand All @@ -71509,7 +71536,7 @@ <h4 id=unloading-documents><span class=secno>6.6.11 </span>Unloading documents</
<a href=#refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be unloaded</a>, then
the user implicitly also <a href=#refused-to-allow-the-document-to-be-unloaded title="refused to allow the
document to be unloaded">refused to allow <em>this</em> document
to be unloaded</a>; abort these steps.</p>
to be unloaded</a>; jump to the step labeled <i>end</i>.</p>

<li><p>If <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state of
the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing
Expand All @@ -71518,6 +71545,9 @@ <h4 id=unloading-documents><span class=secno>6.6.11 </span>Unloading documents</

</ol></li>

<li><p><i>End</i>: Decrease the <code><a href=#document>Document</a></code>'s
<a href=#ignore-opens-during-unload-counter>ignore-opens-during-unload counter</a> by one.</li>

</ol><p>When a user agent is to <dfn id=unload-a-document>unload a document</dfn>, it must run
the following steps. These steps are passed an argument, <var title="">recycle</var>, which is either true or false, indicating
whether the <code><a href=#document>Document</a></code> object is going to be
Expand All @@ -71526,6 +71556,9 @@ <h4 id=unloading-documents><span class=secno>6.6.11 </span>Unloading documents</
<ol><li><p>Increase the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination
nesting level</a> by one.</li>

<li><p>Increase the <code><a href=#document>Document</a></code>'s
<a href=#ignore-opens-during-unload-counter>ignore-opens-during-unload counter</a> by one.</li>

<li><p>Fire a <code title=event-pagehide><a href=#event-pagehide>pagehide</a></code> event at
the <code><a href=#window>Window</a></code> object of the <code><a href=#document>Document</a></code>, but
with its <code title=dom-event-target><a href=#dom-event-target>target</a></code> set to the
Expand Down Expand Up @@ -71565,9 +71598,9 @@ <h4 id=unloading-documents><span class=secno>6.6.11 </span>Unloading documents</
<a href=#other-applicable-specifications>other applicable specifications</a>.</li>

<li><p>If this algorithm was invoked by another instance of the
"unload a document" algorithm (i.e. through the steps below that
invoke this algorithm for all descendant browsing contexts), then
abort these steps here.</li>
"unload a document" algorithm (i.e. by the steps below that invoke
this algorithm for all descendant browsing contexts), then jump to
the step labeled <i>end</i>.</li>

<li><p>Let <var title="">descendants</var> be the <a href=#list-of-the-descendant-browsing-contexts>list of the
descendant browsing contexts</a> of the
Expand Down Expand Up @@ -71595,6 +71628,9 @@ <h4 id=unloading-documents><span class=secno>6.6.11 </span>Unloading documents</
<code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> must <a href=#discard-a-document title="discard a document">discard the
<code>Document</code></a>.</li>

<li><p><i>End</i>: Decrease the <code><a href=#document>Document</a></code>'s
<a href=#ignore-opens-during-unload-counter>ignore-opens-during-unload counter</a> by one.</li>

</ol><p>This specification defines the following <dfn id=unloading-document-cleanup-steps>unloading document
cleanup steps</dfn>. Other specifications can define more.</p>

Expand Down

0 comments on commit f8c7a29

Please sign in to comment.