Skip to main content

Module clock

Module clock 

Source
Expand description

Clock — Playwright-style fake timers for a page.

CDP has no native fake-timer primitive, so this is implemented by injecting a compact fake-timer controller script into the page’s main world and then driving it with real Runtime.evaluate calls. The controller overrides Date (so new Date() and Date.now() read from an adjustable base time), performance.now, and the timer functions (setTimeout, clearTimeout, setInterval, clearInterval, requestAnimationFrame).

The shape mirrors Playwright’s page.clock():

§Scope

install() injects the controller on the current execution context only. It is not automatically re-injected on cross-origin navigations; call install() again after such a navigation. The injected controller lives on the page’s main world, so timers scheduled in isolated worlds (e.g. content scripts) are not faked.

Structs§

Clock
A fake-timer handle for a Page.
ClockInstallOptions
Options for Clock::install.