diff --git a/source b/source index 601171fa244..f79b92199fb 100644 --- a/source +++ b/source @@ -98149,16 +98149,16 @@ interface History {
  • Let navigation be history's relevant global object's navigation API.

  • -
  • Let continue be the result of firing a push/replace/reload navigate event at - navigation with navigationType set to - historyHandling, isSameDocument set - to true, destinationURL set to - newURL, and

    Set historyHandling to the result of firing a push/replace/reload navigate event at navigation with navigationType set to historyHandling, + isSameDocument set to true, destinationURL set to newURL, and classicHistoryAPIState set to serializedData.

  • -
  • If continue is false, then return.

    +
  • If historyHandling is null, then return.

  • Run the URL and history update steps given document and newURL, with serializedData set to @@ -98855,12 +98855,15 @@ enum NavigationHistoryBehavior { index to the result of getting the navigation API entry index of reactivatedSHE within navigation.

  • +
  • Flush navigation API restore callbacks given navigation.

  • +
  • Queue a global task on the navigation and traversal task source given navigation's relevant global object to run the following steps:

      +
    1. For each disposedNHE of oldNHEs:

      @@ -100370,6 +100373,8 @@ const p2 = navigation.navigate(url2).finished; ErrorEvent, with additional attributes initialized according to errorInfo.

    2. +
    3. Flush navigation API restore callbacks given navigation.

    4. +
    5. If navigation's transition is null, then return.

    6. @@ -100402,6 +100407,9 @@ const p2 = navigation.navigate(url2).finished;
    7. Let navigation be navigable's active window's navigation API.

    8. +
    9. Let event be navigation's ongoing navigate event.

    10. +
    11. While navigation's ongoing navigate event is not null:

      @@ -100722,6 +100730,7 @@ interface NavigateEvent : Event { undefined intercept(optional NavigationInterceptOptions options = {}); undefined scroll(); + undefined deferPageSwap(NavigationDeferPageSwapOptions options); }; dictionary NavigateEventInit : EventInit { @@ -100745,6 +100754,11 @@ dictionary NavigationInterceptOptions { NavigationScrollBehavior scroll; }; +dictionary NavigationDeferPageSwapOptions { + NavigationDeferPageSwapHistoryChange historyChange; + NavigationDeferPageSwapHandler handler; +}; + enum NavigationFocusReset { "after-transition", "manual" @@ -100755,7 +100769,14 @@ enum NavigationScrollBehavior { "manual" }; -callback NavigationInterceptHandler = Promise<undefined> (); +enum NavigationDeferPageSwapHistoryChange { + "after-transition", + "immediate" +}; + +callback NavigationInterceptHandler = Promise<undefined> (); +callback NavigationDeferPageSwapHandler = Promise<undefined> (NavigationDeferPageSwapController controller); +
      event.navigationType
      @@ -100931,6 +100952,37 @@ callback NavigationInterceptHandler = InvalidStateError" DOMException.

      + +
      event.deferPageSwap(NavigationDeferPageSwapOptions options)
      +
      +

      Delays finalizing a same-origin cross-document navigation, without intercepting it as + a same-document navigation. The navigation will continue to the new page once handlers passed to + this method are settled. This allows setting up some exit animation, or performing some + asynchronous exit actions, without the page deactivation aborting those actions in the + middle.

      + +

      Like intercept(), this method only works + on same-origin non-traverse navigations.

      + +

      Deferring and intercepting cannot co-exist on the same NavigateEvent. Calling + one after the other would throw an "InvalidStateError" + DOMException when the latter is called.

      + +

      All the handler option + passed by succesful calls to this methods are called in order, and once their returned promises + are resolved, the navigation can proceed to swap the page.

      + +

      The historyChange + option controls whether the URL and history change take place immediately, or at page swap. + A value of "after-transition" + would keep the current history state until the navigation is ready to commit, while a value of + "immediate" would + change the history immediately. The default value is "immediate", which creates a + more consistent experience with browser UI, such as pressing the back button immediately after + the transition begins.

      +
      @@ -100950,6 +101002,15 @@ callback NavigationInterceptHandler = navigation handler list, a list of NavigationInterceptHandler callbacks, initially empty.

      +

      Each NavigateEvent has a defer page-swap handler list, a + list of NavigationDeferPageSwapHandler callbacks, initially empty.

      + +

      Each NavigateEvent has a page-swap history + change behavior, a NavigationDeferPageSwapHistoryChange, initially "immediate".

      +

      Each NavigateEvent has a focus reset behavior, a NavigationFocusReset-or-null, initially null.

      @@ -100983,10 +101044,10 @@ callback NavigationInterceptHandler = downloadRequest, info, hasUAVisualTransition, and - sourceElement attributes - must return the values they are initialized to.

      + data-x="dom-NavigateEvent-hasUAVisualTransition">hasUAVisualTransition, and sourceElement attributes must return the + values they are initialized to.

      @@ -101005,6 +101066,15 @@ callback NavigationInterceptHandler = InvalidStateError" DOMException.

    12. +
    13. +

      If this's defer page-swap handler list + is not empty, then throw an + "InvalidStateError" DOMException.

      + +

      The same navigation cannot be both intercepted and deferred.

      +
    14. +
    15. If options["precommitHandler"] NavigationInterceptHandler = deferPageSwap(options) method + steps are:

      + +
        +
      1. Perform shared checks given + this.

      2. + +
      3. If this's canIntercept + attribute was initialized to false, then throw a "SecurityError" + DOMException.

      4. + +
      5. If this's dispatch flag is unset, then throw an + "InvalidStateError" DOMException.

      6. + +
      7. +

        If this's interception state is not "none", then throw an "InvalidStateError" + DOMException.

        + +

        The same navigation cannot be both intercepted and deferred.

        +
      8. + +
      9. Let historyChange be options["historyChange"] if exists, otherwise "immediate".

      10. + +
      11. If this's defer page-swap handler list + is not empty and historyChange is not + event's page-swap history change + behavior, then throw an "InvalidStateError" + DOMException.

      12. + +
      13. Set event's + page-swap history + change behavior to historyChange.

      14. + +
      15. Append handler to this's + defer page-swap handler + list.

      16. +
      + + +

      To perform shared checks for a NavigateEvent event:

      @@ -101247,6 +101366,53 @@ callback NavigationInterceptHandler = [Exposed=Window] + interface NavigationDeferPageSwapController { + undefined addRestoreCallback(NavigationDeferPageSwapRestoreHandler handler); + }; + + callback NavigationDeferPageSwapRestoreHandler = undefined (); + +
      +
      deferControlller.addRestoreCallback(NavigationDeferPageSwapRestoreHandler handler)
      +

      Adds a callback handler that will be called when the state needs to be restored + to the pre-navigation conditions. The handler is called if the navigation is aborted, or if the + navigation succeeded and the page is subsequently restored from + back/forward cache.

      +
      + +

      A NavigationDeferPageSwapController has a NavigateEvent event.

      + +
      +

      The addRestoreCallback(callback) + method steps are:

      + +
        +
      1. Let event be this's event.

      2. + +
      3. Perform shared checks given + event.

      4. + +
      5. If event's relevant global object's + navigation API's ongoing navigate event is not event, then throw an + "InvalidStateError" DOMException.

      6. + +
      7. Append callback to event's + relevant global object's navigation + API's restore callback + list.

      8. +
      + +
      + + +
      The NavigationDestination interface
      [Exposed=Window]
      @@ -101490,7 +101656,8 @@ interface NavigationDestination {
         state-or-null classicHistoryAPIState (default
         null), and an optional navigation API method tracker-or-null apiMethodTracker:

      + data-x="fire-navigate-prr-api-method-tracker">apiMethodTracker (default + null):

      1. Let document be navigation's relevant global object's NavigationDestination {

      2. Set destination's is same document to isSameDocument.

      3. -
      4. Return the result of performing the inner

        Perform the inner navigate event firing algorithm given navigation, navigationType, event, destination, userInvolvement, sourceElement, formDataEntryList, null, and - apiMethodTracker.

      5. + apiMethodTracker. If that returned false, return false.

        + +
      6. If event's defer page-swap handler list + is empty, return historyHandling.

      7. + +
      8. Let deferControlller be a new NavigationDeferPageSwapController + created in navigation's relevant realm, + whose event is + event.

      9. + +
      10. Let deferPromisesList be an empty list.

      11. + +
      12. Let navigationID be navigable's + ongoing navigation.

      13. + +
      14. For each handler of event's navigation defer page-swap handler + list, append the result of invoking handler with + « deferControlller » to deferPromisesList.

      15. + +
      16. Wait for all deferPromisesList, with the following as both the + success and failure step: proceed with navigation after deferred commit given + navigable and navigationID.

      17. + +
      18. If event's page-swap history change + behavior is "after-transition", + or if navigationType is "reload", + return navigationType.

      19. + +
      20. Run the URL and history update steps given document and + newURL, with serializedData set to + serlialized state and historyHandling set to + navigationType.

      21. + +
      22. Return "replace".

      @@ -106547,7 +106752,7 @@ location.href = '#foo'; navigationAPIState is not null; otherwise, StructuredSerializeForStorage(undefined).

    16. -
    17. Let continue be the result of firing a push/replace/reload navigate event at navigation with navigationType set to historyHandling, @@ -106562,7 +106767,7 @@ location.href = '#foo'; data-x="fire-navigate-prr-api-method-tracker">apiMethodTracker set to apiMethodTracker.

    18. -
    19. If continue is false, then return.

      +
    20. If historyHandling is null, then return.

    It is possible for navigations with userInvolvement of " data-x="dom-navigationtimingtype-navigate">navigate", sourceSnapshotParams, targetSnapshotParams, userInvolvement, navigationId, navigationParams, cspNavigationType, with allowPOST set to true and completionSteps set to the following + data-x="attempt-to-populate-allow-post">allowPOST set to true, + and completionSteps set to the following step:

      @@ -107196,18 +107401,18 @@ location.href = '#foo';
    1. If navigationAPIState is not null, then set destinationNavigationAPIState to navigationAPIState.

    2. -
    3. Let continue be the result of firing a push/replace/reload navigate event at - navigation with navigationType set to - historyHandling, isSameDocument set - to true, userInvolvement set to - userInvolvement, sourceElement set - to sourceElement, destinationURL - set to url, and

      Set historyHandling to the result of firing a push/replace/reload navigate event at navigation with navigationType set to historyHandling, + isSameDocument set to true, userInvolvement set to userInvolvement, + sourceElement set to sourceElement, destinationURL set to url, and navigationAPIState set to destinationNavigationAPIState.

    4. -
    5. If continue is false, then return.

      +
    6. If historyHandling is null, then return.

    7. Let historyEntry be a new session history entry, with

      @@ -107838,13 +108043,22 @@ location.href = '#foo'; -
      Aborting navigation
      +
      Aborting & deferring navigation

      Each navigable has an ongoing navigation, which is a navigation ID, "traversal", or null, initially null. It is used to track navigation aborting and to prevent any navigations from taking place during traversal.

      +

      Each navigable has a commit navigation steps, which is null or an algorithm + accepting nothing, initially null.

      + +

      Each navigable has a boolean deferring page swap, initially false.

      + +

      Each Navigation has an associated restore callback list, a list of + algorithms, initially empty.

      +

      To set the ongoing navigation for a navigable navigable to newValue:

      @@ -107853,6 +108067,9 @@ location.href = '#foo';
    8. If navigable's ongoing navigation is equal to newValue, then return.

    9. +
    10. Proceed with navigation after deferred commit given navigable + and newValue.

    11. +
    12. Inform the navigation API about aborting navigation given navigable.

    13. @@ -107861,6 +108078,38 @@ location.href = '#foo';
    +
    +

    To proceed with navigation after deferred commit given a navigable navigable + and a navigation ID navigationID, queue a global task on the navigation and traversal task source of navigable's active + window to run the steps:

    + +
      +
    1. Set navigable's deferring page swap to false.

    2. + +
    3. If navigable's commit navigation steps is not null, then call + navigable's commit navigation steps given + navigationID.

    4. + +
    5. Set navigable's commit navigation steps to null.

    6. +
    +
    + +
    +

    To flush navigation API restore callbacks for a Navigation object + navigation:

    +
      +
    1. Set callbacks to navigation's restore callback list.

    2. + +
    3. Set navigation's restore callback list to an empty + list.

    4. + +
    5. For each restoreCallback in + callbacks, call restoreCallback.

    6. +
    +
    +

    Reloading and traversing

    @@ -107890,7 +108139,7 @@ location.href = '#foo';
  • If navigationAPIState is not null, then set destinationNavigationAPIState to navigationAPIState.

  • -
  • Let continue be the result of firing a push/replace/reload navigate event at navigation with navigationType set to " data-x="fire-navigate-prr-api-method-tracker">apiMethodTracker set to apiMethodTracker.

  • -
  • If continue is false, then return.

  • +
  • If eventResult is null, then return.

  • @@ -108138,8 +108387,7 @@ location.href = '#foo';
    (default null), an optional navigation params-or-null navigationParams (default null), an optional string cspNavigationType (default "other"), an optional boolean allowPOST (default false), and optional - algorithm steps allowPOST (default false), and optional algorithm steps completionSteps (default an empty algorithm):

    @@ -108221,13 +108469,19 @@ location.href = '#foo'; -
  • -

    Queue a global task on the navigation and traversal task source, - given navigable's active window, to run these steps:

    +
  • +

    Let processNavigateResponse + be the following steps given a navigation ID navigationToResume:

      -
    1. If navigable's ongoing navigation no longer equals - navigationId, then run completionSteps and abort these steps.

    2. +
    3. If navigationToResume no longer equals navigationId, then run + completionSteps and abort these steps.

    4. + +
    5. Set navigable's commit navigation steps to null.

    6. + +
    7. If navigable's deferring page swap is true, + then set navigable's commit navigation steps to + processNavigateResponse and abort these steps.

    8. Let saveExtraDocumentState be true.

      @@ -108450,6 +108704,10 @@ location.href = '#foo';
    9. Run completionSteps.

  • + +
  • Queue a global task on the navigation and + traversal task source of navigable's active + window to call processNavigateResponse.