@@ -85474,7 +85474,6 @@ interface <dfn>BeforeUnloadEvent</dfn> : <span>Event</span> {
8547485474 <p>To <dfn data-x="abort a document">abort</dfn> a <code>Document</code> <var>document</var>:</p>
8547585475
8547685476 <ol>
85477-
8547885477 <li><p><span data-x="abort a document">Abort</span> the <span data-x="active document">active
8547985478 documents</span> of every <span>child browsing context</span>. If this results in any of those
8548085479 <code>Document</code> objects having their <i
@@ -85491,12 +85490,18 @@ interface <dfn>BeforeUnloadEvent</dfn> : <span>Event</span> {
8549185490 discarded, then set <var>document</var>'s <i
8549285491 data-x="concept-document-salvageable">salvageable</i> state to false.</p></li>
8549385492
85494- <li><p>If <var>document</var> has an <span>active parser</span>, then <span data-x="abort a
85495- parser">abort that parser</span> and set <var>document</var>'s <i
85496- data-x="concept-document-salvageable">salvageable</i> state to false.</p></li>
85493+ <li>
85494+ <p>If <var>document</var> has an <span>active parser</span>, then:</p>
85495+
85496+ <ol>
85497+ <li><p>Set <var>document</var>'s <span>active parser was aborted</span> to true.</p></li>
8549785498
85498- <!-- we could also stop all script, or stop animations -- >
85499+ <li><p><span data-x="abort a parser">Abort that parser</span>.</p></li >
8549985500
85501+ <li><p>Set <var>document</var>'s <i data-x="concept-document-salvageable">salvageable</i> state
85502+ to false.</p></li>
85503+ </ol>
85504+ </li>
8550085505 </ol>
8550185506
8550285507 <p>User agents may allow users to explicitly invoke the <span data-x="abort a document">abort a
@@ -93444,6 +93449,11 @@ document.body.appendChild(frame)</code></pre>
9344493449 method (directly or indirectly) while the document is <span data-x="unload a document">being
9344593450 unloaded</span>. Initially, the counter must be set to zero.</p>
9344693451
93452+ <p><code>Document</code> objects have an <dfn>active parser was aborted</dfn> boolean, which is
93453+ used to prevent scripts from invoking the <code data-x="dom-document-open">document.open()</code>
93454+ and <code data-x="dom-document-write">document.write()</code> methods (directly or indirectly)
93455+ after the document's <span>active parser</span> has been aborted. It is initially false.</p>
93456+
9344793457 <p>The <dfn>document open steps</dfn>, given a <var>document</var>, are as follows:</p>
9344893458
9344993459 <ol>
@@ -93480,6 +93490,16 @@ document.body.appendChild(frame)</code></pre>
9348093490 handler while the <code>Document</code> is being unloaded.</p>
9348193491 </li>
9348293492
93493+ <li>
93494+ <p>If <var>document</var>'s <span>active parser was aborted</span> is true, then return
93495+ <var>document</var>.</p>
93496+
93497+ <p class="note">This notably causes <code data-x="dom-document-open">document.open()</code> to
93498+ be ignored if it is called after a <span data-x="navigate">navigation</span> has started, but
93499+ only during the initial parse. See <a href="https://github.com/whatwg/html/issues/4723">issue
93500+ #4723</a> for more background.</p>
93501+ </li>
93502+
9348393503 <li>
9348493504 <p>If <var>document</var>'s <span data-x="concept-document-bc">browsing context</span> is
9348593505 non-null and there is an existing attempt to <span>navigate</span> <var>document</var>'s <span
@@ -93692,6 +93712,9 @@ document.body.appendChild(frame)</code></pre>
9369293712 than 0, then throw an <span>"<code>InvalidStateError</code>"</span>
9369393713 <code>DOMException</code>.</p></li>
9369493714
93715+ <li><p>If <var>document</var>'s <span>active parser was aborted</span> is true, then
93716+ return.</p></li>
93717+
9369593718 <li>
9369693719 <p>If the <span>insertion point</span> is undefined, then:
9369793720
0 commit comments