Skip to content

The headless browser for AI agents and web scraping

fix(js): record navigation lifecycle timestamps

SGavrl60107d1aa663
diff --git a/crates/obscura-browser/src/page.rs b/crates/obscura-browser/src/page.rs
index b8163547..e6c64cea 100644
--- a/crates/obscura-browser/src/page.rs
+++ b/crates/obscura-browser/src/page.rs
@@ -3,7 +3,7 @@ use std::sync::Arc;
use base64::{engine::general_purpose::STANDARD as BASE64, Engine as _};
use obscura_dom::{parse_html, DomTree};
use obscura_js::frame::FrameRealm;
-use obscura_js::ops::max_live_frames;
+use obscura_js::ops::{max_live_frames, NavigationTiming};
use obscura_js::runtime::ObscuraJsRuntime;
use obscura_net::{
CallbackRegistry, ObscuraHttpClient, ObscuraNetError, RequestCallback, ResourceRequest,
@@ -281,6 +281,7 @@ pub struct Page {
/// It is reset once author styles are installed, so stylesheet download
/// latency does not incorrectly advance newly-created animations.
document_timeline_origin: std::time::Instant,
+ navigation_timing: NavigationTiming,
/// Optional page-scoped ceiling for an end-to-end navigation. Automation
/// frontends set this from their request timeout so a caller asking for a
/// 50-second navigation is not silently cut off by the process default.
@@ -1110,6 +1111,7 @@ impl Page {
default_background_color_override: None,
encoding: "UTF-8".to_string(),
document_timeline_origin: std::time::Instant::now(),
+ navigation_timing: NavigationTiming::default(),
navigation_timeout: None,
navigation_chain_limit: None,
history: Vec::new(),
@@ -1841,6 +1843,7 @@ impl Page {
rt.set_dom(dom);
}
+ rt.set_navigation_timing(self.navigation_timing.clone());
rt.run_page_init();
let _ = rt.execute_script(
"<device-metrics>",
@@ -2838,6 +2841,7 @@ impl Page {
// They still gate DOMContentLoaded, but observe the browser's
// `interactive` readyState while they execute.
if let Some(js) = &mut self.js {
+ js.record_navigation_timing("domInteractive");
let _ = js.execute_script(
"<ready-state-interactive>",
"globalThis.__documentReadyState__ = 'interactive';",
@@ -2923,11 +2927,15 @@ impl Page {
// dynamic script elements do not gate it. They do remain in the
// document's load-event delay set, including scripts inserted by
// a DOMContentLoaded listener.
- let _ = js.execute_script(
+ js.record_navigation_timing("domContentLoadedEventStart");
+ let completed = js.execute_script(
"<dom-content-loaded>",
"try { document.dispatchEvent(new Event('DOMContentLoaded', {bubbles:false,cancelable:false})); } catch(e) {}\n\
try { window.dispatchEvent(new Event('DOMContentLoaded', {bubbles:false,cancelable:false})); } catch(e) {}",
);
+ if completed.is_ok() {
+ js.record_navigation_timing("domContentLoadedEventEnd");
+ }
let load_blockers_finished =
Self::drive_load_delaying_scripts(js, script_deadline).await;
@@ -2940,7 +2948,9 @@ impl Page {
// readyState becomes complete before the load event. A script
// inserted by an onload handler is therefore post-load work and
// remains pending until an explicit caller settle/wait.
- let _ = js.execute_script(
+ js.record_navigation_timing("domComplete");
+ js.record_navigation_timing("loadEventStart");
+ let completed = js.execute_script(
"<load-event>",
"globalThis.__documentReadyState__ = 'complete';\n\
try {\n\
@@ -2948,6 +2958,9 @@ impl Page {
try { window.dispatchEvent(loadEvent); } catch(e) {}\n\
} catch(e) {}",
);
+ if completed.is_ok() {
+ js.record_navigation_timing("loadEventEnd");
+ }
}
if let Some(token) = exec_wd {
if let Some(js) = self.js.as_mut() {
@@ -3354,6 +3367,7 @@ impl Page {
referrer: &str,
) -> Result<(), PageError> {
let url = Url::parse(url_str).map_err(|e| PageError::InvalidUrl(e.to_string()))?;
+ self.navigation_timing = NavigationTiming::default();
// The previous document's background loads end with the document.
self.retire_render_resources();
@@ -3415,6 +3429,7 @@ impl Page {
return Ok(());
}
+ self.navigation_timing.record("fetchStart");
let response = if url.scheme() == "data" {
let content_type = url_str
.strip_prefix("data:")
@@ -3445,6 +3460,7 @@ impl Page {
self.lifecycle = LifecycleState::Failed;
PageError::NetworkError(e.to_string())
})?;
+ self.navigation_timing.record("responseEnd");
// Store binary main resources (images, PDFs, octet-stream) base64 so
// Network.getResponseBody returns intact bytes. A UTF-8-lossy text store
@@ -3471,6 +3487,7 @@ impl Page {
let (body_text, encoding_name) =
obscura_net::decode_response_with_name(&response.body, response.content_type());
self.encoding = encoding_name.to_string();
+ self.navigation_timing.record("domLoading");
let dom = parse_html(&body_text);
self.title = dom
@@ -3721,6 +3738,7 @@ impl Page {
}
pub fn navigate_blank(&mut self) {
+ self.navigation_timing = NavigationTiming::default();
self.retire_render_resources();
self.pending_frame_work.clear();
self.frames.clear();
@@ -4664,6 +4682,7 @@ impl Page {
return;
};
let started_script_ids = js.started_script_ids();
+ self.navigation_timing = js.navigation_timing();
// Preserve console messages logged before suspension: dropping the
// runtime below would otherwise lose any not yet drained (#971).
let pending_console = js.take_pending_console_messages();
@@ -7557,6 +7576,82 @@ mod tests {
);
}
+ #[tokio::test(flavor = "current_thread")]
+ async fn navigation_timing_records_lifecycle_boundaries_not_future_events() {
+ let mut page = import_map_test_page(
+ "navigation-timing", "http://127.0.0.1:9", "<html><body></body></html>",
+ );
+ let html = r#"<!doctype html><script>
+ globalThis.__navigationSamples = [];
+ function sample() {
+ const timing = performance.timing;
+ __navigationSamples.push([
+ timing.navigationStart, timing.responseEnd,
+ timing.domContentLoadedEventStart, timing.domContentLoadedEventEnd,
+ timing.loadEventStart, timing.loadEventEnd
+ ]);
+ }
+ sample();
+ document.addEventListener('DOMContentLoaded', sample);
+ window.addEventListener('load', sample);
+ </script><p>Real navigation timing</p>"#;
+ let encoded = base64::engine::general_purpose::STANDARD.encode(html);
+ page.navigate(&format!("data:text/html;base64,{encoded}")).await.unwrap();
+ let actual = page.js.as_mut().unwrap().evaluate(r#"(() => {
+ const [parser, dom, load] = __navigationSamples;
+ const final = performance.timing;
+ return [
+ parser[3] === 0 && parser[5] === 0,
+ Number.isFinite(parser[1]) && parser[1] >= parser[0],
+ dom[2] > 0 && dom[3] === 0,
+ load[4] > 0 && load[5] === 0,
+ final.domContentLoadedEventEnd >= dom[2],
+ final.loadEventStart >= final.domContentLoadedEventEnd,
+ final.loadEventEnd >= load[4],
+ performance.timeOrigin >= final.navigationStart
+ && performance.timeOrigin < final.navigationStart + 1
+ ];
+ })()"#).unwrap();
+ assert_eq!(actual, serde_json::json!([true, true, true, true, true, true, true, true]));
+ }
+
+ #[tokio::test(flavor = "current_thread")]
+ async fn navigation_timing_survives_suspension_but_resets_on_navigation() {
+ let mut page = import_map_test_page(
+ "navigation-timing-retention", "http://127.0.0.1:9", "<html><body></body></html>",
+ );
+ page.navigate("data:text/html,<p>First</p>").await.unwrap();
+ let expression = "[performance.timeOrigin, performance.timing.navigationStart, performance.timing.loadEventEnd]";
+ let before = page.js.as_mut().unwrap().evaluate(expression).unwrap();
+ assert!(before[2].as_f64().unwrap() > before[1].as_f64().unwrap());
+ page.suspend_js();
+ page.resume_js();
+ assert_eq!(page.js.as_mut().unwrap().evaluate(expression).unwrap(), before);
+ page.navigate("data:text/html,<p>Second</p>").await.unwrap();
+ let after = page.js.as_mut().unwrap().evaluate(expression).unwrap();
+ assert!(after[0].as_f64().unwrap() > before[0].as_f64().unwrap());
+ assert!(after[1].as_f64().unwrap() >= before[2].as_f64().unwrap());
+ }
+
+ #[tokio::test(flavor = "current_thread")]
+ async fn navigation_timing_terminated_handlers_do_not_record_completion() {
+ std::env::set_var("OBSCURA_SCRIPT_DEADLINE_MS", "250");
+ let mut page = import_map_test_page(
+ "terminated-navigation-timing", "http://127.0.0.1:9", "<html><body></body></html>",
+ );
+ for (event, field) in [
+ ("DOMContentLoaded", "domContentLoadedEventEnd"), ("load", "loadEventEnd"),
+ ] {
+ let html = format!("<script>window.addEventListener('{event}',()=>{{globalThis.entered=true;while(true){{}}}});</script>");
+ let encoded = base64::engine::general_purpose::STANDARD.encode(html);
+ page.navigate(&format!("data:text/html;base64,{encoded}")).await.unwrap();
+ assert_eq!(page.js.as_mut().unwrap().evaluate("globalThis.entered === true").unwrap(),
+ serde_json::json!(true), "the {event} handler must actually have started");
+ assert_eq!(page.js.as_mut().unwrap().evaluate(&format!("performance.timing.{field}")).unwrap().as_f64(),
+ Some(0.0), "the terminated {event} handler never completed");
+ }
+ }
+
#[tokio::test(flavor = "current_thread")]
async fn preload_dynamic_script_delays_load_but_not_dom_content_loaded() {
let (base, requests) = spawn_delayed_classic_script_server(
diff --git a/crates/obscura-js/js/bootstrap.js b/crates/obscura-js/js/bootstrap.js
index 41511764..0a815d4e 100644
--- a/crates/obscura-js/js/bootstrap.js
+++ b/crates/obscura-js/js/bootstrap.js
@@ -6323,16 +6323,22 @@ class Document extends Node {
// document.write's parser-blocking queue may still be fetching a
// classic script. It must finish before DOMContentLoaded is observable.
if (__parserBlockingScriptPending > 0) { setTimeout(finishParsing, 1); return; }
+ _dom('performance_lifecycle', 'domInteractive');
globalThis.__documentReadyState__ = 'interactive';
this.dispatchEvent(new Event('readystatechange'));
+ _dom('performance_lifecycle', 'domContentLoadedEventStart');
this.dispatchEvent(new Event('DOMContentLoaded', { bubbles: true }));
+ _dom('performance_lifecycle', 'domContentLoadedEventEnd');
_dom('document_lifecycle', 'DOMContentLoaded');
const complete = () => {
if (generation !== this._writeGeneration) return;
if (__dynLoadDelayingPending > 0) { setTimeout(complete, 1); return; }
+ _dom('performance_lifecycle', 'domComplete');
globalThis.__documentReadyState__ = 'complete';
this.dispatchEvent(new Event('readystatechange'));
+ _dom('performance_lifecycle', 'loadEventStart');
globalThis.dispatchEvent(new Event('load'));
+ _dom('performance_lifecycle', 'loadEventEnd');
_dom('document_lifecycle', 'load');
};
complete();
@@ -16743,11 +16749,18 @@ globalThis.__obscura_init = function() {
var memValues = globalThis.__obscura_stealth ? [4, 8] : [0.25, 0.5, 1, 2, 4, 8];
globalThis.__obscura_mem = memValues[Math.floor(_fpRand(401) * memValues.length)];
- // A navigation start precedes the wall clock, so skew into the past only: an
- // origin ahead of it makes performance.now() and the rAF timestamp negative.
- const t0 = Date.now() - 1 - Math.floor(_fpRand(641) * 100);
- globalThis.performance.timeOrigin = t0;
- globalThis.performance.timing = { navigationStart: t0, domContentLoadedEventEnd: t0, loadEventEnd: t0 };
+ const timing = {};
+ for (const name of Object.keys(JSON.parse(_dom('performance_timing')))) {
+ Object.defineProperty(timing, name, {
+ enumerable: true, get() { return +_dom('performance_timing', name); },
+ });
+ }
+ Object.defineProperty(globalThis.performance, 'timeOrigin', {
+ configurable: true, value: +_dom('performance_time_origin'), writable: false,
+ });
+ Object.defineProperty(globalThis.performance, 'timing', {
+ configurable: true, value: timing, writable: false,
+ });
var _totalHeap = 15000000 + Math.floor(_fpRand(620) * 85000000);
globalThis.performance.memory = {
jsHeapSizeLimit: 4294705152,
diff --git a/crates/obscura-js/src/frame.rs b/crates/obscura-js/src/frame.rs
index c46efda5..0785c374 100644
--- a/crates/obscura-js/src/frame.rs
+++ b/crates/obscura-js/src/frame.rs
@@ -98,6 +98,7 @@ impl FrameRealm {
}
let mut state = ObscuraState::new();
+ state.navigation_timing.record("domLoading");
state.dom = Some(parse_html(html));
state.url = url.to_string();
state.frame_id = frame_id;
@@ -147,20 +148,40 @@ impl FrameRealm {
/// can talk to its parent perfectly and still never build its interface,
/// which looks like a rendering problem and is a lifecycle one.
pub fn dispatch_load_events(&self, parent: &mut ObscuraJsRuntime) -> Result<(), String> {
+ let state = self.realms.borrow().by_frame_id(self.frame_id)
+ .ok_or_else(|| "Frame no longer exists".to_string())?;
+ {
+ let mut state = state.borrow_mut();
+ state.navigation_timing.record("domInteractive");
+ state.navigation_timing.record("domContentLoadedEventStart");
+ }
self.execute_script(
parent,
"globalThis.__documentReadyState__ = 'interactive';\
try { document.dispatchEvent(new Event('DOMContentLoaded', \
{ bubbles: false, cancelable: false })); } catch (_) {}\
try { window.dispatchEvent(new Event('DOMContentLoaded', \
- { bubbles: false, cancelable: false })); } catch (_) {}\
- globalThis.__documentReadyState__ = 'complete';\
+ { bubbles: false, cancelable: false })); } catch (_) {}",
+ )?;
+ {
+ let mut state = state.borrow_mut();
+ state.navigation_timing.record("domContentLoadedEventEnd");
+ state.navigation_timing.record("domComplete");
+ state.navigation_timing.record("loadEventStart");
+ }
+ let result = self.execute_script(
+ parent,
+ "globalThis.__documentReadyState__ = 'complete';\
try { document.dispatchEvent(new Event('readystatechange')); } catch (_) {}\
try { const loadEvent = new Event('load', \
{ bubbles: false, cancelable: false }); \
if (typeof window.onload === 'function') { try { window.onload.call(window, loadEvent); } catch (_) {} } \
try { window.dispatchEvent(loadEvent); } catch (_) {} } catch (_) {}",
- )
+ );
+ if result.is_ok() {
+ state.borrow_mut().navigation_timing.record("loadEventEnd");
+ }
+ result
}
/// Delivers a `postMessage` that another realm sent to this one.
@@ -829,6 +850,47 @@ mod tests {
);
}
+ #[test]
+ fn frame_navigation_timing_records_its_own_event_boundaries() {
+ let mut parent = page("https://parent.example/", "<html><body></body></html>");
+ let frame = FrameRealm::new(&mut parent, 1, 0, "https://parent.example/frame",
+ "<html><body></body></html>").unwrap();
+ frame.execute_script(&mut parent, r#"
+ globalThis.samples = [];
+ function sample() {
+ samples.push([performance.timing.domContentLoadedEventStart,
+ performance.timing.domContentLoadedEventEnd,
+ performance.timing.loadEventStart, performance.timing.loadEventEnd]);
+ }
+ document.addEventListener('DOMContentLoaded', sample);
+ window.addEventListener('load', sample);
+ Date.now = () => 0;
+ "#).unwrap();
+ frame.dispatch_load_events(&mut parent).unwrap();
+ assert_eq!(frame.evaluate(&mut parent, r#"(() => {
+ const [dom, load] = samples;
+ return [dom[0] > 0 && dom[1] === 0, load[2] > 0 && load[3] === 0,
+ performance.timing.domContentLoadedEventEnd >= dom[0],
+ performance.timing.loadEventEnd >= load[2]];
+ })()"#).unwrap(), serde_json::json!([true, true, true, true]));
+ assert_eq!(parent.evaluate("performance.timing.loadEventEnd").unwrap().as_f64(), Some(0.0));
+ }
+
+ #[test]
+ fn frame_navigation_timing_terminated_load_does_not_record_completion() {
+ let mut parent = page("https://parent.example/", "<html><body></body></html>");
+ let frame = FrameRealm::new(&mut parent, 1, 0, "https://parent.example/frame",
+ "<html><body></body></html>").unwrap();
+ frame.execute_script(&mut parent,
+ "window.addEventListener('load',()=>{globalThis.entered=true;while(true){}});").unwrap();
+ let token = parent.arm_watchdog(std::time::Duration::from_millis(250));
+ let result = frame.dispatch_load_events(&mut parent);
+ let fired = parent.disarm_watchdog(token);
+ assert!(fired && result.is_err(), "the infinite load handler must be terminated");
+ assert_eq!(frame.evaluate(&mut parent, "globalThis.entered === true").unwrap(), serde_json::json!(true));
+ assert_eq!(frame.evaluate(&mut parent, "performance.timing.loadEventEnd").unwrap().as_f64(), Some(0.0));
+ }
+
#[test]
fn frame_body_onload_content_attribute_reflects_to_window() {
let mut parent = page("https://parent.example/", "<html><body></body></html>");
diff --git a/crates/obscura-js/src/ops.rs b/crates/obscura-js/src/ops.rs
index 6e3cb024..5123c998 100644
--- a/crates/obscura-js/src/ops.rs
+++ b/crates/obscura-js/src/ops.rs
@@ -109,6 +109,44 @@ pub(crate) struct CanvasBackingSurface {
pub pixels: JsBuffer,
}
+const NAVIGATION_TIMING_FIELDS: [&str; 10] = [
+ "navigationStart", "fetchStart", "responseEnd", "domLoading", "domInteractive",
+ "domContentLoadedEventStart", "domContentLoadedEventEnd", "domComplete",
+ "loadEventStart", "loadEventEnd",
+];
+
+/// Observed document milestones, anchored once to the epoch and advanced by
+/// the monotonic clock. Unavailable transport details are not synthesized.
+#[derive(Clone)]
+pub struct NavigationTiming {
+ pub time_origin: f64,
+ origin: std::time::Instant,
+ values: [u64; 10],
+}
+
+impl Default for NavigationTiming {
+ fn default() -> Self {
+ let origin = std::time::Instant::now();
+ let time_origin = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH).unwrap_or_default().as_secs_f64() * 1_000.0;
+ let mut values = [0; 10];
+ values[0] = time_origin as u64;
+ Self { time_origin, origin, values }
+ }
+}
+
+impl NavigationTiming {
+ pub fn record(&mut self, name: &str) {
+ if let Some(index) = NAVIGATION_TIMING_FIELDS.iter().position(|field| *field == name) {
+ // document.open/close and synthetic events must not replace the
+ // first navigation's already-completed milestones.
+ if self.values[index] == 0 {
+ self.values[index] = (self.time_origin + self.origin.elapsed().as_secs_f64() * 1_000.0) as u64;
+ }
+ }
+ }
+}
+
pub struct ObscuraState {
pub dom: Option<DomTree>,
pub url: String,
@@ -124,6 +162,7 @@ pub struct ObscuraState {
/// browser/API navigations leave this empty; document-initiated
/// navigations set it to the source document URL.
pub referrer: String,
+ pub navigation_timing: NavigationTiming,
pub blocked_urls: Vec<String>,
pub cookie_jar: Option<Arc<CookieJar>>,
pub http_client: Option<Arc<ObscuraHttpClient>>,
@@ -384,6 +423,7 @@ impl ObscuraState {
encoding: "UTF-8".to_string(),
title: String::new(),
referrer: String::new(),
+ navigation_timing: NavigationTiming::default(),
blocked_urls: Vec::new(),
cookie_jar: None,
http_client: None,
@@ -1668,6 +1708,24 @@ fn op_dom(
}
fn op_dom_inner(shared: SharedState, cmd: String, arg1: String, arg2: String) -> String {
+ if cmd == "performance_time_origin" {
+ return shared.borrow().navigation_timing.time_origin.to_string();
+ }
+ if cmd == "performance_timing" {
+ let state = shared.borrow();
+ let timing = &state.navigation_timing;
+ if arg1.is_empty() {
+ let values: serde_json::Map<String, serde_json::Value> = NAVIGATION_TIMING_FIELDS
+ .iter().zip(timing.values).map(|(name, value)| (name.to_string(), value.into())).collect();
+ return serde_json::Value::Object(values).to_string();
+ }
+ return NAVIGATION_TIMING_FIELDS.iter().position(|field| *field == arg1)
+ .map(|index| timing.values[index].to_string()).unwrap_or_else(|| "null".into());
+ }
+ if cmd == "performance_lifecycle" {
+ shared.borrow_mut().navigation_timing.record(&arg1);
+ return "null".into();
+ }
if cmd == "document_lifecycle" {
let mut state = shared.borrow_mut();
// Page lifecycle collection is independent of Runtime.enable.
diff --git a/crates/obscura-js/src/runtime.rs b/crates/obscura-js/src/runtime.rs
index 8ed7727b..e712c961 100644
--- a/crates/obscura-js/src/runtime.rs
+++ b/crates/obscura-js/src/runtime.rs
@@ -2400,12 +2400,25 @@ impl ObscuraJsRuntime {
/// Run __obscura_init() after all per-page properties (UA, platform, stealth, etc.)
/// have been set. Must be called once per page setup, after all set_* methods.
pub fn run_page_init(&mut self) {
+ self.state.borrow_mut().navigation_timing.record("domLoading");
let _ = self.execute_runtime_script(
"<obscura:page-init>",
"globalThis.__obscura_init();".to_string(),
);
}
+ pub fn navigation_timing(&self) -> crate::ops::NavigationTiming {
+ self.state.borrow().navigation_timing.clone()
+ }
+
+ pub fn set_navigation_timing(&self, timing: crate::ops::NavigationTiming) {
+ self.state.borrow_mut().navigation_timing = timing;
+ }
+
+ pub fn record_navigation_timing(&self, name: &str) {
+ self.state.borrow_mut().navigation_timing.record(name);
+ }
+
/// Override the coordinates the navigator.geolocation shim reports. The
/// values are injected as numeric globals the bootstrap reads; when unset it
/// keeps the built-in default. Callers validate the range before calling.
@@ -6401,6 +6414,36 @@ mod tests {
);
}
+ #[tokio::test(flavor = "current_thread")]
+ async fn document_close_navigation_timing_records_real_lifecycle_only_once() {
+ let mut rt = setup_runtime("<html><body></body></html>");
+ assert_eq!(rt.evaluate("performance.timing.loadEventEnd").unwrap().as_f64(), Some(0.0));
+ rt.execute_script("document-close-timing", r#"
+ document.open();
+ globalThis.samples = [];
+ document.addEventListener('DOMContentLoaded', () => samples.push([
+ performance.timing.domContentLoadedEventStart, performance.timing.domContentLoadedEventEnd]));
+ window.addEventListener('load', () => samples.push([
+ performance.timing.loadEventStart, performance.timing.loadEventEnd]));
+ Date.now = () => 0;
+ document.write('<p>Written document</p>'); document.close();
+ "#).unwrap();
+ rt.run_event_loop_bounded(100).await.unwrap();
+ assert_eq!(rt.evaluate(r#"(() => {
+ const [dom, load] = samples;
+ const end = performance.timing.loadEventEnd;
+ const origin = performance.timeOrigin;
+ window.dispatchEvent(new Event('load'));
+ document.open(); document.write('<p>Written again</p>'); document.close();
+ return [dom[0] > 0 && dom[1] === 0, load[0] > 0 && load[1] === 0,
+ end >= load[0], performance.timing.loadEventEnd === end,
+ performance.timeOrigin === origin];
+ })()"#).unwrap(), serde_json::json!([true, true, true, true, true]));
+ let before = rt.evaluate("[performance.timeOrigin, performance.timing.loadEventEnd]").unwrap();
+ rt.run_event_loop_bounded(100).await.unwrap();
+ assert_eq!(rt.evaluate("[performance.timeOrigin, performance.timing.loadEventEnd]").unwrap(), before);
+ }
+
#[tokio::test(flavor = "current_thread")]
async fn performance_now_does_not_outrun_elapsed_time() {
let mut rt = setup_runtime("<html><body></body></html>");
diff --git a/docs/Use-with-Playwright.md b/docs/Use-with-Playwright.md
index 2de7a1eb..b482ebf4 100644
--- a/docs/Use-with-Playwright.md
+++ b/docs/Use-with-Playwright.md
@@ -117,8 +117,17 @@ named marks or numeric timestamps; `detail` is structured-cloned.
Navigation, resource, paint, and long-task entries are not emitted. User Timing
entries remain available until cleared or the realm is destroyed; applications
that continuously record timings should call `clearMarks()` and `clearMeasures()`.
-Legacy `performance.timing` is still incomplete; measurements using navigation
-milestone names are not yet reliable.
+Legacy `performance.timing` records main-document navigation start, fetch start,
+response completion and DOM/load milestones. Event-end values remain zero until
+their handlers finish. These read-only, integer epoch timestamps use a native
+monotonic clock and share the real origin with `performance.timeOrigin`; they
+survive runtime suspension and are not replaced by synthetic events or
+`document.open()`/`close()`. Named User Timing measures can use these milestones.
+Transport response completion is observed when the buffered fetch returns.
+DNS, connection, TLS, first-byte, redirect and previous-document unload timings
+remain unavailable rather than fabricated. Child realms record their own DOM
+and load milestones, but do not yet receive the fetch's start/completion metadata.
+This is partial legacy timing support, not Navigation Timing conformance.
## Multiple pages