WebNavigationClient


@WebNavigationClient.ExperimentalNavigationCallback
interface WebNavigationClient


Page identification and lifecycle APIs. This class provides callbacks to identify the different stages of navigation. For more information about the navigation lifecycle, please see the Life of a Navigation Presentation.

Note: These navigation callbacks only fire for navigations happening on the main frame.

Navigation lifecycle events:

  • onNavigationStarted
  • Potentially zero or more onNavigationRedirected events
  • onNavigationCompleted
  • If the navigation commits and is not a same-document navigation, potentially any combination and order of zero or one of each of:
    • onPageLoadEvent
    • onPageDomContentLoaded
    • onFirstContentfulPaint

Summary

Nested types

@Retention(value = RetentionPolicy.CLASS)
@Target(value = [ElementType.METHOD, ElementType.TYPE, ElementType.FIELD])
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
annotation WebNavigationClient.ExperimentalNavigationCallback

Denotes Navigation, Page and WebNavigationClient API surfaces are experimental.

Public functions

Unit

Fired when the page achieves "First Contentful Paint".

Unit

Fired when a navigation completes.

Unit

Fired when a navigation is redirected.

Unit

Fired when a navigation starts, including same-document navigations.

Unit

Fired when any Page is evicted/destroyed.

Unit

Fired when the `DOMContentLoaded` event is fired for the current page.

Unit

Fired when the `window.load` event is fired for the current page.

Public functions

onFirstContentfulPaint

fun onFirstContentfulPaint(page: Page): Unit

Fired when the page achieves "First Contentful Paint".

See First Contentful Paint (FCP) for a definition.

Parameters
page: Page

The Page for which the First Contentful Paint occurred.

onNavigationCompleted

fun onNavigationCompleted(navigation: Navigation): Unit

Fired when a navigation completes.

The navigation might not have actually committed (e.g., results in 204/download/cancelled).

Parameters
navigation: Navigation

The Navigation object representing the completed navigation.

onNavigationRedirected

fun onNavigationRedirected(navigation: Navigation): Unit

Fired when a navigation is redirected.

Parameters
navigation: Navigation

The Navigation object representing the redirected navigation.

onNavigationStarted

fun onNavigationStarted(navigation: Navigation): Unit

Fired when a navigation starts, including same-document navigations.

Note: These navigation callbacks only fire for navigations happening on the main frame.

Parameters
navigation: Navigation

The Navigation object representing the started navigation.

onPageDeleted

fun onPageDeleted(page: Page): Unit

Fired when any Page is evicted/destroyed. This can occur immediately on navigation, or later if the page is BFCached and subsequently evicted.

Parameters
page: Page

The Page that was evicted or destroyed.

onPageDomContentLoadedEventFired

fun onPageDomContentLoadedEventFired(page: Page): Unit

Fired when the `DOMContentLoaded` event is fired for the current page.

Parameters
page: Page

The Page for which the `DOMContentLoaded` event fired.

onPageLoadEventFired

fun onPageLoadEventFired(page: Page): Unit

Fired when the `window.load` event is fired for the current page.

Parameters
page: Page

The Page for which the `window.load` event fired.