The headless browser for AI agents and web scraping
feat(js): implement User Timing entries and observers
SGavrle4b61386b1dd
diff --git a/crates/obscura-js/js/bootstrap.js b/crates/obscura-js/js/bootstrap.jsindex 5ed990db..41511764 100644--- a/crates/obscura-js/js/bootstrap.js+++ b/crates/obscura-js/js/bootstrap.js@@ -10434,12 +10434,6 @@ globalThis.IntersectionObserver = class IntersectionObserver {else Promise.resolve().then(wireUp);})();globalThis.IntersectionObserverEntry = class IntersectionObserverEntry {};-globalThis.PerformanceObserver = class { constructor(){} observe(){} disconnect(){} };-// Feature detection reads this static before deciding to observe anything;-// absent it, supportedEntryTypes.includes(...) throws and instrumentation-// bails. Report only types the engine can actually emit records for.-PerformanceObserver.supportedEntryTypes = ["mark", "measure", "navigation", "resource", "paint"];-_markNative(PerformanceObserver);globalThis.DOMException = (function () {const NAME_TO_CODE = {@@ -11352,9 +11346,7 @@ globalThis.performance = globalThis.performance || {return _last;};})(),- mark(){}, measure(){},- clearMarks(){}, clearMeasures(){}, clearResourceTimings(){},- getEntries(){return [];}, getEntriesByName(){return [];}, getEntriesByType(){return [];},+ clearResourceTimings(){},setResourceTimingBufferSize(){},timeOrigin: 0,timing: { navigationStart: 0, domContentLoadedEventEnd: 0, loadEventEnd: 0 },@@ -11366,6 +11358,289 @@ globalThis.performance = globalThis.performance || {},};+// User Timing entries belong to this realm. The registry gives marks/measures+// an unlimited timeline: retain them until clearMarks/clearMeasures or teardown,+// not an arbitrary cap that silently invalidates long-running measurements.+(function() {+ const perf = globalThis.performance;+ globalThis.Performance = class Performance {+ constructor() { throw new TypeError('Illegal constructor'); }+ };+ Object.setPrototypeOf(perf, Performance.prototype);+ const buffers = Object.assign(Object.create(null), {mark: [], measure: []});+ const latestMarks = new Map();+ const entryState = new WeakMap();+ const observerState = new WeakMap();+ const listState = new WeakMap();+ const observers = new Set();+ const entryKey = {};+ const supported = Object.freeze(['mark', 'measure']);+ const timingNames = new Set([+ 'navigationStart', 'unloadEventStart', 'unloadEventEnd', 'redirectStart', 'redirectEnd',+ 'fetchStart', 'domainLookupStart', 'domainLookupEnd', 'connectStart', 'connectEnd',+ 'secureConnectionStart', 'requestStart', 'responseStart', 'responseEnd', 'domLoading',+ 'domInteractive', 'domContentLoadedEventStart', 'domContentLoadedEventEnd',+ 'domComplete', 'loadEventStart', 'loadEventEnd',+ ]);+ let deliveryPending = false;+ function state(map, receiver) {+ const value = map.get(receiver);+ if (!value) throw new TypeError('Illegal invocation');+ return value;+ }+ function string(value) {+ if (typeof value === 'symbol') throw new TypeError('Cannot convert a Symbol to a string');+ return String(value);+ }+ function dictionary(value) {+ if (value == null) return {};+ if (typeof value !== 'object' && typeof value !== 'function') throw new TypeError('Expected a dictionary');+ return value;+ }+ function number(value) {+ const result = +value;+ if (!Number.isFinite(result)) throw new TypeError('Timestamp must be finite');+ return result;+ }+ function timestamp(value) {+ if (typeof value === 'number') {+ value = number(value);+ if (value < 0) throw new TypeError('Timestamp must not be negative');+ return value;+ }+ value = string(value);+ if (timingNames.has(value)) {+ if (value === 'navigationStart') return 0;+ const time = perf.timing[value] || 0;+ if (!time) throw new DOMException('Timing event has not occurred', 'InvalidAccessError');+ return time - perf.timing.navigationStart;+ }+ const mark = latestMarks.get(value);+ if (!mark) throw new DOMException('The mark does not exist: ' + value, 'SyntaxError');+ return entryState.get(mark).startTime;+ }+ function entries(buffer, name, type) {+ return buffer.filter(entry => {+ const data = entryState.get(entry);+ return (name === undefined || data.name === name) && (type === undefined || data.entryType === type);+ }).sort((a, b) => entryState.get(a).startTime - entryState.get(b).startTime);+ }+ function allEntries() { return buffers.mark.concat(buffers.measure); }+ function checkPerformance(receiver) {+ if (receiver !== perf) throw new TypeError('Illegal invocation');+ }+ globalThis.PerformanceEntry = class PerformanceEntry {+ constructor(key) { if (key !== entryKey) throw new TypeError('Illegal constructor'); }+ get name() { return state(entryState, this).name; }+ get entryType() { return state(entryState, this).entryType; }+ get startTime() { return state(entryState, this).startTime; }+ get duration() { return state(entryState, this).duration; }+ toJSON() {+ const data = state(entryState, this);+ return {name: data.name, entryType: data.entryType, startTime: data.startTime, duration: data.duration, detail: data.detail};+ }+ };+ globalThis.PerformanceMark = class PerformanceMark extends PerformanceEntry {+ constructor(name, options = {}) {+ super(entryKey);+ if (!arguments.length) throw new TypeError('A mark name is required');+ name = string(name);+ options = dictionary(options);+ const detail = options.detail;+ const start = options.startTime;+ const startTime = start === undefined ? perf.now() : number(start);+ if (timingNames.has(name)) throw new DOMException('Reserved timing name: ' + name, 'SyntaxError');+ if (startTime < 0) throw new TypeError('Timestamp must not be negative');+ entryState.set(this, {name, entryType: 'mark', startTime, duration: 0,+ detail: detail === undefined ? null : _structuredClone(detail, new Map())});+ }+ get detail() {+ const data = state(entryState, this);+ if (data.entryType !== 'mark') throw new TypeError('Illegal invocation');+ return data.detail;+ }+ };+ globalThis.PerformanceMeasure = class PerformanceMeasure extends PerformanceEntry {+ constructor() { throw new TypeError('Illegal constructor'); }+ get detail() {+ const data = state(entryState, this);+ if (data.entryType !== 'measure') throw new TypeError('Illegal invocation');+ return data.detail;+ }+ };+ function queueDelivery() {+ if (deliveryPending) return;+ deliveryPending = true;+ // Reuse browser posted tasks: asynchronous delivery without a timer-wheel+ // delay or polling, cancelled at the document-generation boundary.+ _browserPostedTaskEnqueue(() => {+ deliveryPending = false;+ for (const observer of Array.from(observers)) {+ const data = observerState.get(observer);+ if (!data.records.length) continue;+ const list = Object.create(PerformanceObserverEntryList.prototype);+ listState.set(list, data.records);+ data.records = [];+ const options = data.requiresDroppedEntries ? {droppedEntriesCount: 0} : {};+ data.requiresDroppedEntries = false;+ try { data.callback.call(observer, list, observer, options); }+ catch (error) { globalThis.reportError(error); }+ }+ }, 0, _browserPostedTaskGeneration(), () => {+ deliveryPending = false;+ for (const observer of observers) observerState.get(observer).records = [];+ });+ }+ function record(entry) {+ const data = entryState.get(entry);+ buffers[data.entryType].push(entry);+ if (data.entryType === 'mark') {+ const previous = latestMarks.get(data.name);+ if (!previous || entryState.get(previous).startTime <= data.startTime) latestMarks.set(data.name, entry);+ }+ let notify = false;+ for (const observer of observers) {+ const observerData = observerState.get(observer);+ if (observerData.types.has(data.entryType)) { observerData.records.push(entry); notify = true; }+ }+ if (notify) queueDelivery();+ return entry;+ }+ perf.mark = function mark(name, options = {}) {+ checkPerformance(this);+ if (!arguments.length) throw new TypeError('A mark name is required');+ return record(new PerformanceMark(name, options));+ };+ perf.measure = function measure(name, startOrOptions = {}, endMark) {+ checkPerformance(this);+ if (!arguments.length) throw new TypeError('A measure name is required');+ name = string(name);+ const isOptions = startOrOptions == null || typeof startOrOptions === 'object' || typeof startOrOptions === 'function';+ let start, end, duration, detail;+ if (isOptions) {+ const options = dictionary(startOrOptions);+ detail = options.detail;+ const rawDuration = options.duration;+ duration = rawDuration === undefined ? undefined : number(rawDuration);+ end = options.end;+ if (typeof end === 'number') end = number(end);+ else if (end !== undefined) end = string(end);+ start = options.start;+ if (typeof start === 'number') start = number(start);+ else if (start !== undefined) start = string(start);+ if (start !== undefined || end !== undefined || duration !== undefined || detail !== undefined) {+ if (endMark !== undefined || (start === undefined && end === undefined) ||+ (start !== undefined && end !== undefined && duration !== undefined)) throw new TypeError('Invalid measure options');+ }+ } else start = string(startOrOptions);+ if (endMark !== undefined) end = string(endMark);+ const endTime = end !== undefined ? timestamp(end) :+ start !== undefined && duration !== undefined ? timestamp(start) + timestamp(duration) : perf.now();+ const startTime = start !== undefined ? timestamp(start) :+ duration !== undefined && end !== undefined ? timestamp(end) - timestamp(duration) : 0;+ const entry = Object.create(PerformanceMeasure.prototype);+ entryState.set(entry, {name, entryType: 'measure', startTime, duration: endTime - startTime,+ detail: detail === undefined ? null : _structuredClone(detail, new Map())});+ return record(entry);+ };+ function clear(type, name) {+ name = name === undefined ? undefined : string(name);+ buffers[type] = name === undefined ? [] : buffers[type].filter(entry => entryState.get(entry).name !== name);+ if (type === 'mark') {+ if (name === undefined) latestMarks.clear();+ else latestMarks.delete(name);+ }+ }+ perf.clearMarks = function clearMarks(name = undefined) { checkPerformance(this); clear('mark', name); };+ perf.clearMeasures = function clearMeasures(name = undefined) { checkPerformance(this); clear('measure', name); };+ perf.getEntries = function getEntries() { checkPerformance(this); return entries(allEntries()); };+ perf.getEntriesByType = function getEntriesByType(type) {+ checkPerformance(this);+ if (!arguments.length) throw new TypeError('An entry type is required');+ type = string(type);+ return entries(buffers[type] || []);+ };+ perf.getEntriesByName = function getEntriesByName(name, type = undefined) {+ checkPerformance(this);+ if (!arguments.length) throw new TypeError('An entry name is required');+ return entries(allEntries(), string(name), type === undefined ? undefined : string(type));+ };+ globalThis.PerformanceObserverEntryList = class PerformanceObserverEntryList {+ constructor() { throw new TypeError('Illegal constructor'); }+ getEntries() { return entries(state(listState, this)); }+ getEntriesByType(type) {+ const buffer = state(listState, this);+ if (!arguments.length) throw new TypeError('An entry type is required');+ return entries(buffer, undefined, string(type));+ }+ getEntriesByName(name, type = undefined) {+ const buffer = state(listState, this);+ if (!arguments.length) throw new TypeError('An entry name is required');+ return entries(buffer, string(name), type === undefined ? undefined : string(type));+ }+ };+ globalThis.PerformanceObserver = class PerformanceObserver {+ constructor(callback) {+ if (typeof callback !== 'function') throw new TypeError('An observer callback is required');+ observerState.set(this, {callback, records: [], types: new Set(), mode: undefined, requiresDroppedEntries: false});+ }+ observe(options = {}) {+ const data = state(observerState, this);+ options = dictionary(options);+ const buffered = options.buffered;+ const entryTypes = options.entryTypes;+ const rawType = options.type;+ const type = rawType === undefined ? undefined : string(rawType);+ if (entryTypes === undefined && type === undefined) throw new TypeError('An entry type is required');+ if (entryTypes !== undefined && (type !== undefined || buffered !== undefined)) throw new TypeError('Invalid observer options');+ let types;+ if (entryTypes !== undefined) {+ if (entryTypes == null || (typeof entryTypes !== 'object' && typeof entryTypes !== 'function')) throw new TypeError('Expected a sequence');+ if (typeof entryTypes[Symbol.iterator] !== 'function') throw new TypeError('Expected a sequence');+ types = Array.from(entryTypes, string);+ } else types = [type];+ const mode = entryTypes === undefined ? 'single' : 'multiple';+ if (data.mode !== undefined && data.mode !== mode) throw new DOMException('Cannot change observer mode', 'InvalidModificationError');+ data.mode = mode;+ data.requiresDroppedEntries = true;+ types = types.filter(value => supported.includes(value));+ if (!types.length) return;+ if (mode === 'multiple') data.types = new Set(types);+ else data.types.add(type);+ observers.add(this);+ if (buffered) {+ for (const entry of buffers[type]) data.records.push(entry);+ if (data.records.length) queueDelivery();+ }+ }+ disconnect() {+ const data = state(observerState, this);+ observers.delete(this);+ data.records = [];+ data.types.clear();+ }+ takeRecords() {+ const data = state(observerState, this);+ const records = data.records;+ data.records = [];+ return records;+ }+ static get supportedEntryTypes() { return supported; }+ };+ for (const name of ['mark', 'measure', 'clearMarks', 'clearMeasures', 'getEntries', 'getEntriesByType', 'getEntriesByName']) {+ Object.defineProperty(Performance.prototype, name, Object.getOwnPropertyDescriptor(perf, name));+ delete perf[name];+ }+ for (const name of ['Performance', 'PerformanceEntry', 'PerformanceMark', 'PerformanceMeasure', 'PerformanceObserverEntryList', 'PerformanceObserver']) {+ Object.defineProperty(globalThis, name, {enumerable: false});+ const proto = globalThis[name].prototype;+ Object.defineProperty(proto, Symbol.toStringTag, {value: name, configurable: true});+ for (const key of Object.getOwnPropertyNames(proto)) {+ if (key !== 'constructor') Object.defineProperty(proto, key, {...Object.getOwnPropertyDescriptor(proto, key), enumerable: true});+ }+ }+})();+var _commonFonts = ['Arial', 'Arial Black', 'Arial Narrow','Baskerville', 'Book Antiqua',diff --git a/crates/obscura-js/src/runtime.rs b/crates/obscura-js/src/runtime.rsindex 7193f86e..8ed7727b 100644--- a/crates/obscura-js/src/runtime.rs+++ b/crates/obscura-js/src/runtime.rs@@ -6167,6 +6167,223 @@ mod tests {);}+ #[test]+ fn user_timing_named_measures_resolve_recorded_timestamps() {+ let mut rt = setup_runtime("<html><body></body></html>");+ let result = rt.evaluate(r#"(function() {+ performance.mark('start', {startTime: 20});+ performance.mark('start', {startTime: 5});+ performance.mark('end', {startTime: 12});+ const measure = performance.measure('work', 'start', 'end');+ return [measure.startTime, measure.duration, measure.entryType,+ performance.getEntriesByType('mark').map(e => e.startTime),+ performance.getEntriesByName('work', 'measure').length];+ })()"#).unwrap();+ assert_eq!(result, serde_json::json!([20, -8, "measure", [5, 12, 20], 1]));+ }++ #[test]+ fn user_timing_options_clone_details_without_registering_constructors() {+ let mut rt = setup_runtime("<html><body></body></html>");+ let result = rt.evaluate(r#"(function() {+ const detail = {values: new Map([['count', 7]])}; detail.self = detail;+ const entry = performance.measure('work', {start: 3, duration: 4, detail});+ detail.values.set('count', 9);+ const standalone = new PerformanceMark('standalone', {startTime: 2});+ return [entry.startTime, entry.duration, entry.detail.values.get('count'),+ entry.detail.self === entry.detail, entry instanceof PerformanceMeasure,+ entry instanceof PerformanceEntry, Object.keys(entry),+ Object.prototype.toString.call(entry), standalone.duration,+ performance.getEntriesByName('standalone').length,+ performance.measure('backward', {start: 8, end: 2}).duration,+ performance.measure('derived', {end: 3, duration: 4}).startTime];+ })()"#).unwrap();+ assert_eq!(result, serde_json::json!([3, 4, 7, true, true, true, [],+ "[object PerformanceMeasure]", 0, 0, -6, -1]));+ }++ #[test]+ fn user_timing_clear_methods_preserve_other_entry_types() {+ let mut rt = setup_runtime("<html><body></body></html>");+ let result = rt.evaluate(r#"(function() {+ performance.mark('same', {startTime: 1});+ performance.mark('other', {startTime: 2});+ performance.measure('same', {start: 1, end: 3});+ performance.clearMarks('same');+ const before = performance.getEntries().map(e => e.entryType + ':' + e.name);+ performance.clearMeasures();+ return [before, performance.getEntries().map(e => e.name)];+ })()"#).unwrap();+ assert_eq!(result, serde_json::json!([["measure:same", "mark:other"], ["other"]]));+ }++ #[test]+ fn user_timing_rejects_invalid_measurements_without_recording_them() {+ let mut rt = setup_runtime("<html><body></body></html>");+ let result = rt.evaluate(r#"(function() {+ const errors = [+ () => performance.mark(), () => performance.measure(),+ () => performance.mark('navigationStart'),+ () => performance.mark('x', {startTime: -1}),+ () => performance.mark('x', {startTime: Infinity}),+ () => performance.mark('x', {detail: () => {}}),+ () => performance.measure('x', 'missing'),+ () => performance.measure('x', {duration: 2}),+ () => performance.measure('x', {detail: 2}),+ () => performance.measure('x', {start: 1, end: 2, duration: 1}),+ () => performance.measure('x', {start: 1}, 'missing'),+ () => performance.measure('x', {start: -1}),+ () => performance.measure('x', {start: NaN}),+ () => performance.getEntriesByName(),+ () => new PerformanceEntry(), () => new PerformanceMeasure(),+ ].map(fn => { try { fn(); return 'none'; } catch (error) { return error.name; } });+ return [errors, performance.getEntries().length];+ })()"#).unwrap();+ assert_eq!(result, serde_json::json!([[+ "TypeError", "TypeError", "SyntaxError", "TypeError", "TypeError", "DataCloneError",+ "SyntaxError", "TypeError", "TypeError", "TypeError", "TypeError", "TypeError",+ "TypeError", "TypeError", "TypeError", "TypeError"], 0]));+ }++ #[tokio::test(flavor = "current_thread")]+ async fn user_timing_observer_delivers_buffered_entries_after_the_current_task() {+ let mut rt = setup_runtime("<html><body></body></html>");+ rt.execute_script("user-timing-observer", r#"+ globalThis.__timingDelivery = [];+ let synchronous = true;+ performance.mark('old', {startTime: 9});+ const observer = new PerformanceObserver(function(list, owner) {+ __timingDelivery.push([!synchronous, this === owner && owner === observer,+ list.getEntries().map(e => e.name), list.getEntriesByName('new', 'mark').length,+ Object.prototype.toString.call(list)]);+ observer.disconnect();+ });+ observer.observe({type: 'mark', buffered: true});+ performance.mark('new', {startTime: 2});+ performance.clearMarks();+ synchronous = false;+ "#).unwrap();+ rt.run_event_loop_bounded(100).await.unwrap();+ assert_eq!(rt.evaluate("__timingDelivery").unwrap(), serde_json::json!([+ [true, true, ["new", "old"], 1, "[object PerformanceObserverEntryList]"]+ ]));+ }++ #[tokio::test(flavor = "current_thread")]+ async fn user_timing_drained_observers_do_not_starve_other_observers() {+ let mut rt = setup_runtime("<html><body></body></html>");+ rt.execute_script("user-timing-drain", r#"+ globalThis.__timingDrain = {callbacks: []};+ const drained = new PerformanceObserver(() => __timingDrain.callbacks.push('drained'));+ const cancelled = new PerformanceObserver(() => __timingDrain.callbacks.push('cancelled'));+ const active = new PerformanceObserver(list => {+ __timingDrain.callbacks.push(list.getEntries().map(e => e.name));+ active.disconnect();+ });+ drained.observe({type: 'mark'});+ cancelled.observe({type: 'mark'});+ active.observe({type: 'mark'});+ performance.mark('first', {startTime: 5});+ performance.mark('second', {startTime: 1});+ __timingDrain.records = drained.takeRecords().map(e => e.name);+ cancelled.disconnect();+ __timingDrain.cancelledRecords = cancelled.takeRecords().length;+ try { cancelled.observe({entryTypes: ['mark']}); }+ catch (error) { __timingDrain.modeError = error.name; }+ "#).unwrap();+ rt.run_event_loop_bounded(100).await.unwrap();+ assert_eq!(rt.evaluate("__timingDrain").unwrap(), serde_json::json!({+ "callbacks": [["second", "first"]], "records": ["first", "second"],+ "cancelledRecords": 0, "modeError": "InvalidModificationError",+ }));+ }++ #[test]+ fn user_timing_unknown_entry_types_return_empty_lists() {+ let mut rt = setup_runtime("<html><body></body></html>");+ let result = rt.evaluate(r#"['__proto__', 'constructor', 'toString', 'unsupported']+ .map(type => performance.getEntriesByType(type).length)"#).unwrap();+ assert_eq!(result, serde_json::json!([0, 0, 0, 0]));+ }++ #[test]+ fn user_timing_webidl_dictionary_getters_are_read_once() {+ let mut rt = setup_runtime("<html><body></body></html>");+ let result = rt.evaluate(r#"(function() {+ let durationReads = 0, typeReads = 0;+ const measure = performance.measure('work', {start: 3,+ get duration() { durationReads++; return 4; }});+ const observer = new PerformanceObserver(() => {});+ observer.observe({get type() { typeReads++; return 'mark'; }});+ observer.disconnect();+ return [measure.duration, durationReads, typeReads];+ })()"#).unwrap();+ assert_eq!(result, serde_json::json!([4, 1, 1]));+ }++ #[tokio::test(flavor = "current_thread")]+ async fn user_timing_buffered_observers_accept_large_timelines() {+ let mut rt = setup_runtime("<html><body></body></html>");+ rt.execute_script("large-timing-timeline", r#"+ for (let i = 0; i < 150000; i++) performance.mark('work', {startTime: i});+ globalThis.__largeTimingDelivery = [];+ const observer = new PerformanceObserver(list => {+ const entries = list.getEntries();+ __largeTimingDelivery = [entries.length, entries[0].startTime,+ entries[entries.length - 1].startTime];+ observer.disconnect();+ });+ observer.observe({type: 'mark', buffered: true});+ performance.clearMarks();+ "#).unwrap();+ rt.run_event_loop_bounded(1000).await.unwrap();+ assert_eq!(rt.evaluate("__largeTimingDelivery").unwrap(),+ serde_json::json!([150000, 0, 149999]));+ }++ #[tokio::test(flavor = "current_thread")]+ async fn user_timing_observer_reports_dropped_entries_once_per_observe() {+ let mut rt = setup_runtime("<html><body></body></html>");+ rt.execute_script("timing-callback-options", r#"+ globalThis.__timingOptions = [];+ const observer = new PerformanceObserver((list, owner, options) => {+ __timingOptions.push([list.getEntries().map(e => e.name),+ Object.hasOwn(options, 'droppedEntriesCount') ? options.droppedEntriesCount : 'unset']);+ if (__timingOptions.length === 1) performance.mark('second');+ else if (__timingOptions.length === 2) {+ owner.observe({type: 'mark'});+ performance.mark('third');+ } else owner.disconnect();+ });+ observer.observe({type: 'mark'});+ performance.mark('first');+ "#).unwrap();+ rt.run_event_loop_bounded(100).await.unwrap();+ assert_eq!(rt.evaluate("__timingOptions").unwrap(), serde_json::json!([+ [["first"], 0], [["second"], "unset"], [["third"], 0]+ ]));+ }++ #[test]+ fn user_timing_interfaces_expose_inherited_operations() {+ let mut rt = setup_runtime("<html><body></body></html>");+ let result = rt.evaluate(r#"(function() {+ if (typeof Performance !== 'function') return 'Performance missing';+ const mark = Performance.prototype.mark.call(performance, 'work', {startTime: 7});+ const measure = Performance.prototype.measure.call(performance, 'work', {start: 7, duration: 3});+ let illegal = 'none';+ try { new Performance(); } catch (error) { illegal = error.name; }+ return [performance instanceof Performance, illegal, mark.startTime, measure.duration,+ ['mark', 'clearMarks', 'measure', 'clearMeasures'].map(name =>+ [Object.hasOwn(performance, name), performance[name].length, performance[name].name]),+ ['Performance', 'PerformanceMark', 'PerformanceMeasure', 'PerformanceObserver'].map(name =>+ Object.getOwnPropertyDescriptor(globalThis, name).enumerable)];+ })()"#).unwrap();+ assert_eq!(result, serde_json::json!([true, "TypeError", 7, 3,+ [[false, 1, "mark"], [false, 0, "clearMarks"], [false, 1, "measure"],+ [false, 0, "clearMeasures"]], [false, false, false, false]]));+ }+#[test]fn performance_now_is_monotonic_under_bursty_calls() {let mut rt = setup_runtime("<html><body></body></html>");diff --git a/docs/Use-with-Playwright.md b/docs/Use-with-Playwright.mdindex c4665d23..2de7a1eb 100644--- a/docs/Use-with-Playwright.md+++ b/docs/Use-with-Playwright.md@@ -106,6 +106,20 @@ not run page tasks or force collection. `embedderHeapUsedSize` is zero becauseObscura's Rust DOM is not a V8-managed cppgc heap; Rust allocations and renderermemory are not included.+## Application timing++Page scripts can record `performance.mark()` and `performance.measure()`+entries, retrieve them through the timeline getters, and observe them through+`PerformanceObserver`, including buffered delivery. Measurement options accept+named marks or numeric timestamps; `detail` is structured-cloned.++`PerformanceObserver.supportedEntryTypes` reports `mark` and `measure` only.+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.+## Multiple pages```js