Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore document.open/write after the active parser has been aborted #4907

Merged
merged 3 commits into from
Oct 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -85198,7 +85198,6 @@ interface <dfn>BeforeUnloadEvent</dfn> : <span>Event</span> {
<p>To <dfn data-x="abort a document">abort</dfn> a <code>Document</code> <var>document</var>:</p>

<ol>

<li><p><span data-x="abort a document">Abort</span> the <span data-x="active document">active
documents</span> of every <span>child browsing context</span>. If this results in any of those
<code>Document</code> objects having their <i
Expand All @@ -85215,12 +85214,18 @@ interface <dfn>BeforeUnloadEvent</dfn> : <span>Event</span> {
discarded, then set <var>document</var>'s <i
data-x="concept-document-salvageable">salvageable</i> state to false.</p></li>

<li><p>If <var>document</var> has an <span>active parser</span>, then <span data-x="abort a
parser">abort that parser</span> and set <var>document</var>'s <i
data-x="concept-document-salvageable">salvageable</i> state to false.</p></li>
<li>
<p>If <var>document</var> has an <span>active parser</span>, then:</p>
domenic marked this conversation as resolved.
Show resolved Hide resolved

<ol>
<li><p>Set <var>document</var>'s <span>active parser was aborted</span> to true.</p></li>

<!-- we could also stop all script, or stop animations -->
<li><p><span data-x="abort a parser">Abort that parser</span>.</p></li>

<li><p>Set <var>document</var>'s <i data-x="concept-document-salvageable">salvageable</i> state
to false.</p></li>
</ol>
</li>
</ol>

<p>User agents may allow users to explicitly invoke the <span data-x="abort a document">abort a
Expand Down Expand Up @@ -93299,6 +93304,11 @@ document.body.appendChild(frame)</code></pre>
method (directly or indirectly) while the document is <span data-x="unload a document">being
unloaded</span>. Initially, the counter must be set to zero.</p>
domenic marked this conversation as resolved.
Show resolved Hide resolved

<p><code>Document</code> objects have an <dfn>active parser was aborted</dfn> boolean, which is
used to prevent scripts from invoking the <code data-x="dom-document-open">document.open()</code>
and <code data-x="dom-document-write">document.write()</code> methods (directly or indirectly)
after the document's <span>active parser</span> has been aborted. It is initially false.</p>

<p>The <dfn>document open steps</dfn>, given a <var>document</var>, are as follows:</p>

<ol>
Expand Down Expand Up @@ -93335,6 +93345,16 @@ document.body.appendChild(frame)</code></pre>
handler while the <code>Document</code> is being unloaded.</p>
</li>

<li>
domenic marked this conversation as resolved.
Show resolved Hide resolved
<p>If <var>document</var>'s <span>active parser was aborted</span> is true, then return
<var>document</var>.</p>

<p class="note">This notably causes <code data-x="dom-document-open">document.open()</code> to
be ignored if it is called after a <span data-x="navigate">navigation</span> has started, but
only during the initial parse. See <a href="https://github.com/whatwg/html/issues/4723">issue
#4723</a> for more background.</p>
</li>

<li>
<p>If <var>document</var>'s <span data-x="concept-document-bc">browsing context</span> is
non-null and there is an existing attempt to <span>navigate</span> <var>document</var>'s <span
Expand Down Expand Up @@ -93547,6 +93567,9 @@ document.body.appendChild(frame)</code></pre>
than 0, then throw an <span>"<code>InvalidStateError</code>"</span>
<code>DOMException</code>.</p></li>

<li><p>If <var>document</var>'s <span>active parser was aborted</span> is true, then
return.</p></li>

<li>
<p>If the <span>insertion point</span> is undefined, then:

Expand Down