Skip to content
Permalink
Browse files

[giow] (3) Fix an infinite loop. There's no interop here, really, so …

…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 f8c7a29c2c8ac5728c96f8efa8f8c4bbae4490dd
Showing with 167 additions and 53 deletions.
  1. +54 −18 complete.html
  2. +54 −18 index
  3. +59 −17 source

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

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

<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

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

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

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

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

Oops, something went wrong.

0 comments on commit f8c7a29

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