From 0969d8d97d0b498364d78fb8029a7c77c859f76a Mon Sep 17 00:00:00 2001 From: jgraham Date: Tue, 13 Jul 2021 21:16:22 +0100 Subject: [PATCH] Add WebDriver BiDi navigation callbacks This change is motivated by WebDriver BiDi needing to observe the progress of navigations, in order to support commands and events related to navigation: https://github.com/w3c/webdriver-bidi/pull/93 In HTML, this adds a single new concept; a navigation id which is a unique id generated for each navigation. This enables WebDriver BiDi to tell when events are from the same navigation. In WebDriver BiDi, a navigation status struct is defined, with an id, a URL and a status. This is used as a uniform interface for communicating the navigation progress through all the integration points, even though not all fields are useful in all cases. The actual integration points added are: * Navigation started * Navigation aborted * Navigation failed * Download started * Fragment navigated * DOM load complete * Load complete --- source | 219 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 190 insertions(+), 29 deletions(-) diff --git a/source b/source index 327b5d1d2eb..aaabd4fcf9e 100644 --- a/source +++ b/source @@ -4081,6 +4081,38 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • process the manifest
  • + +
    WebDriver BiDi
    + +
    +

    The following terms are defined in WebDriver BiDi:

    + + +
    + +
    UUID
    + +
    +

    The following terms are defined in uuid:

    + +
    @@ -9229,6 +9261,9 @@ partial interface Document { data-x="she-document">document's is initial about:blank is true.

    +

    The Document has a navigation + id, which is a navigation id or null.

    +

    The DocumentOrShadowRoot interface

    DOM defines the permissions policy is permissionsPolicy, cross-origin opener - policy is coop, and which is ready for post-load tasks.

    + policy is coop, + navigation id is null, + and which is ready for post-load tasks.

  • Assert: document's URL and document's relevant settings object's Location { // but see also items:

    +
    id
    +
    A navigation id.
    +
    request
    null or a request that started the navigation
    @@ -86032,6 +86072,9 @@ interface Location { // but see also
    As explained in issue #1130 the use of a browsing context as source might not be the correct architecture.

    +

    A navigation has a navigation id, which is a unique + string.

    + @@ -86040,9 +86083,10 @@ interface Location { // but see also historyHandling (default "default"), an optional policy container-or-null historyPolicyContainer (default null) and an + data-x="navigation-historypolicycontainer">historyPolicyContainer (default null), an optional string navigationType (default - "other"):

    + "other"), and an optional navigation id + navigationId (default null):

    1. If resource is a URL, then set resource to a new Location { // but see also reload", + and browingContext's active document's navigation id is not null, let + navigationId be browingContext's active document's + navigation id. Otherwise let navigation + id be the result of generating a random UUID.

    2. +
    +
  • +
  • If browsingContext's active document's unload counter - is greater than 0, then return.

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

    To process a navigate URL scheme, given a URL url, a @@ -87056,7 +87157,8 @@ interface Location { // but see also final sandboxing flag set, and cross-origin opener policy is navigationParams's cross-origin opener - policy.

    + policy, and navigation id is + navigationParams's id.

    The new Window's associated Document is set to @@ -87395,9 +87497,9 @@ new PaymentRequest(…); // Allowed to use defined in XML and Namespaces in XML, XML Media Types, DOM, and other relevant specifications to create and initialize a Document object - given "xml", type, and navigationParams. They must - also create a corresponding XML parser.

    + document, given "xml", type, and + navigationParams. They must also create a corresponding XML parser. +

    At the time of writing, the XML specification community had not actually yet specified how XML and the DOM interact.

    @@ -87408,16 +87510,20 @@ new PaymentRequest(…); // Allowed to use encoding is established, the document's character encoding must be set to that character encoding.

    -

    Then, with the newly created Document, the user agent must update the - session history with the new page given navigationParams and the newly-created - Document. User agents may do this before the complete document has been parsed (thus - achieving incremental rendering), and must do this before any scripts are to be - executed.

    +

    Then, with document, the user agent must update the session history with the + new page given navigationParams and document. User agents may do + this before the complete document has been parsed (thus achieving incremental rendering), + and must do this before any scripts are to be executed.

    + +

    Once parsing is complete, the user agent must set document's navigation id to null.

    + +

    For HTML documents this is reset when parsing is complete, after firing the load + event.

    Error messages from the parse process (e.g., XML namespace well-formedness errors) may be reported inline by mutating the Document.

    -

    Page load processing model for text files

    When a plain text document is to be loaded, provided navigation params @@ -87670,8 +87776,9 @@ new PaymentRequest(…); // Allowed to use

    Navigating to a fragment

    To navigate to a fragment given a browsing - context browsingContext, a URL url, and a history - handling behavior historyHandling:

    + context browsingContext, a URL url, a history + handling behavior historyHandling, and a navigation + id navigationId:

    1. @@ -87703,6 +87810,14 @@ new PaymentRequest(…); // Allowed to use nonBlockingEvents set to true. This will scroll to the fragment given in what is now the document's URL.

    2. + +
    3. 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 @@ -88568,6 +88683,24 @@ interface BeforeUnloadEvent : Event { discarded, then set document's salvageable state to false.

    +
  • +

    If document's navigation id + is non-null, then:

    + +
      +
    1. Invoke WebDriver BiDi navigation aborted with document's browsing context, and new WebDriver BiDi navigation + status whose whose id is + document's navigation id, status is "canceled", and url is + document's URL.

    2. + +
    3. Set document's navigation + id to null.

    4. +
    +
  • +
  • If document has an active parser, then:

    @@ -113472,6 +113605,16 @@ document.body.appendChild(text); ServiceWorkerContainer object whose associated service worker client is the Document object's relevant settings object.

  • + +
  • Invoke WebDriver BiDi DOM content loaded with the Document's + browsing context, and a new WebDriver BiDi + navigation status whose id is the + Document object's navigation id, status is "pending", and url is the + Document object's URL.

  • @@ -113506,6 +113649,18 @@ document.body.appendChild(text); data-x="event-load">load at window, with legacy target override flag set.

    +
  • Invoke WebDriver BiDi load complete with the Document's + browsing context, and a new WebDriver BiDi + navigation status whose id is the + Document object's navigation + id, status is "complete", and url is the Document object's URL.

  • + +
  • Set the Document object's + navigation id to null.

  • +
  • Set the Document's load timing info's load event end time to the current high resolution time given window.

  • @@ -125142,6 +125297,9 @@ INSERT INTERFACES HERE
    [UTR36]
    (Non-normative) UTR #36: Unicode Security Considerations, M. Davis, M. Suignard. Unicode Consortium.
    +
    [UUID]
    +
    uuid, B. Coe, R. Kieffer, C. Tavan. WICG.
    +
    [WASMJS]
    (Non-normative) WebAssembly JavaScript Interface, D. Ehrenberg. W3C.
    @@ -125157,6 +125315,9 @@ INSERT INTERFACES HERE
    [WEBCRYPTO]
    (Non-normative) Web Cryptography API, M. Watson. W3C.
    +
    [WEBDRIVERBIDI]
    +
    WebDriver BiDi. W3C
    +
    [WEBGL]
    WebGL Specifications, D. Jackson, J. Gilbert. Khronos Group.