Skip to main content

Module quiescence

Module quiescence 

Source
Expand description

Quiescence: the report a surface makes of its pending work, and the default policy for “settled”.

Every automation harness that polls-and-sleeps does so because it cannot ask the engine what is still in flight. The engine can answer per source, and the per-source signals already exist — this module adds no mechanism, only the common vocabulary the host uses to join them:

  • loads: LoadingState (this crate) — terminal at Done / Failed
  • script microtasks: script-engine-api’s pump (Quiescent / Pending)
  • timers: the runtime’s next_timer_delay()
  • animation-frame callbacks: the runtime’s has_animation_frame_callbacks()
  • declared animations: layout’s has_active_animations()

Only the host sees all of these at once, so the host assembles a PendingWork per surface; consumers (a test harness, a WebDriver adapter, an agent’s observation) read it instead of sleeping.

§Settling vs perpetual sources

The default settled policy counts only work that finishes by itself: loads, microtasks, and dirty layout. The other sources are reported but do not block, each for a stated reason:

  • Timers. A page with setTimeout(fn, 30_000) is not “busy” for those thirty seconds. WebDriver’s own document-readiness never waits on timers, and a harness that did would turn every long-poll page into a hang.
  • Animation-frame callbacks. A one-shot rAF (schedule a measurement) settles next frame, but a rAF loop — every game loop, every physics surface — re-requests forever, and the two are statically indistinguishable. Blocking on rAF turns “the orrery is breathing” into “the harness never returns”.
  • Declared animations. CSS transitions/animations run on the engine’s clock and may be infinite (animation-iteration-count: infinite).

For those, the tool is a condition-wait (“element exists”, “attribute equals”), not a broader settle. A caller with cause to block on the perpetual sources opts in explicitly via fully_idle and owns the hang risk it is accepting.

Structs§

PendingWork
One surface’s pending work, by source, at the moment of asking.

Traits§

QuiescenceQuery
Common-minimum quiescence query, per surface. Implemented host-side (only the host sees loads, script, and layout at once); read by harnesses, protocol adapters, and agent observation assembly.