From 5f172053c8a9b8e83639e2ca0d3b3e57e41a848b Mon Sep 17 00:00:00 2001 From: James Graham Date: Mon, 7 Jun 2021 17:13:54 +0100 Subject: [PATCH] Add navigation hooks for WebDriver BiDi history traversal WebDriver BiDi wants to invoke the 'traverse the history by a delta` algorithm, and get a callback whenever the algoritihm has run to completion, either by failing or by the navigation or state restoration completing. https://github.com/w3c/webdriver-bidi/pull/109 is the WebDriver BiDi side of this change. --- source | 160 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 118 insertions(+), 42 deletions(-) diff --git a/source b/source index 55b15337e83..59f14cca7d4 100644 --- a/source +++ b/source @@ -4132,6 +4132,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • WebDriver BiDi fragment navigated
  • WebDriver BiDi DOM content loaded
  • WebDriver BiDi load complete
  • +
  • WebDriver BiDi page show
  • +
  • WebDriver BiDi pop state
  • @@ -84700,16 +84702,23 @@ interface History {
    -

    To traverse the history by a delta given delta and browsing - context source browsing context, the user agent must append a task to this top-level browsing context's session - history traversal queue, the task consisting of running - the following steps:

    +

    To traverse the history by a delta given delta, browsing + context source browsing context, and an optional navigation id navigationId (default null), + the user agent must append a task to this top-level + browsing context's session history traversal queue, the task consisting of running the following steps:

    1. If the index of the current entry of the joint session history plus delta is less than zero or greater than or equal to the number of items in the - joint session history, then return.

      + joint session history, invoke WebDriver BiDi navigation failed + with source browsing context, and a WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is resource's url, then return.

    2. Let specified entry be the entry in the joint session history whose index is the sum of delta and the index of the @@ -84719,10 +84728,22 @@ interface History { the specified entry.

    3. If source browsing context is not allowed to navigate - specified browsing context, then return.

    4. + specified browsing context, then invoke WebDriver BiDi navigation failed with + with source browsing context, and a WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is resource's url, then return.

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

    6. + counter is greater than 0, then invoke WebDriver BiDi navigation failed with + with source browsing context, and a WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is resource's url, then return.

    7. Queue a global task on the history traversal task source given @@ -84730,6 +84751,9 @@ interface History { steps:

        +
      1. If navigationId is null, let navigation id be the result of + generating a random UUID.

      2. +
      3. If there is an ongoing attempt to navigate specified browsing context that has not yet matured (i.e. it has not passed the point of making its Document the active document), then cancel that @@ -84743,7 +84767,13 @@ interface History {

        1. Prompt to unload the active document of the specified browsing context. If the user refused to allow the document to be - unloaded, then return.

        2. + unloaded, , then invoke WebDriver BiDi navigation failed with + with source browsing context, and a WebDriver BiDi navigation status + whose id is navigationId, status is "canceled", and url is resource's url, then return.

        3. Unload the active document of the specified browsing context.

        4. @@ -84752,7 +84782,8 @@ interface History {
        5. Traverse the history of the specified browsing context to the specified entry with explicitHistoryNavigation set to - true.

          + true, and navigation id set to + navigationId.

      @@ -86246,8 +86277,6 @@ interface Location { // but see also id is navigationId,

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

    8. + handling, and navigation id + set to navigationId.

    @@ -87393,7 +87423,9 @@ new PaymentRequest(…); // Allowed to use
  • Traverse the history to newEntry with historyHandling set to "replace".

  • + data-x="hh-replace">replace", and navigation id set to navigationId. +

    @@ -87422,7 +87454,9 @@ new PaymentRequest(…); // Allowed to use
  • Append newEntry to sessionHistory.

  • -
  • Traverse the history to newEntry.

  • +
  • Traverse the history to newEntry with navigation id set to navigationId. +

  • @@ -87816,18 +87850,11 @@ new PaymentRequest(…); // Allowed to use mode.

  • Traverse the history to the new entry, with historyHandling set to historyHandling and with - nonBlockingEvents set to true. This will scroll to the - fragment given in what is now the document's historyHandling set to historyHandling, + nonBlockingEvents set to true, and navigation id set to navigationId. + This will scroll to the fragment given in what is now the document's URL.

  • - -
  • Invoke WebDriver BiDi fragment navigated with browsingContext, - and a new WebDriver BiDi navigation status whose id is navigationId, url is resource's url, and status is "complete".

  • If the scrolling fails because the relevant ID has @@ -87956,8 +87983,9 @@ new PaymentRequest(…); // Allowed to use with an optional history handling behavior historyHandling (default "default"), an optional boolean nonBlockingEvents - (default false), and an optional boolean explicitHistoryNavigation (default - false):

    + (default false), an optional boolean explicitHistoryNavigation (default + false), optional navigation id + navigationId (default null):

    This algorithm is not just invoked when explicitly going back or forwards in the session history — it is also invoked @@ -87983,11 +88011,12 @@ new PaymentRequest(…); // Allowed to use

  • Navigate the browsing context to request with historyHandling - set to "entry update" and with entry update", with historyPolicyContainer set to - entry's policy container. The navigation - must be done using the same source browsing context as was used the first time - entry was created.

    + entry's policy container, and with + navigation id set to navigationId. + The navigation must be done using the same source browsing context as was + used the first time entry was created.

    The "navigate" algorithm reinvokes this "traverse" algorithm to complete the traversal, at which point entry's

    Let newDocument be entry's document.

  • +
  • If navigationId is null:

    + +
      +
    1. If newDocument's navigation + id is not null, let navigationId be newDocument's navigation id. Otherwise let + navigationId be the result of generating a random UUID. +

    2. +
    +
  • +
  • If newDocument is different than the current entry's document, or historyHandling is "entry update" or "reload", @@ -88098,6 +88141,14 @@ new PaymentRequest(…); // Allowed to use

  • Fire a page transition event named pageshow at newDocument's relevant global object with true.

  • + +
  • Invoke WebDriver BiDi page show with newDocument's + browsing context, and a new WebDriver BiDi + navigation status whose id is the + navigationId, status is + "complete", and url is the newDocument's URL.