fix(performance): validate observer options and retain observe mode

This commit is contained in:
ldm0
2026-10-11 18:06:48 +08:00
parent 68e47c85cd
commit 27953cc9f1
3 changed files with 21 additions and 0 deletions
@@ -2313,6 +2313,7 @@ mod offline_audio_context_interfaces;
mod offline_audio_float;
mod payment_response_interfaces;
mod performance_measurement_interfaces;
mod performance_observer_contract;
mod performance_receivers;
mod periodic_wave_interfaces;
mod popup_root_window;
@@ -1541,6 +1541,7 @@ mod strict_script_mime;
mod network;
mod onerror;
mod performance_observer_contract;
mod postmessage;
mod canvas_transform_snapshots;
mod synthetic_exceptions;
@@ -0,0 +1,19 @@
use super::*;
#[tokio::test]
async fn worker_observer_options_modes_and_disconnect_match_window_semantics() {
ensure_v8();
let source = format!(
r#"const probe = {};
const checks = probe(globalThis, globalThis, 'worker');
postMessage({{total: checks.length, failures: checks.filter(row => !row.passed)}});
close();"#,
include_str!("../../../script_vm/tests/performance_observer_contract.js"),
);
let mut worker = spawn_worker(source, "test://performance_observer_contract".into());
let message = timeout(TIMEOUT, worker.recv())
.await
.expect("timed out")
.expect("channel closed");
assert_eq!(expect_post_json(message), r#"{"total":91,"failures":[]}"#);
}