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.
browsingContext.navigationStarted is emitted for non-history navigation that is not a fragment navigation or reload.
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.)
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
browsingContext.fragmentNavigation is emitted when any same-document navigation occurs.
browsingContext.navigationStarted is emitted whenever the frame starts any loading process.
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.
I want to navigate to a page.
Corresponds to page.goto.
page.goto should end when the expected navigation has completed or an error.
I want to detect navigation.
Corresponds to page.waitForNavigation.
page.waitForNavigation should be able to detect when a navigation occurs.
page.waitForNavigation should wait for first navigation to complete or fail.
Verbatim spec
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.browsingContext.navigationStarted
is emitted for non-history navigation that is not a fragment navigation or reload.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.)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.browsingContext.navigationAborted
occurs only when navigation is aborted ifwindow.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
browsingContext.fragmentNavigation
is emitted when any same-document navigation occurs.browsingContext.navigationStarted
is emitted whenever the frame starts any loading process.browsingContext.navigationFailed
andbrowsingContext.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
andhistory.pushState
.page.goto
.page.goto
should end when the expected navigation has completed or an error.page.waitForNavigation
.page.waitForNavigation
should be able to detect when a navigation occurs.page.waitForNavigation
should wait for first navigation to complete or fail.Issues