NavigationListener


@WebNavigationClient.ExperimentalNavigationCallback
interface NavigationListener


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:

Summary

Public functions

Unit
onFirstContentfulPaint(page: Page, loadTimeUs: Long)

Called when the page achieves "First Contentful Paint".

Unit
onFirstContentfulPaintMillis(page: Page, durationMillis: Long)

Called when the page achieves "First Contentful Paint".

Unit
onLargestContentfulPaintMillis(page: Page, durationMillis: Long)

Called when the page fires a "Largest Contentful Paint" event.

Unit

Called when a navigation completes.

Unit

Called when a navigation is redirected.

Unit

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

Unit

Called when any Page is evicted/destroyed.

Unit

Called when the DOMContentLoaded event is fired for the current page.

Unit

Called when the window.load event is fired for the current page.

Unit
onPerformanceMarkMillis(page: Page, markName: String, markTimeMillis: Long)

Called when the page registers a performance mark.

Public functions

onFirstContentfulPaint

Added in 1.15.0
fun onFirstContentfulPaint(page: Page, loadTimeUs: Long): Unit

Called 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.

loadTimeUs: Long

Navigation to First Contentful Paint load time in microseconds.

onFirstContentfulPaintMillis

fun onFirstContentfulPaintMillis(page: Page, durationMillis: Long): Unit

Called when the page achieves "First Contentful Paint".

See First Contentful Paint (FCP) for a definition.

This method is called only if NAVIGATION_LISTENER_V2 is supported. You can check whether that flag is supported using isFeatureSupported.

Parameters
page: Page

The Page for which the First Contentful Paint occurred.

durationMillis: Long

Navigation to First Contentful Paint duration in milliseconds.

onLargestContentfulPaintMillis

fun onLargestContentfulPaintMillis(page: Page, durationMillis: Long): Unit

Called when the page fires a "Largest Contentful Paint" event.

See Largest Contentful Paint (LCP) for a definition.

This method is called only if NAVIGATION_LISTENER_V2 is supported. You can check whether that flag is supported using isFeatureSupported.

Parameters
page: Page

The Page for which the Largest Contentful Paint occurred.

durationMillis: Long

Navigation to Largest Contentful Paint duration in milliseconds.

onNavigationCompleted

Added in 1.15.0
fun onNavigationCompleted(navigation: Navigation): Unit

Called when a navigation completes.

The navigation might not have actually committed (e.g., results in 204/download/cancelled), but those that do they will have committed by this point.

Parameters
navigation: Navigation

The Navigation object representing the completed navigation.

onNavigationRedirected

Added in 1.15.0
fun onNavigationRedirected(navigation: Navigation): Unit

Called when a navigation is redirected.

Parameters
navigation: Navigation

The Navigation object representing the redirected navigation.

onNavigationStarted

Added in 1.15.0
fun onNavigationStarted(navigation: Navigation): Unit

Called 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

Added in 1.15.0
fun onPageDeleted(page: Page): Unit

Called 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.

onPageDomContentLoadedEvent

Added in 1.15.0
fun onPageDomContentLoadedEvent(page: Page): Unit

Called when the DOMContentLoaded event is fired for the current page.

Parameters
page: Page

The Page for which the DOMContentLoaded event fired.

onPageLoadEvent

Added in 1.15.0
fun onPageLoadEvent(page: Page): Unit

Called when the window.load event is fired for the current page.

Parameters
page: Page

The Page for which the window.load event fired.

onPerformanceMarkMillis

fun onPerformanceMarkMillis(page: Page, markName: String, markTimeMillis: Long): Unit

Called when the page registers a performance mark.

See Performance: mark() method for a definition.

This method is called only if NAVIGATION_LISTENER_V2 is supported. You can check whether that flag is supported using isFeatureSupported.

Parameters
page: Page

The Page for which the performance mark was registered.

markName: String

The name of the performance mark.

markTimeMillis: Long

The time of the performance mark in milliseconds since Performance.timeOrigin.