From e85177a97cfa1beedebfbe4c6726b5591f6b01ab Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Mon, 10 May 2021 18:51:50 -0400 Subject: [PATCH] Tweak "is unloading" in navigation This replaces vague text about "if the prompt to unload algorithm is being run" and the like for "unload" with an explicit check of the "unload counter". The "unload counter" is a rename of the "ignore-opens-during-unload counter", which was already used for similar explicit checks in document.open(). This results in the same check being done everywhere, which appears to match at least some implementations better. Previously, for example, "traverse the history by a delta" did not check for beforeunload, only unload. --- source | 52 ++++++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/source b/source index 4a6c9a1216e..f81f28b83d7 100644 --- a/source +++ b/source @@ -84029,8 +84029,8 @@ interface History {
  • If source browsing context is not allowed to navigate specified browsing context, then return.

  • -
  • If the specified browsing context's active document's - unload a document algorithm is currently running, return.

  • +
  • If the specified browsing context's active document's unload + counter is greater than 0, then return.

  • Queue a global task on the history traversal task source given @@ -85450,20 +85450,13 @@ interface Location { // but see also

    If historyHandling is not "reload", @@ -87677,6 +87670,10 @@ dictionary PageTransitionEventInit : EventInit {

    Event loops have a termination nesting level counter, which must initially be 0.

    +

    Document objects have an unload + counter, which is used to ignore certain operations while the below algorithms run. + Initially, the counter must be set to zero.

    +

    To prompt to unload, given a Document object document and optionally a recursiveFlag, run these steps:

    @@ -87684,8 +87681,7 @@ dictionary PageTransitionEventInit : EventInit {
  • Increase the event loop's termination nesting level by 1.

  • -
  • Increase the document's ignore-opens-during-unload counter by - 1.

  • +
  • Increase the document's unload counter by 1.

  • Let event be the result of creating an event using BeforeUnloadEvent.

  • @@ -87753,8 +87749,7 @@ dictionary PageTransitionEventInit : EventInit { -
  • Decrease the document's ignore-opens-during-unload counter by - 1.

  • +
  • Decrease the document's unload counter by 1.

  • To unload a @@ -87765,8 +87760,7 @@ dictionary PageTransitionEventInit : EventInit {

  • Increase the event loop's termination nesting level by one.

  • -
  • Increase document's ignore-opens-during-unload counter by - one.

  • +
  • Increase document's unload counter by 1.

  • If document's page showing flag is false, then jump to the step labeled unload event below (i.e. skip firing the PageTransitionEventInit : EventInit {

  • -
  • Decrease document's ignore-opens-during-unload counter by - one.

  • +
  • Decrease document's unload counter by 1.

  • This specification defines the following unloading document cleanup steps. @@ -87965,8 +87958,8 @@ interface BeforeUnloadEvent : Event { data-x="concept-document-bc">browsing context.

  • If there is an existing attempt to navigate browsingContext and - that attempt is not currently running the unload a document algorithm, then cancel - that navigation.

  • + document's unload counter is 0, then cancel that navigation.

  • Abort document.

  • @@ -94000,11 +93993,6 @@ document.body.appendChild(frame)
    -

    Document objects have an ignore-opens-during-unload counter, which is - used to prevent scripts from invoking the document.open() - method (directly or indirectly) while the document is being - unloaded. Initially, the counter must be set to zero.

    -

    Document objects have an active parser was aborted boolean, which is used to prevent scripts from invoking the document.open() and document.write() methods (directly or indirectly) @@ -94038,8 +94026,8 @@ document.body.appendChild(frame)

  • -

    Similarly, if document's ignore-opens-during-unload counter is - greater than 0, then return document.

    +

    Similarly, if document's unload counter is greater than 0, then + return document.

    This basically causes document.open() to be ignored when it's called from a beforeunload,

    If the insertion point is undefined, then:

      -
    1. If document's ignore-opens-during-unload counter is greater than - 0 or document's ignore-destructive-writes counter is greater than 0, - then return.

    2. +
    3. If document's unload counter is greater than 0 or + document's ignore-destructive-writes counter is greater than 0, then + return.

    4. Run the document open steps with document.