From 2062a686308f85c6e46d2c14f9ade828041d17d5 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 10 Mar 2021 13:48:37 -0500 Subject: [PATCH] Fix same-URL navigation session history handling Closes #6202. Also tidies up the "update the session history with the new page" algorithm more generally, e.g. to be explicit about what session history is being accessed. --- source | 107 +++++++++++++++++++++++++++------------------------------ 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/source b/source index 4fb32bc16b1..e41ebdc81f8 100644 --- a/source +++ b/source @@ -84575,6 +84575,15 @@ interface Location { // but see also default", + resource is a request, and either + resource's url equals browsingContext's active + document's URL or resource's url's scheme is + "javascript"', then set historyHandling to + "replace". +
  • Let activeDocumentNavigationOrigin be the origin of the active document of browsingContext.

  • @@ -85557,9 +85566,14 @@ new PaymentRequest(…); // Allowed to use following steps:

      +
    1. Let sessionHistory be navigationParams's browsing context's session + history.

    2. +
    3. -

      Unload the document of the current entry.

      +

      Unload sessionHistory's current + entry's document.

      If this instance of the navigation algorithm is canceled while this step is running the unload a document algorithm, then the unload a @@ -85570,28 +85584,29 @@ new PaymentRequest(…); // Allowed to use

    4. -
      -
      If navigationParams's history - handling is "entry update" or "reload"
      - +

      Switch on navigationParams's history + handling:

      +
      +
      "entry update"
      +
      "reload"
        -
      1. Replace the document of the current - entry, and of any other entries that reference the same document as that entry, with newDocument.

      2. - -
      3. Traverse the history to the current entry with historyHandling set to navigationParams's history handling.

      4. +
      5. Let oldDocument be sessionHistory's current entry's + document.

      6. + +
      7. For each entry of + sessionHistory: if entry's document + is oldDocument, then set entry's document to newDocument.

      8. + +
      9. Traverse the history to sessionHistory's current + entry with historyHandling set to + navigationParams's history + handling.

      -
      Otherwise, if the navigation was initiated with a URL that equals navigationParams's browsing context's active - document's URL
      - +
      "replace"
      1. @@ -85600,34 +85615,15 @@ new PaymentRequest(…); // Allowed to use data-x="concept-document-url">URL and document is newDocument.

        -

        Some browsers copy over the serialized state of current entry, - but this is inconsistent. See issue - #6213 for more discussion on this.

        +

        Some browsers copy over the serialized state sessionHistory's + current entry in cases where its URL equals that of newDocument, but this is + inconsistent. See issue #6213 for + more discussion on this.

      2. -
      3. Insert newEntry after the current entry in - navigationParams's browsing - context's session history.

      4. - -
      5. Traverse the history to newEntry with historyHandling set to "replace".

      6. -
      -
      - -
      Otherwise, if navigationParams's history - handling is "replace"
      - -
      -
        -
      1. Let newEntry be a new session history entry whose URL is newDocument's URL and document is - newDocument.

      2. - -
      3. Insert newEntry after the current entry in - navigationParams's browsing - context's session history.

      4. +
      5. Insert newEntry into sessionHistory after its current + entry.

      6. Traverse the history to newEntry with historyHandling set to "

      -
      Otherwise
      - +
      "default"
        -
      1. Assert: navigationParams's history - handling is "default".

      2. -
      3. -

        Remove all the entries in the session history after the current - entry. If the current entry is the last entry in the session history, - then no entries are removed.

        +

        Remove all the entries in sessionHistory after its current entry. + (If the current entry is the last entry in the session history, then no entries + are removed.)

        This doesn't necessarily have to affect the user agent's user interface.

      4. -
      5. Append a new session history entry to the session history, - whose URL is newDocument's

        Let newEntry be a new session history entry whose URL is newDocument's URL and document is newDocument.

      6. -
      7. Traverse the history to the new entry.

      8. +
      9. Append newEntry to + sessionHistory.

      10. + +
      11. Traverse the history to newEntry.