w3c / webdriver-bidi

Bidirectional WebDriver protocol for browser automation
https://w3c.github.io/webdriver-bidi/
363 stars 40 forks source link

Status of navigation in WebDriver BiDi #662

Open jrandolf-2 opened 7 months ago

jrandolf-2 commented 7 months ago

Verbatim spec

  1. browsingContext.fragmentNavigated is emitted only for fragment navigation. a. This does not include history navigation. b. History navigation that triggers fragment navigation is also not included.
  2. browsingContext.navigationStarted is emitted for non-history navigation that is not a fragment navigation or reload.
  3. browsingContext.navigationFailed occurs almost only during non-history navigation that is not a fragment navigation or reload when either a. unload is happening, b. beforeunload cancels the navigation, or c. the navigation is not committed into history and another navigation starts (i.e. the latest navigation always takes precedent unless the current navigation is already committed into history.)
  4. browsingContext.navigationFailed occurs for all navigation only when 6.4.4.2 of https://html.spec.whatwg.org/#attempt-to-populate-the-history-entry's-document is hit which has several specific conditions.
  5. browsingContext.navigationAborted occurs only when navigation is aborted if window.stop is called during navigation or a fresh document has started loading but another navigation stops it. (Imagine navigating from about:blank to example.com to google.com fast enough that example.com doesn’t get parsed; navigation aborted will occur for the edge from about:blank to example.com) a. Note: browsingContext.navigationStarted for example.com to google.com will happen before the navigation aborted for about:blank to example.com.

Current implementations

Chromium

  1. browsingContext.fragmentNavigation is emitted when any same-document navigation occurs.
  2. browsingContext.navigationStarted is emitted whenever the frame starts any loading process.
  3. browsingContext.navigationFailed and browsingContext.navigationAborted are not emitted.

Use cases

Puppeteer

Puppeteer defines navigation as "what users expect". This includes, but not limited to, navigation due to interacting with the browser, history navigation and, perhaps a little less navigation-like, history.replaceState and history.pushState.

  1. I want to navigate to a page.
    1. Corresponds to page.goto.
    2. page.goto should end when the expected navigation has completed or an error.
  2. I want to detect navigation.
    1. Corresponds to page.waitForNavigation.
    2. page.waitForNavigation should be able to detect when a navigation occurs.
    3. page.waitForNavigation should wait for first navigation to complete or fail.

Issues