diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79f5971efa6..ba701de928a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,8 +117,13 @@ jobs: - name: Check clippy run: cargo clippy --workspace --all-targets --all-features -- -D warnings - - name: Check standalone DevTools feature contracts - run: python3 tools/devtools-size-ab.py --check-only --online --jobs 2 + - name: Check renderer tests without DevTools + run: cargo check --locked -p moli-renderer-v8 --no-default-features --tests + + - name: Check standalone DevTools contracts and run runtime smoke + env: + CARGO_PROFILE_DEV_DEBUG: "0" + run: python3 tools/devtools-size-ab.py --check-only --runtime-smoke --online --jobs 2 nextest: name: Nextest diff --git a/docs/DEVTOOLS.md b/docs/DEVTOOLS.md index ba05a6f3f4f..f184e524da1 100644 --- a/docs/DEVTOOLS.md +++ b/docs/DEVTOOLS.md @@ -16,6 +16,9 @@ instrumentation, frontend node/session state, synthetic input, Fetch interceptio commands, network-resource loading for DevTools and ServiceWorker debugger controls. Command variants, constructors and corresponding dispatch branches use `#[cfg]`. A disabled build cannot construct or call these frontend operations. +Worker startup pause settings and Fetch interception settings follow the same +feature gate as the commands that resume them. Shared document load parameters +apply interception only when DevTools is enabled. The disabled build does not create a default frontend Inspector session. Page and Worker frontend session tables, frontend response sinks, DOM subscriptions @@ -46,23 +49,26 @@ A workspace build can enable DevTools through another member or a development dependency. Check a standalone consumer as well as the full workspace: ```sh -python3 tools/devtools-size-ab.py --check-only +python3 tools/devtools-size-ab.py --check-only --runtime-smoke +cargo check -p moli-renderer-v8 --no-default-features --tests python3 tools/devtools-size-ab.py --limo-root ../limo --jobs 1 ``` The script generates an independent workspace under the output directory and -uses the local checkout. API checks are self-contained and do not require Limo; -the release size and runtime comparison additionally uses a Limo checkout. +uses the local checkout. The runtime probe starts a local HTTP fixture. +The release size comparison also uses a Limo checkout. Positive checks preserve evaluation, capture and PDF and selector/script wait APIs. The two asymmetric combinations (types enabled with the renderer disabled, and renderer enabled with the core facade disabled) also have to compile. Negative checks require the DevTools command types, facade entry points and protocol-only DOM commands to fail compilation without the feature; the -same fixtures must compile with it enabled. +same fixtures must compile with it enabled. The negative checks also cover +Worker startup pause settings and navigation interception configuration. The runtime probe checks DOM activation and selection, host evaluation and -Promise results, selector waits, Worker fetch/XHR, process/Worker timezone notifications, -ServiceWorker registration, PNG capture and PDF output. The smoke runner compares +Promise results, selector waits, Page fetch, Dedicated Worker fetch/XHR, +SharedWorker startup and fetch, process and Worker timezone notifications, +ServiceWorker registration, PNG capture and PDF output. The release smoke runner compares both variants on the same cases, recording existing failures separately from behavior differences introduced by the feature. diff --git a/moli-core/src/page/accessibility_support/mod.rs b/moli-core/src/page/accessibility_support/mod.rs index 2ba711495a4..332998bc09a 100644 --- a/moli-core/src/page/accessibility_support/mod.rs +++ b/moli-core/src/page/accessibility_support/mod.rs @@ -25,8 +25,10 @@ impl Page { RendererPageReply::OptionalAccessibilityNodes(nodes) => Ok(nodes), ) } +} - #[cfg(feature = "devtools")] +#[cfg(feature = "devtools")] +impl Page { pub fn start_accessibility_tree_payloads_for_document( &self, max_depth: Option, @@ -36,7 +38,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_accessibility_tree_payloads( &mut self, completion: CompletedPageCommand, @@ -46,7 +47,6 @@ impl Page { .unwrap_or_default()) } - #[cfg(feature = "devtools")] pub fn finish_accessibility_tree_payloads_optional( &mut self, completion: CompletedPageCommand, @@ -60,7 +60,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub async fn accessibility_tree_payloads_for_document_async( &mut self, max_depth: Option, @@ -70,14 +69,12 @@ impl Page { self.finish_accessibility_tree_payloads(completion) } - #[cfg(feature = "devtools")] pub fn start_accessibility_node_payload_for_document( &self, ) -> anyhow::Result { self.start_page_command(RendererPageCommand::AccessibilityNodePayloadForDocument) } - #[cfg(feature = "devtools")] pub fn finish_accessibility_node_payload( &mut self, completion: CompletedPageCommand, @@ -91,7 +88,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_accessibility_tree_payloads_for_node( &self, reference: RendererDomNodeReference, @@ -103,7 +99,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn start_accessibility_tree_payloads_for_backend_node_id( &self, backend_node_id: u32, @@ -115,7 +110,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_accessibility_node_payload_for_node( &self, reference: RendererDomNodeReference, @@ -123,7 +117,6 @@ impl Page { self.start_page_command(RendererPageCommand::AccessibilityNodePayloadForNode { reference }) } - #[cfg(feature = "devtools")] pub fn start_accessibility_node_payload_for_backend_node_id( &self, backend_node_id: u32, @@ -133,7 +126,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn start_accessibility_node_and_ancestor_payloads_for_node( &self, reference: RendererDomNodeReference, @@ -143,7 +135,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_accessibility_node_and_ancestor_payloads_for_backend_node_id( &self, backend_node_id: u32, @@ -153,7 +144,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_accessibility_child_node_payloads_for_node( &self, reference: RendererDomNodeReference, @@ -163,7 +153,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn start_accessibility_child_node_payloads_for_backend_node_id( &self, backend_node_id: u32, @@ -173,7 +162,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_accessibility_partial_tree_payloads_for_node( &self, reference: RendererDomNodeReference, @@ -187,7 +175,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_accessibility_partial_tree_payloads_for_backend_node_id( &self, backend_node_id: u32, @@ -199,7 +186,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn finish_accessibility_payloads_for_backend_node_id( &mut self, completion: CompletedPageCommand, @@ -213,7 +199,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_accessibility_tree_payloads_for_object_id( &self, inspector_session_id: Option, @@ -227,7 +212,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_accessibility_node_and_ancestor_payloads_for_object_id( &self, inspector_session_id: Option, @@ -241,7 +225,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_accessibility_partial_tree_payloads_for_object_id( &self, inspector_session_id: Option, @@ -257,7 +240,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn finish_accessibility_payloads_for_object_id( &mut self, completion: CompletedPageCommand, @@ -271,7 +253,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub async fn child_frame_accessibility_tree_payloads_async( &mut self, frame_id: &str, @@ -282,7 +263,6 @@ impl Page { self.finish_child_frame_accessibility_tree_payloads(completion, max_depth) } - #[cfg(feature = "devtools")] pub fn start_child_frame_accessibility_tree_payloads( &self, frame_id: &str, @@ -296,7 +276,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn finish_child_frame_accessibility_tree_payloads( &mut self, completion: CompletedPageCommand, @@ -307,7 +286,6 @@ impl Page { .and_then(|payloads| payloads.payloads)) } - #[cfg(feature = "devtools")] pub fn finish_child_frame_accessibility_payloads( &mut self, completion: CompletedPageCommand, @@ -321,7 +299,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_child_frame_accessibility_node_payload( &self, frame_id: &str, @@ -331,7 +308,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_child_frame_accessibility_node_payload( &mut self, completion: CompletedPageCommand, diff --git a/moli-core/src/page/input_support.rs b/moli-core/src/page/input_support.rs index c76b9dd04b6..12afa9dfbf3 100644 --- a/moli-core/src/page/input_support.rs +++ b/moli-core/src/page/input_support.rs @@ -6,7 +6,6 @@ use super::{ RendererPointerEventProperties, RendererTouchPoint, }; -#[cfg(feature = "devtools")] fn decode_input_dispatch_outcome_reply( reply: RendererPageReply, operation: &str, @@ -39,7 +38,6 @@ fn settled_input_reply(completion: RendererCommandTurnCompletion) -> Result, @@ -363,7 +352,6 @@ impl PageInputExt for Page { }) } - #[cfg(feature = "devtools")] fn finish_dispatch_touch_event_at_point_with_outcome( &mut self, completion: CompletedPageCommand, @@ -372,7 +360,6 @@ impl PageInputExt for Page { decode_input_dispatch_outcome_reply(reply, "touch event page command") } - #[cfg(feature = "devtools")] async fn dispatch_drag_event_at_point_with_outcome_async( &mut self, x: f64, @@ -387,7 +374,6 @@ impl PageInputExt for Page { .await } - #[cfg(feature = "devtools")] async fn dispatch_drag_event_at_point_async( &mut self, x: f64, @@ -399,7 +385,6 @@ impl PageInputExt for Page { Page::dispatch_drag_event_at_point_async(self, x, y, event_name, data, modifiers).await } - #[cfg(feature = "devtools")] fn start_dispatch_drag_event_at_point_with_outcome( &self, x: f64, @@ -417,7 +402,6 @@ impl PageInputExt for Page { }) } - #[cfg(feature = "devtools")] fn finish_dispatch_drag_event_at_point_with_outcome( &mut self, completion: CompletedPageCommand, @@ -426,17 +410,14 @@ impl PageInputExt for Page { decode_input_dispatch_outcome_reply(reply, "drag event page command") } - #[cfg(feature = "devtools")] async fn clear_active_drag_data_transfer_async(&mut self) -> Result<()> { Page::clear_active_drag_data_transfer_async(self).await } - #[cfg(feature = "devtools")] fn start_clear_active_drag_data_transfer(&self) -> Result { self.start_page_command(RendererPageCommand::ClearActiveDragDataTransfer) } - #[cfg(feature = "devtools")] fn start_cancel_dragging(&self) -> Result { self.start_page_command(RendererPageCommand::CancelDragging) } @@ -454,12 +435,10 @@ impl PageInputExt for Page { ) } - #[cfg(feature = "devtools")] async fn insert_text_into_active_control_async(&mut self, text: &str) -> Result { Page::insert_text_into_active_control_async(self, text).await } - #[cfg(feature = "devtools")] fn start_insert_text_into_active_control(&self, text: &str) -> Result { self.start_page_command(RendererPageCommand::InsertTextIntoActiveControl( text.to_owned(), @@ -474,7 +453,6 @@ impl PageInputExt for Page { decode_insert_text_reply(reply) } - #[cfg(feature = "devtools")] async fn dispatch_key_event_with_outcome_async( &mut self, event_name: &str, @@ -498,7 +476,6 @@ impl PageInputExt for Page { .await } - #[cfg(feature = "devtools")] fn start_dispatch_key_event_with_outcome( &self, event_name: &str, @@ -521,7 +498,6 @@ impl PageInputExt for Page { ) } - #[cfg(feature = "devtools")] fn finish_dispatch_key_event_with_outcome( &mut self, completion: CompletedPageCommand, @@ -530,7 +506,6 @@ impl PageInputExt for Page { decode_input_dispatch_outcome_reply(reply, "key event page command") } - #[cfg(feature = "devtools")] async fn dispatch_key_event_async( &mut self, event_name: &str, @@ -556,7 +531,6 @@ impl PageInputExt for Page { } impl Page { - #[cfg(feature = "devtools")] pub fn start_prepare_element_click( &self, inspector_session_id: Option, @@ -568,7 +542,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn start_dispatch_prepared_element_click( &self, click: super::RendererPreparedPointerClick, @@ -586,7 +559,6 @@ pub fn decode_element_click_preparation_completion( } #[doc(hidden)] -#[cfg(feature = "devtools")] pub fn decode_element_click_dispatch_completion( completion: RendererCommandTurnCompletion, ) -> Result> { @@ -597,7 +569,6 @@ pub fn decode_element_click_dispatch_completion( impl Page { /// Starts key dispatch with an explicit DOM KeyboardEvent location. /// The legacy PageInputExt entry point continues to use location 0. - #[cfg(feature = "devtools")] pub fn start_dispatch_key_event_with_location_outcome( &self, event_name: &str, diff --git a/moli-core/src/page/js_evaluation.rs b/moli-core/src/page/js_evaluation.rs index fd90601c4da..f921992ad6d 100644 --- a/moli-core/src/page/js_evaluation.rs +++ b/moli-core/src/page/js_evaluation.rs @@ -449,8 +449,10 @@ impl Page { RendererPageReply::OptionalString(frame_id) => Ok(frame_id), ) } +} - #[cfg(feature = "devtools")] +#[cfg(feature = "devtools")] +impl Page { pub async fn create_isolated_world_async( &mut self, name: &str, @@ -470,7 +472,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub async fn create_isolated_world_for_frame_async( &mut self, frame_id: &str, @@ -491,7 +492,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_create_isolated_world( &self, name: &str, @@ -505,7 +505,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn start_create_isolated_world_runtime_activity_capturing_runtime_inspector_messages( &self, inspector_session_id: Option<&str>, @@ -521,7 +520,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_create_isolated_world( &mut self, completion: CompletedPageCommand, @@ -531,7 +529,6 @@ impl Page { Ok(execution_context_id) } - #[cfg(feature = "devtools")] pub fn finish_create_isolated_world_command_turn( &mut self, completion: CompletedPageCommand, @@ -547,7 +544,6 @@ impl Page { Ok((*execution_context_id, output)) } - #[cfg(feature = "devtools")] pub async fn dispatch_runtime_protocol_message_async( &mut self, raw_json: &str, @@ -557,7 +553,6 @@ impl Page { self.finish_runtime_protocol_message(completion) } - #[cfg(feature = "devtools")] pub async fn dispatch_runtime_protocol_message_for_inspector_session_async( &mut self, inspector_session_id: Option, @@ -571,12 +566,10 @@ impl Page { self.finish_runtime_protocol_message(completion) } - #[cfg(feature = "devtools")] pub fn start_runtime_protocol_message(&self, raw_json: String) -> Result { self.start_runtime_protocol_message_for_inspector_session(None, raw_json) } - #[cfg(feature = "devtools")] pub fn start_runtime_protocol_message_for_inspector_session( &self, inspector_session_id: Option, @@ -588,7 +581,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn start_runtime_protocol_message_with_deferred_response( &self, raw_json: String, @@ -601,7 +593,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_runtime_protocol_message_for_inspector_session_with_deferred_response( &self, inspector_session_id: Option, @@ -617,7 +608,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_routable_runtime_protocol_message_for_inspector_session( &self, inspector_session_id: Option, @@ -664,7 +654,6 @@ impl Page { } } - #[cfg(feature = "devtools")] pub fn start_runtime_inspector_io_message_without_response( &self, inspector_session_id: Option, @@ -683,7 +672,9 @@ impl Page { ); Ok(Self::pending_io_runtime_inspector_command_dispatch(route)) } +} +impl Page { pub fn runtime_inspector_pause_active(&self) -> bool { self.handle.runtime_inspector_pause_active() } @@ -803,8 +794,10 @@ impl Page { Ok(serde_json::to_string(&message)?) } +} - #[cfg(feature = "devtools")] +#[cfg(feature = "devtools")] +impl Page { pub async fn runtime_enable_events_async( &mut self, ) -> Result> { @@ -812,7 +805,6 @@ impl Page { .await } - #[cfg(feature = "devtools")] pub async fn runtime_enable_events_for_inspector_session_async( &mut self, inspector_session_id: Option<&str>, @@ -823,7 +815,6 @@ impl Page { self.finish_runtime_enable_events(completion) } - #[cfg(feature = "devtools")] pub async fn runtime_enable_context_restore_events_for_inspector_session_async( &mut self, inspector_session_id: Option<&str>, @@ -834,12 +825,10 @@ impl Page { self.finish_runtime_enable_context_restore_events(completion) } - #[cfg(feature = "devtools")] pub fn start_runtime_enable_events(&self) -> Result { self.start_runtime_enable_events_for_inspector_session(None) } - #[cfg(feature = "devtools")] pub fn start_runtime_enable_events_for_inspector_session( &self, inspector_session_id: Option<&str>, @@ -848,7 +837,9 @@ impl Page { inspector_session_id.map(str::to_owned), )) } +} +impl Page { pub fn finish_runtime_enable_events( &mut self, completion: CompletedPageCommand, @@ -938,20 +929,20 @@ impl Page { RendererPageReply::RuntimeConsoleMessageSnapshots(messages) => Ok(messages), ) } +} - #[cfg(feature = "devtools")] +#[cfg(feature = "devtools")] +impl Page { pub async fn runtime_heap_usage_async(&mut self) -> Result { let pending = self.start_runtime_heap_usage()?; let completion = pending.wait().await?; self.finish_runtime_heap_usage(completion) } - #[cfg(feature = "devtools")] pub fn start_runtime_heap_usage(&self) -> Result { self.start_page_command(RendererPageCommand::RuntimeHeapUsage) } - #[cfg(feature = "devtools")] pub fn finish_runtime_heap_usage( &mut self, completion: CompletedPageCommand, @@ -965,7 +956,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_performance_metric_snapshot(&self) -> Result { self.start_page_command(RendererPageCommand::PerformanceMetricSnapshot) } @@ -974,7 +964,6 @@ impl Page { /// by interruptible V8 Inspector commands. The snapshot remains the latest /// owner-published value because collecting a fresh JS-derived snapshot is /// not re-entrant while the isolate is executing JavaScript. - #[cfg(feature = "devtools")] pub fn start_performance_metric_snapshot_from_io( &self, ) -> ( @@ -993,7 +982,6 @@ impl Page { /// Publishes the terminal `Performance.getMetrics` response through the /// concrete renderer DevTools session that owns this Page attachment. - #[cfg(feature = "devtools")] pub fn start_performance_get_metrics_from_io_with_response( &self, inspector_session_id: Option, @@ -1013,12 +1001,16 @@ impl Page { ); Ok(Self::pending_devtools_io_command_dispatch(route)) } +} +impl Page { pub fn cached_performance_metric_snapshot(&self) -> RendererPerformanceMetricSnapshot { self.page_state.performance_metric_snapshot().clone() } +} - #[cfg(feature = "devtools")] +#[cfg(feature = "devtools")] +impl Page { pub fn finish_performance_metric_snapshot( &mut self, completion: CompletedPageCommand, @@ -1032,7 +1024,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_dom_debugger_get_event_listeners( &self, inspector_session_id: Option, @@ -1048,7 +1039,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn finish_dom_debugger_get_event_listeners( &mut self, completion: CompletedPageCommand, @@ -1062,7 +1052,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_dom_debugger_configure_event_listener_breakpoint( &self, inspector_session_id: Option, @@ -1078,7 +1067,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_dom_debugger_configure_xhr_breakpoint( &self, inspector_session_id: Option, @@ -1092,7 +1080,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn start_dom_debugger_configure_dom_breakpoint( &self, inspector_session_id: Option, @@ -1108,7 +1095,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_dom_debugger_configure_dom_breakpoint( &mut self, completion: CompletedPageCommand, @@ -1122,11 +1108,12 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_runtime_collect_garbage(&self) -> Result { self.start_page_command(RendererPageCommand::RuntimeCollectGarbage) } +} +impl Page { pub fn finish_runtime_collect_garbage( &mut self, completion: CompletedPageCommand, @@ -1139,8 +1126,10 @@ impl Page { RendererPageReply::Unit => Ok(()), ) } +} - #[cfg(feature = "devtools")] +#[cfg(feature = "devtools")] +impl Page { pub async fn add_runtime_binding_async( &mut self, name: &str, @@ -1156,7 +1145,6 @@ impl Page { .await } - #[cfg(feature = "devtools")] pub async fn add_runtime_binding_for_inspector_session_async( &mut self, inspector_session_id: Option, @@ -1174,7 +1162,6 @@ impl Page { .await } - #[cfg(feature = "devtools")] pub async fn install_runtime_binding_async( &mut self, name: &str, @@ -1190,7 +1177,6 @@ impl Page { .await } - #[cfg(feature = "devtools")] pub fn start_install_runtime_binding( &self, name: &str, @@ -1204,26 +1190,22 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub async fn remove_runtime_binding_async(&mut self, name: &str) -> Result<()> { let command = RendererPageCommand::RemoveRuntimeBinding(name.to_owned()); self.dispatch_unit_page_command_async(command, "remove runtime binding") .await } - #[cfg(feature = "devtools")] pub fn start_remove_runtime_binding(&self, name: &str) -> Result { self.start_page_command(RendererPageCommand::RemoveRuntimeBinding(name.to_owned())) } - #[cfg(feature = "devtools")] pub async fn remove_default_runtime_binding_async(&mut self, name: &str) -> Result<()> { let command = RendererPageCommand::RemoveDefaultRuntimeBinding(name.to_owned()); self.dispatch_unit_page_command_async(command, "remove default runtime binding") .await } - #[cfg(feature = "devtools")] pub async fn restore_runtime_protocol_state_async( &mut self, inspector_session_id: Option, @@ -1257,7 +1239,6 @@ impl Page { Ok(predecessor) } - #[cfg(feature = "devtools")] pub async fn apply_runtime_protocol_state_async( &mut self, isolated_worlds: &[RuntimeIsolatedWorldDefinition], @@ -1273,7 +1254,6 @@ impl Page { .await } - #[cfg(feature = "devtools")] pub async fn apply_runtime_protocol_state_for_inspector_session_async( &mut self, inspector_session_id: Option, @@ -1303,7 +1283,6 @@ impl Page { Ok(predecessor) } - #[cfg(feature = "devtools")] async fn runtime_enable_concrete_output_for_inspector_session_async( &mut self, inspector_session_id: Option<&str>, @@ -1322,7 +1301,9 @@ impl Page { )?; Ok(predecessor) } +} +impl Page { pub async fn run_page_surface_override_script_async(&mut self, source: &str) -> Result<()> { self.dispatch_unit_page_command_async( RendererPageCommand::RunPageSurfaceOverrideScript { @@ -1354,8 +1335,10 @@ impl Page { }; Ok((*result, output)) } +} - #[cfg(feature = "devtools")] +#[cfg(feature = "devtools")] +impl Page { pub async fn add_document_start_script_runtime_activity_async( &mut self, inspector_session_id: Option<&str>, @@ -1371,7 +1354,6 @@ impl Page { self.finish_document_start_script_result(pending.wait().await?) } - #[cfg(feature = "devtools")] pub fn start_add_document_start_script_runtime_activity( &self, inspector_session_id: Option<&str>, @@ -1385,7 +1367,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub async fn remove_document_start_script_by_registry_key_async( &mut self, registry_key: &str, @@ -1397,7 +1378,6 @@ impl Page { .await } - #[cfg(feature = "devtools")] pub fn start_remove_document_start_script_by_registry_key( &self, registry_key: &str, @@ -1407,7 +1387,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub async fn set_runtime_binding_state_async( &mut self, inspector_session_id: Option, @@ -1425,7 +1404,6 @@ impl Page { .await } - #[cfg(feature = "devtools")] pub fn start_set_runtime_binding_state( &self, inspector_session_id: Option, @@ -1438,7 +1416,9 @@ impl Page { session_runtime_bindings: session_runtime_bindings.to_vec(), }) } +} +impl Page { pub fn finish_unit_runtime_page_command( &mut self, completion: CompletedPageCommand, diff --git a/moli-core/src/page/renderer_command_support.rs b/moli-core/src/page/renderer_command_support.rs index 56100c67d87..6abe6b3de16 100644 --- a/moli-core/src/page/renderer_command_support.rs +++ b/moli-core/src/page/renderer_command_support.rs @@ -283,8 +283,10 @@ impl Page { "set inline stylesheet text page command", ) } +} - #[cfg(feature = "devtools")] +#[cfg(feature = "devtools")] +impl Page { pub fn start_style_sheet_payload_for_style_sheet_id( &self, style_sheet_id: &str, @@ -295,7 +297,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_style_sheet_payload_for_style_sheet_id_and_inspector_session( &self, inspector_session_id: Option, @@ -307,7 +308,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_style_sheet_payload( &mut self, completion: CompletedPageCommand, @@ -321,12 +321,10 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_style_sheet_inventory_for_document(&self) -> Result { self.start_style_sheet_inventory_for_document_and_inspector_session(None) } - #[cfg(feature = "devtools")] pub fn start_style_sheet_inventory_for_document_and_inspector_session( &self, inspector_session_id: Option, @@ -336,7 +334,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_style_sheet_inventory_for_document( &mut self, completion: CompletedPageCommand, @@ -350,7 +347,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_reset_css_agent_session( &self, inspector_session_id: Option, @@ -359,7 +355,9 @@ impl Page { inspector_session_id, }) } +} +impl Page { pub fn finish_reset_css_agent_session( &mut self, completion: CompletedPageCommand, @@ -421,8 +419,10 @@ impl Page { pub fn document_title(&self) -> String { self.page_state.document_title().to_owned() } +} - #[cfg(feature = "devtools")] +#[cfg(feature = "devtools")] +impl Page { pub fn start_node_has_geometry_for_object_id_in_inspector_session( &self, inspector_session_id: Option, @@ -434,7 +434,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn start_scroll_node_into_view_if_needed_for_object_id_in_inspector_session( &self, inspector_session_id: Option, @@ -448,7 +447,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn start_scroll_node_into_view_if_needed( &self, reference: RendererDomNodeReference, @@ -457,7 +455,6 @@ impl Page { self.start_page_command(RendererPageCommand::ScrollNodeIntoViewIfNeeded { reference, rect }) } - #[cfg(feature = "devtools")] pub fn start_scroll_backend_node_into_view_if_needed( &self, backend_node_id: u32, @@ -469,7 +466,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn finish_node_has_geometry_for_object_id( &mut self, completion: CompletedPageCommand, @@ -483,7 +479,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_node_has_geometry_for_backend_node_id( &self, backend_node_id: u32, @@ -493,7 +488,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_node_has_geometry_for_backend_node_id( &mut self, completion: CompletedPageCommand, @@ -507,7 +501,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn finish_scroll_node_into_view_if_needed( &mut self, completion: CompletedPageCommand, @@ -521,7 +514,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_client_rect_for_object_id_in_inspector_session( &self, inspector_session_id: Option, @@ -533,7 +525,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn finish_client_rect_for_object_id( &mut self, completion: CompletedPageCommand, @@ -557,7 +548,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_client_rect_for_backend_node_id( &self, backend_node_id: u32, @@ -565,7 +555,6 @@ impl Page { self.start_page_command(RendererPageCommand::ClientRectForBackendNodeId { backend_node_id }) } - #[cfg(feature = "devtools")] pub fn finish_client_rect_for_backend_node_id( &mut self, completion: CompletedPageCommand, @@ -589,7 +578,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_geometry_for_object_id_in_inspector_session( &self, inspector_session_id: Option, @@ -601,7 +589,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn finish_document_geometry_for_object_id( &mut self, completion: CompletedPageCommand, @@ -609,7 +596,6 @@ impl Page { self.finish_document_geometry(completion, "document geometry object id page command") } - #[cfg(feature = "devtools")] pub fn start_document_geometry_for_node( &self, reference: RendererDomNodeReference, @@ -617,7 +603,6 @@ impl Page { self.start_page_command(RendererPageCommand::DocumentGeometryForNode { reference }) } - #[cfg(feature = "devtools")] pub fn start_document_geometry_for_backend_node_id( &self, backend_node_id: u32, @@ -627,7 +612,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn finish_document_geometry_for_backend_node_id( &mut self, completion: CompletedPageCommand, @@ -635,7 +619,6 @@ impl Page { self.finish_document_geometry_for_node(completion) } - #[cfg(feature = "devtools")] pub fn finish_document_geometry_for_node( &mut self, completion: CompletedPageCommand, @@ -643,7 +626,6 @@ impl Page { self.finish_document_geometry(completion, "document geometry node page command") } - #[cfg(feature = "devtools")] fn finish_document_geometry( &mut self, completion: CompletedPageCommand, @@ -658,7 +640,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_hit_test( &self, inspector_session_id: Option, @@ -676,7 +657,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_document_hit_test( &mut self, completion: CompletedPageCommand, @@ -690,7 +670,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_remove_document_node( &self, reference: RendererDomNodeReference, @@ -698,7 +677,6 @@ impl Page { self.start_page_command(RendererPageCommand::RemoveDocumentNode { reference }) } - #[cfg(feature = "devtools")] pub fn start_remove_document_backend_node_id( &self, backend_node_id: u32, @@ -706,7 +684,6 @@ impl Page { self.start_remove_document_node(RendererDomNodeReference::BackendNodeId(backend_node_id)) } - #[cfg(feature = "devtools")] pub fn finish_remove_document_node( &mut self, completion: CompletedPageCommand, @@ -715,7 +692,6 @@ impl Page { .map(|removed| removed.unwrap_or(false)) } - #[cfg(feature = "devtools")] pub fn finish_remove_document_node_reference( &mut self, completion: CompletedPageCommand, @@ -729,7 +705,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_mutate_document_node_attribute( &self, reference: RendererDomNodeReference, @@ -741,7 +716,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn start_mutate_document_backend_node_attribute( &self, backend_node_id: u32, @@ -753,7 +727,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn finish_mutate_document_node_attribute( &mut self, completion: CompletedPageCommand, @@ -767,7 +740,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_edit_document_node( &self, inspector_session_id: Option, @@ -779,7 +751,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_edit_document_node( &mut self, completion: CompletedPageCommand, @@ -793,7 +764,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_focus_document_node( &self, reference: RendererDomNodeReference, @@ -801,7 +771,6 @@ impl Page { self.start_page_command(RendererPageCommand::FocusDocumentNode { reference }) } - #[cfg(feature = "devtools")] pub fn start_focus_document_backend_node_id( &self, backend_node_id: u32, @@ -809,7 +778,6 @@ impl Page { self.start_focus_document_node(RendererDomNodeReference::BackendNodeId(backend_node_id)) } - #[cfg(feature = "devtools")] pub fn finish_focus_document_node_id( &mut self, completion: CompletedPageCommand, @@ -823,7 +791,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_focus_document_node_for_object_id( &self, inspector_session_id: Option, @@ -835,7 +802,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn start_autofill_trigger( &self, request: RendererAutofillTriggerRequest, @@ -843,7 +809,6 @@ impl Page { self.start_page_command(RendererPageCommand::TriggerAutofill(request)) } - #[cfg(feature = "devtools")] pub fn finish_autofill_trigger( &mut self, completion: CompletedPageCommand, @@ -857,7 +822,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_set_file_input_files_for_backend_node_id( &self, backend_node_id: u32, @@ -871,7 +835,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_set_file_input_files( &mut self, completion: CompletedPageCommand, @@ -885,7 +848,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_set_file_input_files_for_object_id_in_inspector_session( &self, inspector_session_id: Option, @@ -901,7 +863,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn finish_set_file_input_files_for_object_id( &mut self, completion: CompletedPageCommand, @@ -915,7 +876,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_node_snapshot_for_object_id_in_inspector_session( &self, inspector_session_id: Option, @@ -935,7 +895,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn start_request_document_node_for_object_id( &self, inspector_session_id: Option, @@ -948,7 +907,9 @@ impl Page { object_id, )) } +} +impl Page { pub fn finish_request_document_node_for_object_id( &mut self, completion: CompletedPageCommand, @@ -1187,8 +1148,10 @@ impl Page { RendererPageReply::OptionalDocumentChildNodeSnapshotEvents(events) => Ok(events), ) } +} - #[cfg(feature = "devtools")] +#[cfg(feature = "devtools")] +impl Page { pub fn start_document_query_selector_for_document( &self, selector: String, @@ -1199,7 +1162,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_query_selector_for_document_in_inspector_session( &self, inspector_session_id: Option, @@ -1215,7 +1177,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn start_document_query_selector_for_backend_node_id( &self, root_backend_node_id: u32, @@ -1231,7 +1192,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_query_selector_for_node_in_inspector_session( &self, inspector_session_id: Option, @@ -1249,7 +1209,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn start_document_query_selector_for_backend_node_id_in_inspector_session( &self, inspector_session_id: Option, @@ -1267,7 +1226,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_child_frame_document_query_selector_for_node( &self, inspector_session_id: Option, @@ -1289,7 +1247,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_child_frame_document_query_selector_for_backend_node_id( &self, inspector_session_id: Option, @@ -1309,7 +1266,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn finish_document_query_selector( &mut self, completion: CompletedPageCommand, @@ -1323,7 +1279,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_query_selector_with_child_node_snapshot_events_for_node( &self, inspector_session_id: Option, @@ -1343,7 +1298,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_query_selector_with_child_node_snapshot_events_for_backend_node_id( &self, inspector_session_id: Option, @@ -1361,7 +1315,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn finish_document_query_selector_with_child_node_snapshot_events( &mut self, completion: CompletedPageCommand, @@ -1375,7 +1328,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_perform_search( &self, inspector_session_id: Option, @@ -1391,7 +1343,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_document_perform_search( &mut self, completion: CompletedPageCommand, @@ -1405,7 +1356,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_search_results( &self, inspector_session_id: Option, @@ -1421,7 +1371,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_document_search_results( &mut self, completion: CompletedPageCommand, @@ -1440,7 +1389,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_discard_document_search_results( &self, inspector_session_id: Option, @@ -1452,7 +1400,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_discard_document_search_results( &mut self, completion: CompletedPageCommand, @@ -1466,7 +1413,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_set_document_node_stack_traces_enabled( &self, inspector_session_id: Option, @@ -1478,7 +1424,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_set_document_node_stack_traces_enabled( &mut self, completion: CompletedPageCommand, @@ -1492,7 +1437,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_node_stack_trace( &self, inspector_session_id: Option, @@ -1504,7 +1448,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_document_node_stack_trace( &mut self, completion: CompletedPageCommand, @@ -1518,7 +1461,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_frontend_node_binding( &self, inspector_session_id: Option, @@ -1533,7 +1475,6 @@ impl Page { } /// Resolve an internal automation binding without treating it as a CDP input. - #[cfg(feature = "devtools")] pub fn start_document_internal_frontend_node_binding( &self, inspector_session_id: Option, @@ -1547,7 +1488,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_document_frontend_node_binding( &mut self, completion: CompletedPageCommand, @@ -1561,7 +1501,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_register_document_bidi_node_binding( &self, inspector_session_id: Option, @@ -1575,7 +1514,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_register_document_bidi_node_binding( &mut self, completion: CompletedPageCommand, @@ -1589,7 +1527,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_bidi_node_binding( &self, inspector_session_id: Option, @@ -1601,7 +1538,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn finish_document_bidi_node_binding( &mut self, completion: CompletedPageCommand, @@ -1615,7 +1551,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_bidi_node_shared_id_for_backend_node_id( &self, inspector_session_id: Option, @@ -1629,7 +1564,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn finish_document_bidi_node_shared_id_for_backend_node_id( &mut self, completion: CompletedPageCommand, @@ -1644,7 +1578,6 @@ impl Page { } /// Resolve the native reference and read attributes in one renderer turn. - #[cfg(feature = "devtools")] pub fn start_document_node_attributes( &self, reference: RendererDomNodeReference, @@ -1652,7 +1585,6 @@ impl Page { self.start_page_command(RendererPageCommand::DocumentNodeAttributes { reference }) } - #[cfg(feature = "devtools")] pub fn start_document_node_attributes_for_backend_node_id( &self, backend_node_id: u32, @@ -1662,7 +1594,6 @@ impl Page { )) } - #[cfg(feature = "devtools")] pub fn finish_document_node_attributes( &mut self, completion: CompletedPageCommand, @@ -1676,7 +1607,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_node_text( &self, reference: RendererDomNodeReference, @@ -1684,7 +1614,6 @@ impl Page { self.start_page_command(RendererPageCommand::DocumentNodeText { reference }) } - #[cfg(feature = "devtools")] pub fn start_document_node_text_for_backend_node_id( &self, backend_node_id: u32, @@ -1692,7 +1621,6 @@ impl Page { self.start_document_node_text(RendererDomNodeReference::BackendNodeId(backend_node_id)) } - #[cfg(feature = "devtools")] pub fn finish_document_node_text( &mut self, completion: CompletedPageCommand, @@ -1706,7 +1634,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn start_document_node_property( &self, reference: RendererDomNodeReference, @@ -1718,7 +1645,6 @@ impl Page { }) } - #[cfg(feature = "devtools")] pub fn start_document_node_property_for_backend_node_id( &self, backend_node_id: u32, @@ -1730,7 +1656,6 @@ impl Page { ) } - #[cfg(feature = "devtools")] pub fn finish_document_node_property( &mut self, completion: CompletedPageCommand, @@ -1743,7 +1668,9 @@ impl Page { RendererPageReply::DocumentNodePropertyResolution(resolution) => Ok(resolution), ) } +} +impl Page { pub fn start_outer_html_for_document( &self, include_shadow_dom: bool, diff --git a/moli-core/src/runtime/navigation_engine.rs b/moli-core/src/runtime/navigation_engine.rs index dde80b6e8ba..bd6469faa33 100644 --- a/moli-core/src/runtime/navigation_engine.rs +++ b/moli-core/src/runtime/navigation_engine.rs @@ -54,9 +54,20 @@ struct DocumentPageLoadOptions { pub viewport_surface: Option, pub network_offline: bool, pub blocked_url_patterns: Vec, + /// Requested Fetch interception classes when DevTools is enabled. pub fetch_subresource_interception_classes: SubresourceInterceptionClasses, } +fn renderer_interception_classes( + classes: SubresourceInterceptionClasses, +) -> SubresourceInterceptionClasses { + if cfg!(feature = "devtools") { + classes + } else { + SubresourceInterceptionClasses::NONE + } +} + /// Explicit resource authority source for a newly committed top-level Document. /// /// A real network navigation must carry the seed minted by its @@ -235,6 +246,7 @@ pub struct PreparedDocumentPageCommitConfiguration { pub bypass_service_worker: bool, pub cache_disabled: bool, pub blocked_url_patterns: Vec, + #[cfg(feature = "devtools")] pub fetch_subresource_interception: SubresourceInterceptionClasses, } @@ -258,7 +270,10 @@ impl PreparedDocumentPageCommitConfiguration { bypass_service_worker: self.bypass_service_worker, cache_disabled: self.cache_disabled, blocked_url_patterns: self.blocked_url_patterns, + #[cfg(feature = "devtools")] fetch_subresource_interception_classes: self.fetch_subresource_interception, + #[cfg(not(feature = "devtools"))] + fetch_subresource_interception_classes: SubresourceInterceptionClasses::NONE, } } } @@ -945,6 +960,7 @@ impl NavigationEngine { self.page_network_policy.set_blocked_url_patterns(patterns); } + #[cfg(feature = "devtools")] pub fn set_subresource_interception( &mut self, classes: crate::page::SubresourceInterceptionClasses, @@ -1748,7 +1764,9 @@ impl NavigationEngine { }, network_offline, blocked_url_patterns, - fetch_subresource_interception_classes, + fetch_subresource_interception_classes: renderer_interception_classes( + fetch_subresource_interception_classes, + ), runtime_inspector_session_restore_snapshots, root_frame_id, main_document_commit, @@ -1904,7 +1922,9 @@ impl NavigationEngine { }, network_offline, blocked_url_patterns, - fetch_subresource_interception_classes, + fetch_subresource_interception_classes: renderer_interception_classes( + fetch_subresource_interception_classes, + ), runtime_inspector_session_restore_snapshots, root_frame_id, main_document_commit, @@ -2039,8 +2059,9 @@ impl NavigationEngine { }, network_offline: options.network_offline, blocked_url_patterns: options.blocked_url_patterns, - fetch_subresource_interception_classes: options - .fetch_subresource_interception_classes, + fetch_subresource_interception_classes: renderer_interception_classes( + options.fetch_subresource_interception_classes, + ), runtime_inspector_session_restore_snapshots: options .runtime_inspector_session_restore_snapshots, root_frame_id: options.root_frame_id, diff --git a/moli-renderer-v8/src/context_bootstrap/file_api/data_transfer.rs b/moli-renderer-v8/src/context_bootstrap/file_api/data_transfer.rs index 012c468330c..631a047a255 100644 --- a/moli-renderer-v8/src/context_bootstrap/file_api/data_transfer.rs +++ b/moli-renderer-v8/src/context_bootstrap/file_api/data_transfer.rs @@ -2130,6 +2130,7 @@ mod tests { }); } + #[cfg(feature = "devtools")] #[test] fn event_views_share_records_without_reviving_closed_view_permissions() { with_transfer_scope(|scope| { diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime.rs index 51838b9f2a7..07d4f7190c5 100644 --- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime.rs +++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime.rs @@ -25,7 +25,7 @@ pub(in crate::context_bootstrap) use self::navigator::{ STORAGE_BUCKET_MANAGER_POPUP_ID_SLOT, STORAGE_MANAGER_CHILD_HANDLE_SLOT, STORAGE_MANAGER_POPUP_ID_SLOT, build_storage_manager_worker_template, current_protocol_user_gesture_activation, finalize_navigator_credentials_realm_bindings, - install_storage_manager_constructor_template_bindings, service_worker_container_for_window, + install_storage_manager_constructor_template_bindings, service_worker_container_for_client, service_worker_owner_token_value, }; #[cfg(test)] diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs index d22c2d001c0..bd99bd13641 100644 --- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs +++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs @@ -1646,22 +1646,26 @@ fn navigator_runtime_data_object<'s>( .and_then(|value| v8::Local::::try_from(value).ok()) } -pub(in crate::context_bootstrap) fn service_worker_container_for_window<'s>( +pub(in crate::context_bootstrap) fn service_worker_container_for_client<'s>( scope: &mut v8::PinScope<'s, '_>, - window: v8::Local<'s, v8::Object>, + client: v8::Local<'s, v8::Object>, ) -> Option> { - // Native notifications address the Window's associated container. Neither - // Window.navigator nor Navigator.serviceWorker invokes author code here. - let navigator = get_private_value(scope, window, WINDOW_NAVIGATOR_SLOT) - .and_then(|value| v8::Local::::try_from(value).ok()) - .or_else(|| { - super::super::window_lazy_surface::ensure_window_lazy_surface_object( - scope, - window, - super::super::window_lazy_surface::WindowLazySurface::Navigator, - ) - .ok() - })?; + // Native notifications resolve the client container through its realm's + // navigator backing without invoking author-defined getters. + let navigator = if get_private_value(scope, client, WORKER_NAVIGATOR_INSTALLED_SLOT).is_some() { + ensure_worker_navigator_in_current_realm(scope).ok()? + } else { + get_private_value(scope, client, WINDOW_NAVIGATOR_SLOT) + .and_then(|value| v8::Local::::try_from(value).ok()) + .or_else(|| { + super::super::window_lazy_surface::ensure_window_lazy_surface_object( + scope, + client, + super::super::window_lazy_surface::WindowLazySurface::Navigator, + ) + .ok() + })? + }; let backing = navigator_runtime_data_object(scope, navigator)?; ensure_navigator_subobject(scope, backing, NavigatorSubobject::ServiceWorker) .ok() diff --git a/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs b/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs index 9a1138957f3..f89e0ca1678 100644 --- a/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs +++ b/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs @@ -1,6 +1,6 @@ use super::*; use crate::context_bootstrap::navigator_runtime::{ - SERVICE_WORKER_OWNER_TOKEN_SLOT, service_worker_container_for_window, + SERVICE_WORKER_OWNER_TOKEN_SLOT, service_worker_container_for_client, service_worker_owner_token_value, }; use crate::document_runtime::DomHandle; @@ -810,7 +810,7 @@ fn service_worker_container_for_owner<'s>( scope: &mut v8::PinScope<'s, '_>, owner: crate::native_bridge::OwnerDispatchScope, ) -> Option> { - let window = match owner { + let client = match owner { crate::native_bridge::OwnerDispatchScope::Top => scope.get_current_context().global(scope), crate::native_bridge::OwnerDispatchScope::Child(handle) => { let host_ptr = context_host_ptr_from_global_bridge(scope)?; @@ -821,14 +821,7 @@ fn service_worker_container_for_owner<'s>( unsafe { &*host_ptr }.lightweight_popup_window(scope, popup_id)? } }; - service_worker_container_from_window(scope, window) -} - -fn service_worker_container_from_window<'s>( - scope: &mut v8::PinScope<'s, '_>, - window: v8::Local<'s, v8::Object>, -) -> Option> { - service_worker_container_for_window(scope, window) + service_worker_container_for_client(scope, client) } fn service_worker_container_registration_cache<'s>( diff --git a/moli-renderer-v8/src/devtools/ingress/io.rs b/moli-renderer-v8/src/devtools/ingress/io.rs index 71f5a5d254d..4f13e02d76c 100644 --- a/moli-renderer-v8/src/devtools/ingress/io.rs +++ b/moli-renderer-v8/src/devtools/ingress/io.rs @@ -884,6 +884,19 @@ fn fail_io_command(mut command: RendererInspectorIoCommand, message: &str) { } #[cfg(test)] +#[test] +fn closed_isolate_discards_queued_and_late_environment_notifications() { + let pause_bridge = crate::devtools::pause::RendererInspectorPauseBridge::default(); + let ingress = RendererInspectorIoIngress::new(pause_bridge.pause_loop_wake(), None); + let notifier = ingress.environment_notifier(); + notifier.notify(ProcessEnvironmentInvalidation::LocaleAndDateTime); + ingress.close("isolate disposed"); + notifier.notify(ProcessEnvironmentInvalidation::DateTime); + assert_eq!(ingress.claim_environment_invalidation(), None); + assert!(!ingress.shared.state.lock().has_ready()); +} + +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; use crate::devtools::pause::RendererInspectorPauseBridge; @@ -893,7 +906,6 @@ mod tests { RendererRuntimeInspectorResponseChannel, RendererTurnOutputJournal, renderer_output_transport_channel, }; - #[cfg(feature = "devtools")] use crate::runtime::{RendererInspectorCommandEnvelope, RendererInspectorIngressTicket}; fn ingress() -> RendererInspectorIoIngress { @@ -901,7 +913,6 @@ mod tests { RendererInspectorIoIngress::new(pause_bridge.pause_loop_wake(), None) } - #[cfg(feature = "devtools")] fn enqueue( ingress: &RendererInspectorIoIngress, agent_token: RendererDevToolsAgentToken, @@ -922,7 +933,6 @@ mod tests { ) } - #[cfg(feature = "devtools")] fn io_ticket(session: &str) -> RendererInspectorIngressTicket { RendererInspectorIngressTicket::new( None, @@ -956,17 +966,6 @@ mod tests { ingress.finish_session_detach(agent, command.ticket().session()); } - #[test] - fn closed_isolate_discards_queued_and_late_environment_notifications() { - let ingress = ingress(); - let notifier = ingress.environment_notifier(); - notifier.notify(ProcessEnvironmentInvalidation::LocaleAndDateTime); - ingress.close("isolate disposed"); - notifier.notify(ProcessEnvironmentInvalidation::DateTime); - assert_eq!(ingress.claim_environment_invalidation(), None); - assert!(!ingress.shared.state.lock().has_ready()); - } - fn session_response_output( call_id: i32, result: serde_json::Value, diff --git a/moli-renderer-v8/src/devtools/pause/mod.rs b/moli-renderer-v8/src/devtools/pause/mod.rs index a4f341ef816..44761acb0ce 100644 --- a/moli-renderer-v8/src/devtools/pause/mod.rs +++ b/moli-renderer-v8/src/devtools/pause/mod.rs @@ -11,7 +11,7 @@ use moli_page_types::V8InspectorSessionState; use moli_page_types::{DevToolsSessionKey, RendererDevToolsAgentToken}; use parking_lot::{Condvar, Mutex}; use serde_json::Value; -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] use serde_json::json; use crate::devtools::target::RendererDevToolsTargetHandle; @@ -19,7 +19,7 @@ use crate::devtools::target::RendererDevToolsTargetHandle; use crate::runtime::RendererInspectorIngressTicket; #[cfg(feature = "devtools")] use crate::runtime::RendererInspectorPauseCommandEffect; -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] use crate::runtime::RendererRuntimeInspectorResponseSender; use crate::runtime::{ PageId, RendererOutputResidenceIdentity, RendererRuntimeCommandCausalIdentity, @@ -691,5 +691,5 @@ impl Drop for RendererInspectorPauseCommandDispatchGuard { } } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests; diff --git a/moli-renderer-v8/src/devtools/target.rs b/moli-renderer-v8/src/devtools/target.rs index aa6705647ae..116eba99f9c 100644 --- a/moli-renderer-v8/src/devtools/target.rs +++ b/moli-renderer-v8/src/devtools/target.rs @@ -205,18 +205,15 @@ impl std::fmt::Debug for RendererDevToolsTargetHandle { } } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; - #[cfg(feature = "devtools")] use crate::devtools::command::{ RendererDevToolsIoCommandEnvelope, RendererInspectorCommandEnvelope, RendererInspectorCommandRoute, RendererInspectorIngressTicket, }; use crate::devtools::ingress::io::RendererInspectorIoIngress; - #[cfg(feature = "devtools")] use crate::devtools::ingress::io::RendererRuntimeInspectorIoCommandClaim; - #[cfg(feature = "devtools")] use crate::devtools::ingress::main::{ RendererInspectorMainIngress, RendererRuntimeInspectorMainCommandCompletion, }; diff --git a/moli-renderer-v8/src/document_runtime/devtools_mutations.rs b/moli-renderer-v8/src/document_runtime/devtools_mutations.rs index 21cd4528d85..8d6ca39f16f 100644 --- a/moli-renderer-v8/src/document_runtime/devtools_mutations.rs +++ b/moli-renderer-v8/src/document_runtime/devtools_mutations.rs @@ -250,7 +250,7 @@ fn collect_light_tree_subtree_handles(dom_host: &DomHost, root: DomHandle) -> Ve handles } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; diff --git a/moli-renderer-v8/src/native_bridge/context_host/host_environment.rs b/moli-renderer-v8/src/native_bridge/context_host/host_environment.rs index 3f64893e0d8..7a169f9b818 100644 --- a/moli-renderer-v8/src/native_bridge/context_host/host_environment.rs +++ b/moli-renderer-v8/src/native_bridge/context_host/host_environment.rs @@ -2753,6 +2753,7 @@ impl PageScriptHost { .any(|pattern| moli_fetch::url_pattern_matches(pattern, value)) } + #[cfg(any(test, feature = "devtools"))] pub(crate) fn set_fetch_subresource_interception( &mut self, classes: SubresourceInterceptionClasses, diff --git a/moli-renderer-v8/src/native_bridge/context_host/visual_resource_generation.rs b/moli-renderer-v8/src/native_bridge/context_host/visual_resource_generation.rs index fe09180ce1e..aadf2182288 100644 --- a/moli-renderer-v8/src/native_bridge/context_host/visual_resource_generation.rs +++ b/moli-renderer-v8/src/native_bridge/context_host/visual_resource_generation.rs @@ -12,7 +12,7 @@ use std::sync::{ pub(crate) struct VisualResourceGeneration(Arc); impl VisualResourceGeneration { - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] pub(crate) fn current(&self) -> u64 { self.0.load(Ordering::Acquire) } diff --git a/moli-renderer-v8/src/native_bridge/current_input.rs b/moli-renderer-v8/src/native_bridge/current_input.rs index bf2335a3960..a44a0e0d173 100644 --- a/moli-renderer-v8/src/native_bridge/current_input.rs +++ b/moli-renderer-v8/src/native_bridge/current_input.rs @@ -259,6 +259,7 @@ mod tests { ); } + #[cfg(feature = "devtools")] #[test] fn only_navigation_capable_real_input_supplies_an_input_policy() { assert_eq!( diff --git a/moli-renderer-v8/src/native_bridge/element.rs b/moli-renderer-v8/src/native_bridge/element.rs index 9b27f386663..69aafaceda7 100644 --- a/moli-renderer-v8/src/native_bridge/element.rs +++ b/moli-renderer-v8/src/native_bridge/element.rs @@ -297,6 +297,8 @@ use event_handlers::{ }; pub(in crate::native_bridge::element) use events::construct_event; pub(crate) use events::construct_focus_event; +#[cfg(any(test, feature = "devtools"))] +pub(crate) use events::construct_keyboard_event; use events::{ClickEventSource, construct_click_event}; pub(crate) use events::{ InputEventCoordinates, NodePublicEventDispatchOutcome, TextEditInputType, @@ -315,9 +317,7 @@ pub(crate) use events::{ construct_pointer_event_with_related_target_and_modifiers, construct_wheel_event_for_target, }; #[cfg(feature = "devtools")] -pub(crate) use events::{ - construct_keyboard_event, construct_pointer_event, construct_pointer_event_with_related_target, -}; +pub(crate) use events::{construct_pointer_event, construct_pointer_event_with_related_target}; #[cfg(feature = "devtools")] pub(crate) use focus::focus_live_element_for_inspector; pub(crate) use focus::is_disabled_form_control; diff --git a/moli-renderer-v8/src/native_bridge/element/events.rs b/moli-renderer-v8/src/native_bridge/element/events.rs index 576ab584d68..e4ad57d47f7 100644 --- a/moli-renderer-v8/src/native_bridge/element/events.rs +++ b/moli-renderer-v8/src/native_bridge/element/events.rs @@ -4,6 +4,8 @@ mod constructors; mod dispatch; pub(crate) use self::constructors::construct_focus_event; +#[cfg(any(test, feature = "devtools"))] +pub(crate) use self::constructors::construct_keyboard_event; pub(super) use self::constructors::{ClickEventSource, construct_click_event}; pub(crate) use self::constructors::{ InputEventCoordinates, TextEditInputType, construct_command_event, construct_drop_input_event, @@ -22,7 +24,7 @@ pub(crate) use self::constructors::{ }; #[cfg(feature = "devtools")] pub(crate) use self::constructors::{ - construct_keyboard_event, construct_pointer_event, construct_pointer_event_with_related_target, + construct_pointer_event, construct_pointer_event_with_related_target, construct_text_input_event_for_target, }; pub(crate) use self::dispatch::{ diff --git a/moli-renderer-v8/src/native_bridge/element/events/constructors.rs b/moli-renderer-v8/src/native_bridge/element/events/constructors.rs index a527ccebcbd..c16b79aaa11 100644 --- a/moli-renderer-v8/src/native_bridge/element/events/constructors.rs +++ b/moli-renderer-v8/src/native_bridge/element/events/constructors.rs @@ -175,7 +175,7 @@ impl TextEditInputType { } } -#[cfg(feature = "devtools")] +#[cfg(any(test, feature = "devtools"))] fn keyboard_event_legacy_codes(event_type: &str, key: &str, code: &str) -> (u32, u32, u32) { let char_code = keyboard_event_char_code(event_type, key); let mut key_code = keyboard_event_key_code(key, code); @@ -190,7 +190,7 @@ fn keyboard_event_legacy_codes(event_type: &str, key: &str, code: &str) -> (u32, (char_code, key_code, which) } -#[cfg(feature = "devtools")] +#[cfg(any(test, feature = "devtools"))] fn keyboard_event_char_code(event_type: &str, key: &str) -> u32 { if event_type != "keypress" { return 0; @@ -208,7 +208,7 @@ fn keyboard_event_char_code(event_type: &str, key: &str) -> u32 { ch as u32 } -#[cfg(feature = "devtools")] +#[cfg(any(test, feature = "devtools"))] fn keyboard_event_key_code(key: &str, code: &str) -> u32 { match key { "Backspace" => 8, @@ -243,7 +243,7 @@ fn keyboard_event_key_code(key: &str, code: &str) -> u32 { } } -#[cfg(feature = "devtools")] +#[cfg(any(test, feature = "devtools"))] fn keyboard_event_key_code_for_code(code: &str) -> Option { if let Some(suffix) = code.strip_prefix("Key") && suffix.len() == 1 @@ -316,7 +316,7 @@ fn keyboard_event_key_code_for_code(code: &str) -> Option { }) } -#[cfg(feature = "devtools")] +#[cfg(any(test, feature = "devtools"))] fn single_ascii_digit(value: &str) -> Option { if value.len() != 1 { return None; @@ -325,7 +325,7 @@ fn single_ascii_digit(value: &str) -> Option { digit.is_ascii_digit().then_some(digit - b'0') } -#[cfg(feature = "devtools")] +#[cfg(any(test, feature = "devtools"))] fn keyboard_event_key_code_for_printable_key(key: &str) -> Option { let mut chars = key.chars(); let ch = chars.next()?; @@ -824,7 +824,7 @@ fn construct_touches<'s>( .collect() } -#[cfg(feature = "devtools")] +#[cfg(any(test, feature = "devtools"))] pub(crate) fn construct_keyboard_event<'s>( scope: &mut v8::PinScope<'s, '_>, event_type: &str, diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation/sizing_tests.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation/sizing_tests.rs index 9da2e0c7625..ce0274c0e03 100644 --- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation/sizing_tests.rs +++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation/sizing_tests.rs @@ -69,6 +69,7 @@ fn computed_size_property_batch_looks_up_one_element_once_without_a_document_ind assert_eq!(host.layout_snapshot_cache_observability_for_test(), before); } +#[cfg(feature = "devtools")] #[test] fn computed_size_inspector_property_batch_shares_one_size_lookup() { let mut vm = fixture("
"); @@ -104,6 +105,7 @@ fn computed_size_inspector_property_batch_shares_one_size_lookup() { ); } +#[cfg(feature = "devtools")] #[test] fn computed_size_dom_snapshot_batches_all_nodes_in_one_observation() { let mut markup = String::new(); diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation/sizing_tests/sampling.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation/sizing_tests/sampling.rs index 039b9797776..5d8fcdccc67 100644 --- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation/sizing_tests/sampling.rs +++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation/sizing_tests/sampling.rs @@ -6,6 +6,7 @@ use std::collections::BTreeMap; const GRID: &str = r#"
"#; +#[cfg(feature = "devtools")] fn inspector_properties(host: &PageScriptHost, target: DomHandle) -> BTreeMap { crate::native_bridge::element::computed_style_properties_for_inspector_handle(host, target) .unwrap() @@ -13,6 +14,7 @@ fn inspector_properties(host: &PageScriptHost, target: DomHandle) -> BTreeMap ResourceInterceptionDecision::CancelAuth, }; - self.sender + self.send_decision(decision).is_ok() + } + + fn send_decision(&self, decision: ResourceInterceptionDecision) -> Result<()> { + let sender = self + .sender .lock() .take() - .is_some_and(|sender| sender.send(decision).is_ok()) + .ok_or_else(|| anyhow!("network pause was already resumed"))?; + sender + .send(decision) + .map_err(|_| anyhow!("network load is no longer waiting")) + } + + #[cfg(test)] + pub(crate) fn send_test_decision( + &self, + internal_id: u64, + phase: InterceptionPhase, + decision: ResourceInterceptionDecision, + ) { + assert_eq!((self.internal_id, self.phase), (internal_id, phase)); + self.send_decision(decision).expect("native test decision"); } /// Releasing an interceptor changes native eligibility immediately. It @@ -167,7 +187,6 @@ impl ResourceInterceptionPause { /// native network command subset is accepted; other Page work stays queued. #[cfg(feature = "devtools")] pub fn dispatch(&self, command: RendererPageCommand) -> Result { - #[cfg(feature = "devtools")] use RendererPageCommand as C; use ResourceInterceptionDecision as D; use ResourceInterceptionReply as R; @@ -281,13 +300,7 @@ impl ResourceInterceptionPause { id == self.internal_id && phase == self.phase, "network pause identity or phase does not match" ); - let tx = self - .sender - .lock() - .take() - .ok_or_else(|| anyhow!("network pause was already resumed"))?; - tx.send(decision) - .map_err(|_| anyhow!("network load is no longer waiting"))?; + self.send_decision(decision)?; Ok(reply) } } diff --git a/moli-renderer-v8/src/network/interception_output/worker.rs b/moli-renderer-v8/src/network/interception_output/worker.rs index c819d335faa..d1c8740a8ac 100644 --- a/moli-renderer-v8/src/network/interception_output/worker.rs +++ b/moli-renderer-v8/src/network/interception_output/worker.rs @@ -205,6 +205,7 @@ impl ResourceInterceptionContext { /// The interception configuration of a Worker target, independent of clients. #[derive(Clone, Debug)] pub struct ResourceInterceptionPolicy(pub(crate) crate::network::PageNetworkPolicy); +#[cfg(feature = "devtools")] impl ResourceInterceptionPolicy { pub fn set_interception(&self, classes: crate::types::SubresourceInterceptionClasses) { self.0.set_subresource_interception(classes); diff --git a/moli-renderer-v8/src/network/policy.rs b/moli-renderer-v8/src/network/policy.rs index e892c865431..58433152a71 100644 --- a/moli-renderer-v8/src/network/policy.rs +++ b/moli-renderer-v8/src/network/policy.rs @@ -95,6 +95,8 @@ impl PageNetworkConditionsState { pub struct PageNetworkPolicy { state: Arc>, network_conditions: Arc>, + // Unit-test fixtures also use native pauses to supply synthetic network responses. + #[cfg(any(test, feature = "devtools"))] subresource_interception: Arc>, } @@ -103,6 +105,7 @@ impl Default for PageNetworkPolicy { Self { state: Arc::new(Mutex::new(PageNetworkPolicyState::default())), network_conditions: Arc::new(Mutex::new(PageNetworkConditionsState::default())), + #[cfg(any(test, feature = "devtools"))] subresource_interception: Arc::default(), } } @@ -123,6 +126,7 @@ impl PageNetworkPolicy { Self { state: Arc::new(Mutex::new(state)), network_conditions: Arc::new(Mutex::new(PageNetworkConditionsState::default())), + #[cfg(any(test, feature = "devtools"))] subresource_interception: Arc::default(), } } @@ -140,12 +144,14 @@ impl PageNetworkPolicy { /// reuse across top-level navigation and protocol interception remain /// owned by the stable Page. pub fn isolated_same_page_copy(&self) -> Self { - let mut copy = Self::from_snapshot_with_memory_cache_partition( - self.snapshot(), - self.memory_cache_partition_id(), - ); - copy.subresource_interception = Arc::clone(&self.subresource_interception); - copy + Self { + #[cfg(any(test, feature = "devtools"))] + subresource_interception: Arc::clone(&self.subresource_interception), + ..Self::from_snapshot_with_memory_cache_partition( + self.snapshot(), + self.memory_cache_partition_id(), + ) + } } pub fn shares_memory_cache_partition_with(&self, other: &Self) -> bool { @@ -177,6 +183,7 @@ impl PageNetworkPolicy { revision: snapshot.network_conditions_revision, offline: snapshot.network_offline, })), + #[cfg(any(test, feature = "devtools"))] subresource_interception: Arc::default(), } } @@ -205,6 +212,7 @@ impl PageNetworkPolicy { cache_disabled: snapshot.cache_disabled, })), network_conditions: Arc::clone(&self.network_conditions), + #[cfg(any(test, feature = "devtools"))] subresource_interception: Arc::clone(&self.subresource_interception), } } @@ -214,12 +222,15 @@ impl PageNetworkPolicy { } pub fn shares_state_with(&self, other: &Self) -> bool { - Arc::ptr_eq(&self.state, &other.state) - && Arc::ptr_eq(&self.network_conditions, &other.network_conditions) + let shares_state = Arc::ptr_eq(&self.state, &other.state) + && Arc::ptr_eq(&self.network_conditions, &other.network_conditions); + #[cfg(any(test, feature = "devtools"))] + let shares_state = shares_state && Arc::ptr_eq( &self.subresource_interception, &other.subresource_interception, - ) + ); + shares_state } /// Captures the current request configuration and network conditions. @@ -271,7 +282,7 @@ impl PageNetworkPolicy { state.advance_revision(); } - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] pub(crate) fn set_browser_identity_override( &self, identity: Option>, @@ -318,12 +329,20 @@ impl PageNetworkPolicy { /// Live target eligibility only. Protocol rules and session ordering stay /// with their canonical protocol owner, rather than being copied to XHR. + #[cfg(any(test, feature = "devtools"))] pub fn set_subresource_interception(&self, classes: SubresourceInterceptionClasses) { *self.subresource_interception.lock() = classes; } pub(crate) fn subresource_interception_config(&self) -> SubresourceInterceptionClasses { - *self.subresource_interception.lock() + #[cfg(any(test, feature = "devtools"))] + { + *self.subresource_interception.lock() + } + #[cfg(not(any(test, feature = "devtools")))] + { + SubresourceInterceptionClasses::NONE + } } pub(crate) fn should_intercept_subresource( @@ -524,6 +543,7 @@ impl PageNetworkPolicySnapshot { mod tests { use super::*; + #[cfg(feature = "devtools")] #[test] fn interception_eligibility_follows_same_target_views_only() { let page = PageNetworkPolicy::default(); diff --git a/moli-renderer-v8/src/render_runtime.rs b/moli-renderer-v8/src/render_runtime.rs index 89fc8790362..316ac12a845 100644 --- a/moli-renderer-v8/src/render_runtime.rs +++ b/moli-renderer-v8/src/render_runtime.rs @@ -310,6 +310,7 @@ mod tests { use super::*; + #[cfg(feature = "devtools")] #[test] fn raw_owner_admission_rejects_inspector_page_commands() { let handle = RenderRuntimeHandle::disconnected(); diff --git a/moli-renderer-v8/src/runtime/browser_context_runtime.rs b/moli-renderer-v8/src/runtime/browser_context_runtime.rs index d64623aad47..f0bcf4a2418 100644 --- a/moli-renderer-v8/src/runtime/browser_context_runtime.rs +++ b/moli-renderer-v8/src/runtime/browser_context_runtime.rs @@ -162,6 +162,7 @@ impl RendererProducerRegistrar { #[derive(Clone, Debug)] pub(crate) struct RendererWorkerContextRuntime { debugger_enabled: bool, + #[cfg(feature = "devtools")] shared_worker_pause_on_start: Arc, message_port_registry: crate::message_port_runtime::SharedMessagePortRegistry, broadcast_channel_registry: crate::broadcast_channel_runtime::SharedBroadcastChannelRegistry, @@ -209,7 +210,9 @@ struct RendererBrowserContextRuntimeInner { next_detached_parser_script_fetch_id: AtomicU64, next_dedicated_worker_instance_id: AtomicU64, dedicated_worker_devtools_targets: Mutex>, + #[cfg(feature = "devtools")] dedicated_worker_pause_on_start_for_devtools: AtomicBool, + #[cfg(feature = "devtools")] shared_worker_pause_on_start_for_devtools: Arc, javascript_dialog_handler_enabled: AtomicBool, browser_owns_auxiliary_document_responses: AtomicBool, @@ -616,7 +619,9 @@ impl RendererBrowserContextRuntime { next_detached_parser_script_fetch_id: AtomicU64::default(), next_dedicated_worker_instance_id: AtomicU64::default(), dedicated_worker_devtools_targets: Mutex::new(HashMap::new()), + #[cfg(feature = "devtools")] dedicated_worker_pause_on_start_for_devtools: AtomicBool::new(false), + #[cfg(feature = "devtools")] shared_worker_pause_on_start_for_devtools: Arc::new(AtomicBool::new(false)), javascript_dialog_handler_enabled: AtomicBool::new(false), browser_owns_auxiliary_document_responses: AtomicBool::new(false), @@ -785,6 +790,7 @@ impl RendererBrowserContextRuntime { pub(crate) fn worker_context_runtime(&self) -> RendererWorkerContextRuntime { RendererWorkerContextRuntime { debugger_enabled: self.inner.debugger_enabled, + #[cfg(feature = "devtools")] shared_worker_pause_on_start: self .inner .shared_worker_pause_on_start_for_devtools @@ -1052,6 +1058,7 @@ impl RendererWorkerContextRuntime { ) -> Self { Self { debugger_enabled, + #[cfg(feature = "devtools")] shared_worker_pause_on_start: Arc::new(AtomicBool::new(false)), message_port_registry, broadcast_channel_registry, @@ -1066,7 +1073,14 @@ impl RendererWorkerContextRuntime { } pub(crate) fn shared_worker_pause_on_start_for_devtools(&self) -> bool { - self.shared_worker_pause_on_start.load(Ordering::Acquire) + #[cfg(feature = "devtools")] + { + self.shared_worker_pause_on_start.load(Ordering::Acquire) + } + #[cfg(not(feature = "devtools"))] + { + false + } } pub(crate) fn debugger_enabled(&self) -> bool { self.debugger_enabled @@ -1184,6 +1198,7 @@ mod tests { let (service_wake_tx, _service_wake_rx) = crate::service_worker_runtime::service_worker_owner_wake_channel(); runtime.add_service_worker_owner_wake_sender(service_wake_tx); + #[cfg(feature = "devtools")] runtime.set_service_worker_pause_on_start_for_devtools(true); assert!(!runtime.ensure_service_worker_runtime_for_navigation()); @@ -1221,7 +1236,10 @@ mod tests { .live_client_count, 1 ); - assert!(runtime.service_worker_pause_on_start_for_devtools()); + assert_eq!( + runtime.service_worker_pause_on_start_for_devtools(), + cfg!(feature = "devtools") + ); } #[test] diff --git a/moli-renderer-v8/src/runtime/browser_context_runtime/dedicated_workers.rs b/moli-renderer-v8/src/runtime/browser_context_runtime/dedicated_workers.rs index 9288fb18922..e4a441e4df6 100644 --- a/moli-renderer-v8/src/runtime/browser_context_runtime/dedicated_workers.rs +++ b/moli-renderer-v8/src/runtime/browser_context_runtime/dedicated_workers.rs @@ -65,11 +65,13 @@ impl RendererBrowserContextRuntime { .remove(&instance_id); } + #[cfg(feature = "devtools")] pub fn set_shared_worker_pause_on_start_for_devtools(&self, pause: bool) { self.inner .shared_worker_pause_on_start_for_devtools .store(pause, std::sync::atomic::Ordering::Release); } + #[cfg(feature = "devtools")] pub fn set_dedicated_worker_pause_on_start_for_devtools(&self, pause: bool) { self.inner .dedicated_worker_pause_on_start_for_devtools @@ -77,9 +79,16 @@ impl RendererBrowserContextRuntime { } pub(crate) fn dedicated_worker_pause_on_start_for_devtools(&self) -> bool { - self.inner - .dedicated_worker_pause_on_start_for_devtools - .load(std::sync::atomic::Ordering::Relaxed) + #[cfg(feature = "devtools")] + { + self.inner + .dedicated_worker_pause_on_start_for_devtools + .load(std::sync::atomic::Ordering::Relaxed) + } + #[cfg(not(feature = "devtools"))] + { + false + } } fn dedicated_worker_devtools_handle(&self, instance_id: u64) -> Option { @@ -266,7 +275,7 @@ impl RendererBrowserContextRuntime { } } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; diff --git a/moli-renderer-v8/src/runtime/document_replacement.rs b/moli-renderer-v8/src/runtime/document_replacement.rs index f0229a284d4..0942e111374 100644 --- a/moli-renderer-v8/src/runtime/document_replacement.rs +++ b/moli-renderer-v8/src/runtime/document_replacement.rs @@ -266,5 +266,5 @@ impl RendererDocumentPreparationTarget { } } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests; diff --git a/moli-renderer-v8/src/runtime/owner.rs b/moli-renderer-v8/src/runtime/owner.rs index b1af2df19ed..bc028739b61 100644 --- a/moli-renderer-v8/src/runtime/owner.rs +++ b/moli-renderer-v8/src/runtime/owner.rs @@ -125,6 +125,7 @@ pub struct RendererPreparedDocumentCommitConfiguration { pub bypass_service_worker: bool, pub cache_disabled: bool, pub blocked_url_patterns: Vec, + /// Applied only when renderer DevTools is enabled. pub fetch_subresource_interception_classes: crate::SubresourceInterceptionClasses, } diff --git a/moli-renderer-v8/src/runtime/owner_local_store/mod.rs b/moli-renderer-v8/src/runtime/owner_local_store/mod.rs index a7dc2104a2c..06935c67211 100644 --- a/moli-renderer-v8/src/runtime/owner_local_store/mod.rs +++ b/moli-renderer-v8/src/runtime/owner_local_store/mod.rs @@ -992,8 +992,11 @@ impl RendererOwnerLocalStore { .loader .set_cache_disabled(configuration.cache_disabled); request.blocked_url_patterns = configuration.blocked_url_patterns; - request.fetch_subresource_interception_classes = - configuration.fetch_subresource_interception_classes; + #[cfg(feature = "devtools")] + { + request.fetch_subresource_interception_classes = + configuration.fetch_subresource_interception_classes; + } }}; } apply_configuration!(&mut residence.request); diff --git a/moli-renderer-v8/src/runtime/page_commands.rs b/moli-renderer-v8/src/runtime/page_commands.rs index 3d2944da545..96705deefd0 100644 --- a/moli-renderer-v8/src/runtime/page_commands.rs +++ b/moli-renderer-v8/src/runtime/page_commands.rs @@ -425,7 +425,7 @@ impl PageVm { self.vm_mut().snapshot_console_messages_with_context()?, )) } - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] RendererPageCommand::RuntimeHeapUsage => { Ok(RendererPageReply::RuntimeHeapUsage(Box::new( self.vm_mut() diff --git a/moli-renderer-v8/src/runtime/page_dom/child_frame_nodes.rs b/moli-renderer-v8/src/runtime/page_dom/child_frame_nodes.rs index 951cd79fc42..023666f75b5 100644 --- a/moli-renderer-v8/src/runtime/page_dom/child_frame_nodes.rs +++ b/moli-renderer-v8/src/runtime/page_dom/child_frame_nodes.rs @@ -35,10 +35,9 @@ pub(super) fn collect_shadow_including_document_handles( handles } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; - #[cfg(feature = "devtools")] use crate::dom::native::DomHost; use crate::dom::native::NativeDom; diff --git a/moli-renderer-v8/src/runtime/page_network.rs b/moli-renderer-v8/src/runtime/page_network.rs index 527fec00574..eef1c771b69 100644 --- a/moli-renderer-v8/src/runtime/page_network.rs +++ b/moli-renderer-v8/src/runtime/page_network.rs @@ -157,6 +157,7 @@ impl PageVm { Ok(false) } + #[cfg(feature = "devtools")] pub(crate) fn set_fetch_subresource_interception( &mut self, classes: crate::SubresourceInterceptionClasses, diff --git a/moli-renderer-v8/src/runtime/page_screenshot.rs b/moli-renderer-v8/src/runtime/page_screenshot.rs index 9a7cac2c660..4d6fcce85d0 100644 --- a/moli-renderer-v8/src/runtime/page_screenshot.rs +++ b/moli-renderer-v8/src/runtime/page_screenshot.rs @@ -238,6 +238,7 @@ impl PageVm { self.capture_screencast_frame_with_before_layout(request, || {}) } + #[cfg(feature = "devtools")] #[cfg(test)] pub(super) fn capture_screencast_frame_with_before_layout_hook( &mut self, diff --git a/moli-renderer-v8/src/runtime/page_surface.rs b/moli-renderer-v8/src/runtime/page_surface.rs index 7fe0e62f3bc..250878e1306 100644 --- a/moli-renderer-v8/src/runtime/page_surface.rs +++ b/moli-renderer-v8/src/runtime/page_surface.rs @@ -3806,6 +3806,7 @@ mod renderer_runtime_inspector_response_channel_tests { .into() } + #[cfg(feature = "devtools")] fn assert_raw_session_sink_settlement(raw: &str, expected_success: bool) { let payload = InspectorJson::from_slice(raw.as_bytes()).unwrap(); assert!(!payload.is_materialized()); @@ -3878,6 +3879,7 @@ mod renderer_runtime_inspector_response_channel_tests { assert_eq!(response.payload().to_string(), raw); } + #[cfg(feature = "devtools")] #[test] fn raw_session_sink_large_success_stays_opaque() { let raw = format!( @@ -3887,6 +3889,7 @@ mod renderer_runtime_inspector_response_channel_tests { assert_raw_session_sink_settlement(&raw, true); } + #[cfg(feature = "devtools")] #[test] fn raw_session_sink_deep_success_uses_wire_status() { let raw = format!( @@ -3900,6 +3903,7 @@ mod renderer_runtime_inspector_response_channel_tests { assert_raw_session_sink_settlement(&raw, true); } + #[cfg(feature = "devtools")] #[test] fn raw_session_sink_error_stays_opaque() { assert_raw_session_sink_settlement( @@ -3952,6 +3956,7 @@ mod renderer_runtime_inspector_response_channel_tests { assert!(rx.await.is_err()); } + #[cfg(feature = "devtools")] #[tokio::test] async fn revoking_session_lease_leaves_terminal_settlement_to_protocol_owner() { let attachment = RendererAgentAttachmentId::allocate(); @@ -4050,6 +4055,7 @@ mod renderer_runtime_inspector_response_channel_tests { ); } + #[cfg(feature = "devtools")] #[tokio::test] async fn late_response_waits_for_page_owner_publication() { let page_id = PageId::new_for_testing(1); @@ -4099,6 +4105,7 @@ mod renderer_runtime_inspector_response_channel_tests { ); } + #[cfg(feature = "devtools")] #[tokio::test] async fn session_output_changes_the_sink_without_bypassing_the_page_owner_boundary() { let page_id = PageId::new_for_testing(1); @@ -4184,6 +4191,7 @@ mod renderer_runtime_inspector_response_channel_tests { channel.cancel(); } + #[cfg(feature = "devtools")] #[tokio::test] async fn session_terminal_response_uses_essential_reserve_after_observation_saturation() { let page_id = PageId::new_for_testing(2); @@ -4282,6 +4290,7 @@ mod renderer_runtime_inspector_response_channel_tests { drop(fence); } + #[cfg(feature = "devtools")] #[tokio::test] async fn rejected_session_terminal_response_does_not_settle_the_frontend_call() { let page_id = PageId::new_for_testing(3); @@ -4333,6 +4342,7 @@ mod renderer_runtime_inspector_response_channel_tests { assert_eq!(transport_rx.recv().await, None); } + #[cfg(feature = "devtools")] #[tokio::test] async fn unbound_session_terminal_response_is_not_deferred_or_settled() { let page_id = PageId::new_for_testing(4); @@ -4364,6 +4374,7 @@ mod renderer_runtime_inspector_response_channel_tests { assert_eq!(journal.pending_len(), 0); } + #[cfg(feature = "devtools")] #[tokio::test] async fn rotating_session_lease_rejects_stale_bound_sender_and_publishes_once() { let old_stream = @@ -4452,6 +4463,7 @@ mod renderer_runtime_inspector_response_channel_tests { } } + #[cfg(feature = "devtools")] #[tokio::test] async fn owner_failure_replaces_parked_session_result_with_exactly_one_error() { let page_id = PageId::new_for_testing(21); @@ -4524,6 +4536,7 @@ mod renderer_runtime_inspector_response_channel_tests { } } + #[cfg(feature = "devtools")] #[tokio::test] async fn page_settlement_keeps_nonresponse_output_beside_session_response() { let page_id = PageId::new_for_testing(22); @@ -4586,6 +4599,7 @@ mod renderer_runtime_inspector_response_channel_tests { )); } + #[cfg(feature = "devtools")] #[test] #[should_panic(expected = "one Page command cannot settle multiple terminal session responses")] fn page_settlement_rejects_two_terminal_session_responses() { @@ -5133,7 +5147,7 @@ pub enum RendererPageCommand { ChildFrameIdForDefaultExecutionContextId(i64), ChildDefaultExecutionContextIdForFrameId(String), RuntimeConsoleMessagesWithContext, - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] RuntimeHeapUsage, #[cfg(feature = "devtools")] PerformanceMetricSnapshot, @@ -6183,7 +6197,7 @@ impl RendererPageCommand { } } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod renderer_inspector_command_envelope_tests { use super::*; @@ -6454,7 +6468,7 @@ pub enum RendererPageReply { RuntimeEvaluationResult(RendererRuntimeEvaluationResult), RuntimeInspectorProtocolMessages(RendererRuntimeCommandOutput), RuntimeConsoleMessageSnapshots(Vec), - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] RuntimeHeapUsage(Box), #[cfg(feature = "devtools")] PerformanceMetricSnapshot(Box), diff --git a/moli-renderer-v8/src/runtime/page_vm/mod.rs b/moli-renderer-v8/src/runtime/page_vm/mod.rs index 133d55ab116..a98f4f396b7 100644 --- a/moli-renderer-v8/src/runtime/page_vm/mod.rs +++ b/moli-renderer-v8/src/runtime/page_vm/mod.rs @@ -4612,6 +4612,7 @@ impl PageVm { self.vm_mut().set_network_offline(env.network_offline); self.vm_mut() .set_blocked_url_patterns(&env.blocked_url_patterns); + #[cfg(feature = "devtools")] self.vm_mut() .set_fetch_subresource_interception(env.fetch_subresource_interception_classes); if matches!( diff --git a/moli-renderer-v8/src/runtime/page_vm/resource_search.rs b/moli-renderer-v8/src/runtime/page_vm/resource_search.rs index eb277df9c0f..cdc06201b8b 100644 --- a/moli-renderer-v8/src/runtime/page_vm/resource_search.rs +++ b/moli-renderer-v8/src/runtime/page_vm/resource_search.rs @@ -260,7 +260,7 @@ fn url_without_fragment(value: &str) -> Option { }) } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/child_realm_materialization_completion.rs b/moli-renderer-v8/src/runtime/page_vm/tests/child_realm_materialization_completion.rs index afcd6914075..39785bff4a3 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/child_realm_materialization_completion.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/child_realm_materialization_completion.rs @@ -124,6 +124,7 @@ async fn child_realm_materialization_body_does_not_checkpoint_between_document_s .expect("child realm materialization body boundary witness should run"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn child_realm_materialization_creates_named_preload_world_in_the_selected_turn() { run_page_vm_async_test(async move { @@ -189,6 +190,7 @@ async fn child_realm_materialization_creates_named_preload_world_in_the_selected .expect("child named-world materialization witness should run"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn detached_session_binding_is_not_installed_in_a_later_child_realm() { run_page_vm_async_test(async move { diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/command_checkpoint.rs b/moli-renderer-v8/src/runtime/page_vm/tests/command_checkpoint.rs index 252a48d10c0..7340cad90ff 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/command_checkpoint.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/command_checkpoint.rs @@ -63,6 +63,7 @@ Promise.resolve().then(() => __passiveTimezoneCheckpoint += 1); ); } +#[cfg(feature = "devtools")] #[test] fn file_input_command_completes_listener_microtasks_before_returning() { let mut page_vm = test_page_vm(); @@ -119,6 +120,7 @@ input.addEventListener("change", () => { ); } +#[cfg(feature = "devtools")] #[test] fn insert_text_command_completes_listener_microtasks_before_returning() { let mut page_vm = test_page_vm(); @@ -199,6 +201,7 @@ new MutationObserver(records => { .expect("setDocumentContent command checkpoint should complete"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn fetch_interception_command_completes_window_reactions_without_runtime_drain() { run_page_vm_async_test(async move { @@ -266,6 +269,7 @@ Promise.resolve().then(() => __fetchCommandCheckpoint += 1); .expect("Fetch-interception command checkpoint witness should run"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn offline_fetch_continue_publishes_completed_after_window_command_checkpoint() { run_page_vm_async_test(async move { @@ -359,6 +363,7 @@ Promise.resolve().then(() => __offlineContinueCheckpoint += 1); .expect("offline Fetch-continuation command witness should run"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn rejected_fetch_interception_command_without_window_body_does_not_checkpoint() { run_page_vm_async_test(async move { diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/computed_size/capture.rs b/moli-renderer-v8/src/runtime/page_vm/tests/computed_size/capture.rs index 8aaaf2f928a..4bdc3f143e8 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/computed_size/capture.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/computed_size/capture.rs @@ -1,5 +1,6 @@ use super::*; +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn computed_size_dom_snapshot_capture_preserves_rows_and_never_starts_layout() { run_page_vm_async_test(async move { diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/computed_size/lifecycle.rs b/moli-renderer-v8/src/runtime/page_vm/tests/computed_size/lifecycle.rs index 1263915d78d..210efe0c6de 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/computed_size/lifecycle.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/computed_size/lifecycle.rs @@ -136,6 +136,7 @@ globalThis.slottedStyle=getComputedStyle(document.getElementById('slotted')); .expect("flat-tree layout and live shadow style must remain separate"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn computed_size_reads_do_not_invalidate_screencast_tokens() { use crate::runtime::{ diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/extracted/child_document_scripts.rs b/moli-renderer-v8/src/runtime/page_vm/tests/extracted/child_document_scripts.rs index 582b24f1219..a51ecfc3817 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/extracted/child_document_scripts.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/extracted/child_document_scripts.rs @@ -1748,6 +1748,7 @@ parent.__childReadyHostLoadEvents.push("child-script:" + (globalThis === self)); }) .await; } +#[cfg(feature = "devtools")] #[tokio::test] async fn page_vm_input_event_commits_child_navigation_before_document_script_ready() { let page_vm = test_page_vm(); diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/inline_svg_paint.rs b/moli-renderer-v8/src/runtime/page_vm/tests/inline_svg_paint.rs index 5d8e551daef..487dd0518e1 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/inline_svg_paint.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/inline_svg_paint.rs @@ -374,6 +374,7 @@ async fn inline_svg_reveal_waits_for_visual_publication() { }).await.expect("revealed SVG must become measurable only after a new publication"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn inline_svg_screencast_publishes_changed_geometry_and_skips_clean_polls() { use crate::runtime::{ diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/lifecycle.rs b/moli-renderer-v8/src/runtime/page_vm/tests/lifecycle.rs index 1db95f00d87..9081ca10fe1 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/lifecycle.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/lifecycle.rs @@ -23,6 +23,7 @@ use crate::{ use serde_json::Value; use std::sync::Arc; +#[cfg(feature = "devtools")] #[test] fn stale_domcontentloaded_barrier_preserves_current_document_frontend_bindings() { let mut page_vm = test_page_vm(); @@ -54,6 +55,7 @@ fn stale_domcontentloaded_barrier_preserves_current_document_frontend_bindings() ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn history_keeps_action_window_but_document_open_cancels_it() { run_page_vm_async_test(async move { @@ -787,6 +789,7 @@ fn page_diagnostics_snapshot_includes_runtime_observable_lifecycle_payload() { )); } +#[cfg(feature = "devtools")] #[test] fn page_diagnostics_snapshot_uses_cached_runtime_observable_console_source_items() { let mut page_vm = test_page_vm(); @@ -2767,6 +2770,7 @@ document.addEventListener("DOMContentLoaded", () => { ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn runtime_document_close_response_does_not_wait_for_replacement_lifecycle() { run_page_vm_async_test(async move { @@ -3693,6 +3697,7 @@ fn top_level_http_location_navigation_without_registrations_keeps_service_worker ); } +#[cfg(feature = "devtools")] #[test] fn runtime_evaluate_without_enable_uses_inspector_default_context() { let mut page_vm = test_page_vm(); @@ -3718,6 +3723,7 @@ fn runtime_evaluate_without_enable_uses_inspector_default_context() { ); } +#[cfg(feature = "devtools")] #[test] fn page_native_inspector_owns_object_namespaces_and_groups() { let mut page_vm = test_page_vm(); @@ -3734,6 +3740,7 @@ fn page_native_inspector_owns_object_namespaces_and_groups() { ); } +#[cfg(feature = "devtools")] #[test] fn runtime_stack_capture_follows_session_lifecycle() { let mut page_vm = test_page_vm(); @@ -3745,6 +3752,7 @@ fn runtime_stack_capture_follows_session_lifecycle() { }); } +#[cfg(feature = "devtools")] #[test] fn runtime_stack_capture_preserves_independent_session_limits() { let mut page_vm = test_page_vm(); @@ -3759,6 +3767,7 @@ fn runtime_stack_capture_preserves_independent_session_limits() { }); } +#[cfg(feature = "devtools")] #[test] fn runtime_enable_hides_the_internal_stack_capture_limit_response() { let mut page_vm = test_page_vm(); @@ -3797,6 +3806,7 @@ fn runtime_enable_hides_the_internal_stack_capture_limit_response() { ); } +#[cfg(feature = "devtools")] #[test] fn page_diagnostics_snapshot_uses_rust_runtime_observable_console_source_queue() { let mut page_vm = test_page_vm(); @@ -3832,6 +3842,7 @@ globalThis.__moliConsoleDetails = []; )); } +#[cfg(feature = "devtools")] #[test] fn runtime_console_message_snapshot_ignores_user_tampered_console_buffers() { let mut page_vm = test_page_vm(); diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs b/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs index 96875bbf1a7..b834bf70d6f 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs @@ -96,6 +96,7 @@ use crate::frame_owner_model::{ }; use crate::native_bridge::PendingWindowMessageEndpoint; +#[cfg(feature = "devtools")] mod accessibility; mod async_subresource_completion; mod blob_slice; @@ -122,12 +123,14 @@ mod computed_size; mod cssom_zoom; mod dedicated_worker_client_event; mod document_script_completion; +#[cfg(feature = "devtools")] mod dom_publication; mod element_toggle_event; mod fetch_blob_reading; mod fetch_xhr; mod file_entry_file_callback; mod file_reader; +#[cfg(feature = "devtools")] mod file_system_directory_reader; mod grid_item_box_generation; mod grid_item_paint_order; diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update.rs b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update.rs index 71241941d04..deac8779d55 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update.rs @@ -3,6 +3,7 @@ use super::*; mod image_repeat; mod planar_transforms; mod print; +#[cfg(feature = "devtools")] mod print_isolation; mod transform_precision; diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/print.rs b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/print.rs index efe1a57dfde..adc99c3d401 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/print.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/print.rs @@ -220,6 +220,7 @@ child.contentDocument.body.innerHTML = '

Iframe text

'; }).await.expect("native printing preserves media and interactive state"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn print_to_pdf_preserves_published_geometry_frame_viewports_and_mouse_targets() { run_page_vm_async_test(async move { diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/scrollbars.rs b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/scrollbars.rs index 5f7600a2ed1..87de8c5a1b3 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/scrollbars.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/scrollbars.rs @@ -1,5 +1,6 @@ use super::*; +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn scrollbar_emulation_republishes_frames_hit_targets_and_screencast_pixels() { run_page_vm_async_test(async move { diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/visual_output.rs b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/visual_output.rs index c87dc938c2e..b81b33afc43 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/visual_output.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/visual_output.rs @@ -385,6 +385,7 @@ document.body.innerHTML = '
'; .expect("screencast layout cache test should run"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn screencast_visual_token_tracks_child_document_styles_without_retaining_paint() { run_page_vm_async_test(async move { @@ -460,6 +461,7 @@ child.adoptedStyleSheets = [globalThis.__childScreencastSheet]; .expect("child screencast style-generation fixture should run"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn screencast_visual_token_tracks_canvas_and_scroll_while_screenshot_stays_fresh() { run_page_vm_async_test(async move { @@ -560,6 +562,7 @@ context.fillRect(0, 0, 40, 100); .expect("screencast visual generations fixture should run"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn async_resource_publication_during_screencast_capture_forces_a_followup_frame() { run_page_vm_async_test(async move { diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/worker/service_and_shared_worker_lifecycle.rs b/moli-renderer-v8/src/runtime/page_vm/tests/worker/service_and_shared_worker_lifecycle.rs index 5b5238865c7..171eb25b315 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/worker/service_and_shared_worker_lifecycle.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/worker/service_and_shared_worker_lifecycle.rs @@ -801,6 +801,7 @@ async fn module_shared_worker_credentials_omit_omits_script_cookies() { .await; } +#[cfg(feature = "devtools")] #[tokio::test] async fn shared_worker_console_flows_through_runtime_observable_source() { run_page_vm_async_test(async move { diff --git a/moli-renderer-v8/src/runtime/phase_one/mod.rs b/moli-renderer-v8/src/runtime/phase_one/mod.rs index e836c1161c4..c4f6c2b5ee0 100644 --- a/moli-renderer-v8/src/runtime/phase_one/mod.rs +++ b/moli-renderer-v8/src/runtime/phase_one/mod.rs @@ -101,9 +101,10 @@ use super::script_preloads::{BufferedDocumentPreloadState, ServiceWorkerScriptPr fn script_preloads_require_owner_admission(env: &PageVmEnvConfig) -> bool { !main_document_parser_scripting_enabled(env) - || env - .fetch_subresource_interception_classes - .intercepts(crate::types::SubresourceResourceType::Script) + || (cfg!(feature = "devtools") + && env + .fetch_subresource_interception_classes + .intercepts(crate::types::SubresourceResourceType::Script)) } pub(in crate::runtime) fn main_document_parser_scripting_enabled(env: &PageVmEnvConfig) -> bool { diff --git a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/dom_mutation_state.rs b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/dom_mutation_state.rs index 33915bb120a..7f39905c93e 100644 --- a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/dom_mutation_state.rs +++ b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/dom_mutation_state.rs @@ -383,6 +383,7 @@ parserTarget.focus(); ); })); } +#[cfg(feature = "devtools")] #[test] fn parser_remove_pending_pointer_capture_target_clears_like_js_remove() { let runtime = tokio::runtime::Builder::new_current_thread() @@ -553,6 +554,7 @@ window.parserPendingPointerCapture = installPendingPointerCaptureTarget('parser- ); })); } +#[cfg(feature = "devtools")] #[test] fn parser_reparent_pending_pointer_capture_target_to_disconnected_parent_clears_like_js() { let runtime = tokio::runtime::Builder::new_current_thread() diff --git a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/dom_tracking.rs b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/dom_tracking.rs index ec848b311ba..c9f40fb791b 100644 --- a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/dom_tracking.rs +++ b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/dom_tracking.rs @@ -1,4 +1,5 @@ use super::*; +#[cfg(feature = "devtools")] use crate::document_runtime::DevToolsDomMutationFact; use crate::live_document_parser::LiveDocumentParserStepOutcome; @@ -47,6 +48,8 @@ fn parser_text_batches_before_inspector_and_mutation_observers() { {characterData:true, characterDataOldValue:true});", ).unwrap(); } + #[cfg(feature = "devtools")] + { // Publish before the next chunk, just as chromedp's // DOM.getDocument does while a navigation is still streaming. page_vm @@ -56,6 +59,7 @@ fn parser_text_batches_before_inspector_and_mutation_observers() { .vm_mut() .document_runtime .take_pending_devtools_dom_mutations(); + } let input = if raw_text { "x<" } else { "x&" }.repeat(2_048) + "x"; let expected = seed.to_owned() + &if raw_text { "x<" } else { "x&" }.repeat(2_048) + "x"; @@ -63,6 +67,8 @@ fn parser_text_batches_before_inspector_and_mutation_observers() { driver.pump_parse_step_with_signals(&mut page_vm, owner, &input), LiveDocumentParserStepOutcome::InputBoundary )); + #[cfg(feature = "devtools")] + { let facts = page_vm .vm_mut() .document_runtime @@ -94,7 +100,10 @@ fn parser_text_batches_before_inspector_and_mutation_observers() { (realm={with_window_realm}, raw_text={raw_text})", expected.len() ); + } if with_window_realm { + let actual = page_vm.vm_mut().eval("document.querySelector('main, script').textContent").unwrap(); + assert_eq!(actual, expected); let old_values = page_vm.vm_mut().eval( "JSON.stringify(__tree_buffer_old_values.concat( \ __tree_buffer_observer.takeRecords().map(record => record.oldValue)))", diff --git a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/preload_scanning_and_csp.rs b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/preload_scanning_and_csp.rs index b5cc98fc0a7..3bb9b6a11ad 100644 --- a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/preload_scanning_and_csp.rs +++ b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/preload_scanning_and_csp.rs @@ -367,6 +367,7 @@ fn scanned_stylesheet_starts_without_waiting_for_parser_dom_ownership() { })); }); } +#[cfg(feature = "devtools")] #[test] fn scanned_stylesheet_admission_respects_media_and_fetch_interception() { run_phase_one_large_stack_test("scanned-stylesheet-admission-gates", || { diff --git a/moli-renderer-v8/src/runtime/tests.rs b/moli-renderer-v8/src/runtime/tests.rs index 80fe09a5c58..0f4c93f0594 100644 --- a/moli-renderer-v8/src/runtime/tests.rs +++ b/moli-renderer-v8/src/runtime/tests.rs @@ -347,6 +347,7 @@ fn mouse_input_json_witness(reply: &RendererPageReply) -> serde_json::Value { }) } +#[cfg(feature = "devtools")] async fn dispatch_wheel_for_action_window_test( page: &RendererPageHandle, delta_y: f64, @@ -389,6 +390,7 @@ async fn capture_screenshot_with_request( } } +#[cfg(feature = "devtools")] async fn capture_screencast_frame_with_request( page: &RendererPageHandle, request: super::RendererCaptureScreencastFrameRequest, @@ -552,6 +554,7 @@ async fn assert_window_performance_surface_for_test(page: &RendererPageHandle, p ); } +#[cfg(any(test, feature = "devtools"))] async fn runtime_heap_usage_for_test(page: &RendererPageHandle) -> serde_json::Value { let (reply, _) = page .run_async_command(RendererPageCommand::RuntimeHeapUsage) @@ -641,6 +644,7 @@ fn runtime_indexed_db_test_root(label: &str) -> std::path::PathBuf { )) } +#[cfg(feature = "devtools")] async fn create_isolated_world_for_test( page: &RendererPageHandle, name: &str, @@ -660,6 +664,7 @@ async fn create_isolated_world_for_test( } } +#[cfg(feature = "devtools")] async fn create_isolated_world_runtime_activity_for_test( page: &RendererPageHandle, inspector_session_id: Option<&str>, @@ -681,6 +686,7 @@ async fn create_isolated_world_runtime_activity_for_test( } } +#[cfg(feature = "devtools")] async fn create_isolated_world_for_frame_for_test( page: &RendererPageHandle, frame_id: &str, @@ -1046,6 +1052,7 @@ async fn shared_worker_probe_messages(page: &RendererPageHandle) -> anyhow::Resu .ok_or_else(|| anyhow::anyhow!("expected SharedWorker probe messages string")) } +#[cfg(feature = "devtools")] async fn runtime_protocol_object_id( page: &RendererPageHandle, request: serde_json::Value, @@ -1058,6 +1065,7 @@ async fn runtime_protocol_object_id( .ok_or_else(|| anyhow::anyhow!("expected Runtime response {response_id} to carry objectId")) } +#[cfg(feature = "devtools")] async fn dispatch_runtime_protocol_for_test( page: &RendererPageHandle, request: serde_json::Value, @@ -1067,6 +1075,7 @@ async fn dispatch_runtime_protocol_for_test( .map(|(messages, _)| messages) } +#[cfg(feature = "devtools")] async fn dispatch_runtime_protocol_with_output_for_test( page: &RendererPageHandle, request: serde_json::Value, @@ -1092,6 +1101,7 @@ async fn dispatch_runtime_protocol_with_output_for_test( Ok((messages, output)) } +#[cfg(feature = "devtools")] async fn dispatch_runtime_protocol_with_context_resolution_for_test( page: &RendererPageHandle, action: &str, @@ -1128,12 +1138,14 @@ fn runtime_protocol_response_by_id( .find(|message| message.get("id").and_then(serde_json::Value::as_i64) == Some(response_id)) } +#[cfg(feature = "devtools")] async fn runtime_enable_events_for_test( page: &RendererPageHandle, ) -> anyhow::Result> { runtime_enable_events_for_inspector_session_for_test(page, None).await } +#[cfg(feature = "devtools")] async fn runtime_enable_events_for_inspector_session_for_test( page: &RendererPageHandle, inspector_session_id: Option<&str>, @@ -1276,6 +1288,7 @@ fn runtime_default_context_count(messages: &[serde_json::Value]) -> usize { .count() } +#[cfg(feature = "devtools")] async fn add_runtime_binding_for_test( page: &RendererPageHandle, name: &str, @@ -1298,6 +1311,7 @@ async fn add_runtime_binding_for_test( } } +#[cfg(feature = "devtools")] async fn remove_runtime_binding_for_test( page: &RendererPageHandle, name: &str, @@ -1328,6 +1342,7 @@ async fn set_stored_document_start_scripts_for_test( } } +#[cfg(feature = "devtools")] async fn set_runtime_binding_state_for_test( page: &RendererPageHandle, inspector_session_id: Option, diff --git a/moli-renderer-v8/src/runtime/tests/extracted.rs b/moli-renderer-v8/src/runtime/tests/extracted.rs index 7bc2f5d9620..f3d8ac29882 100644 --- a/moli-renderer-v8/src/runtime/tests/extracted.rs +++ b/moli-renderer-v8/src/runtime/tests/extracted.rs @@ -3,6 +3,7 @@ use super::*; use parking_lot::Mutex; use std::sync::Arc; +#[cfg(feature = "devtools")] mod input_dispatch; mod lazy_main_world; mod navigation_streaming; diff --git a/moli-renderer-v8/src/runtime/tests/extracted/lazy_main_world.rs b/moli-renderer-v8/src/runtime/tests/extracted/lazy_main_world.rs index 7f53ecb3714..eeedeb08fe6 100644 --- a/moli-renderer-v8/src/runtime/tests/extracted/lazy_main_world.rs +++ b/moli-renderer-v8/src/runtime/tests/extracted/lazy_main_world.rs @@ -211,6 +211,7 @@ async fn parser_details_group_exclusivity_is_independent_of_realm_activation() { } } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn native_input_activates_the_live_document_and_its_inline_handler_once() { let runtime = initialize_layout_test_runtime(); @@ -251,6 +252,7 @@ async fn native_input_activates_the_live_document_and_its_inline_handler_once() page.close_async().await.unwrap(); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn cold_runtime_binding_install_initializes_main_world() { for execution_context_id in [None, Some(0)] { @@ -289,6 +291,7 @@ async fn cold_runtime_binding_install_initializes_main_world() { } } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn cold_runtime_binding_removal_keeps_main_world_deferred() { for command in [ @@ -316,6 +319,7 @@ async fn cold_runtime_binding_removal_keeps_main_world_deferred() { } } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn cold_runtime_binding_protocol_removal_clears_pending_world_registration() { for remove in [false, true] { diff --git a/moli-renderer-v8/src/runtime/tests/extracted/navigation_streaming.rs b/moli-renderer-v8/src/runtime/tests/extracted/navigation_streaming.rs index f120ddf40f5..c60a0a5b17f 100644 --- a/moli-renderer-v8/src/runtime/tests/extracted/navigation_streaming.rs +++ b/moli-renderer-v8/src/runtime/tests/extracted/navigation_streaming.rs @@ -1788,6 +1788,7 @@ async fn renderer_owned_navigation_survives_page_creation_observer_detach() { .await .expect("renderer-owned navigation test page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn replacement_navigation_releases_old_inspector_deferred_response_callbacks() { let runtime = JsRuntime::initialize(); diff --git a/moli-renderer-v8/src/runtime/tests/extracted/owner_lifecycle.rs b/moli-renderer-v8/src/runtime/tests/extracted/owner_lifecycle.rs index 94c7f9dc18a..64abd3673a7 100644 --- a/moli-renderer-v8/src/runtime/tests/extracted/owner_lifecycle.rs +++ b/moli-renderer-v8/src/runtime/tests/extracted/owner_lifecycle.rs @@ -1,5 +1,6 @@ use super::*; +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn owner_loop_runs_file_reading_callback_without_retry_command() { let runtime = JsRuntime::initialize(); @@ -2860,6 +2861,7 @@ sender.postMessage(0); .await .expect("blocked-lifecycle fairness page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn owner_scheduler_dispatches_universal_isolated_world_broadcast_channel_to_exact_realm() { let runtime = JsRuntime::initialize(); @@ -3813,6 +3815,7 @@ document.close(); .await .expect("synchronous document.close test page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn runtime_document_close_completion_parks_lifecycle_until_capability_release() { let runtime = JsRuntime::initialize(); diff --git a/moli-renderer-v8/src/runtime/tests/extracted/page_lifecycle_isolation.rs b/moli-renderer-v8/src/runtime/tests/extracted/page_lifecycle_isolation.rs index 5d2c115c9f7..b2fe00283dc 100644 --- a/moli-renderer-v8/src/runtime/tests/extracted/page_lifecycle_isolation.rs +++ b/moli-renderer-v8/src/runtime/tests/extracted/page_lifecycle_isolation.rs @@ -711,6 +711,7 @@ async fn per_page_isolate_policy_keeps_domparser_detached_docs_cleanup_neutral() .await .expect("second shared DOMParser page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_keeps_isolated_worlds_page_owned() { let runtime = JsRuntime::initialize(); @@ -1115,6 +1116,7 @@ async fn per_page_isolate_policy_keeps_child_default_contexts_page_owned() { .await .expect("second shared child-frame page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_keeps_child_isolated_worlds_page_owned() { let runtime = JsRuntime::initialize(); @@ -1330,6 +1332,7 @@ crate::RendererDocumentOptions { ..Default::default() }, .await .expect("second shared child-isolated-world page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_reuses_navigation_isolate_and_replaces_contexts() { let runtime = JsRuntime::initialize(); @@ -1634,6 +1637,7 @@ async fn per_page_isolate_policy_reuses_navigation_isolate_and_replaces_contexts .await .expect("peer shared page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_parser_blocking_navigation_restores_replacement_inspector_session() { let runtime = JsRuntime::initialize(); @@ -2472,6 +2476,7 @@ async fn per_page_isolate_policy_routes_dynamic_import_to_originating_page() { .await .expect("second shared page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_replays_runtime_contexts_per_page() { let runtime = JsRuntime::initialize(); @@ -2611,6 +2616,7 @@ async fn per_page_isolate_policy_replays_runtime_contexts_per_page() { .await .expect("second runtime-replay page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_scopes_document_start_scripts_to_page_worlds() { let runtime = JsRuntime::initialize(); @@ -2734,6 +2740,7 @@ async fn per_page_isolate_policy_scopes_document_start_scripts_to_page_worlds() .await .expect("second document-start page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_keeps_stored_document_start_scripts_page_local() { let runtime = JsRuntime::initialize(); diff --git a/moli-renderer-v8/src/runtime/tests/extracted/runtime_scripts.rs b/moli-renderer-v8/src/runtime/tests/extracted/runtime_scripts.rs index 6181b09b6a7..b225c2a3b50 100644 --- a/moli-renderer-v8/src/runtime/tests/extracted/runtime_scripts.rs +++ b/moli-renderer-v8/src/runtime/tests/extracted/runtime_scripts.rs @@ -1,5 +1,6 @@ use super::*; +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn typed_attributes_resolve_scoped_references_against_live_nodes() { use super::{RendererDocumentNodeAttributesResolution as Attributes, RendererDomNodeReference}; @@ -580,6 +581,7 @@ customElements.define("wpt-parser-microtask-mutates", globalThis.__ParserMicrota .await .expect("parser microtask mutation page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn runtime_binding_replay_cannot_consume_same_id_frontend_deferred_response() { let runtime = JsRuntime::initialize(); @@ -734,6 +736,7 @@ async fn page_document_isolate_completes_real_v8_foreground_task() { "the Page isolate must remain routable while V8 completes foreground work" ); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn child_default_runtime_evaluate_pending_await_promise_does_not_leak_internal_token() { let runtime = JsRuntime::initialize(); @@ -844,6 +847,7 @@ async fn child_default_runtime_evaluate_pending_await_promise_does_not_leak_inte .await .expect("child runtime awaitPromise page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn runtime_enable_waits_for_queued_child_realm_before_reporting_contexts() { let runtime = JsRuntime::initialize(); @@ -922,6 +926,7 @@ async fn runtime_enable_waits_for_queued_child_realm_before_reporting_contexts() .await .expect("Runtime.enable child barrier page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn runtime_enable_events_for_new_inspector_session_replays_existing_isolated_worlds() { let runtime = JsRuntime::initialize(); @@ -966,6 +971,7 @@ async fn runtime_enable_events_for_new_inspector_session_replays_existing_isolat "new inspector session Runtime.enable should replay existing isolated world: {events:?}" ); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn runtime_enable_events_include_renderer_root_frame_id_for_default_context() { let runtime = JsRuntime::initialize(); @@ -1029,6 +1035,7 @@ async fn runtime_enable_events_include_renderer_root_frame_id_for_default_contex .await .expect("root-frame test page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn set_runtime_binding_state_updates_renderer_inspector_session_store() { let runtime = JsRuntime::initialize(); @@ -1124,6 +1131,7 @@ async fn set_runtime_binding_state_updates_renderer_inspector_session_store() { .await .expect("renderer binding clearing test page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn apply_runtime_protocol_state_keeps_session_binding_replay_scoped() { let runtime = JsRuntime::initialize(); @@ -1184,6 +1192,7 @@ async fn apply_runtime_protocol_state_keeps_session_binding_replay_scoped() { .await .expect("renderer protocol-state session binding test page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn inspector_output_flushes_v8_state_for_commands_and_notifications() { let runtime = JsRuntime::initialize(); @@ -1267,6 +1276,7 @@ async fn inspector_output_flushes_v8_state_for_commands_and_notifications() { .await .expect("inspector state output page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn owner_command_fences_exact_cursor_when_later_output_is_already_published() { let runtime = JsRuntime::initialize(); @@ -1364,6 +1374,7 @@ async fn owner_command_fences_exact_cursor_when_later_output_is_already_publishe .await .expect("concurrent command output page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn page_diagnostics_snapshot_is_read_only_for_current_inspector_output() { let runtime = JsRuntime::initialize(); @@ -1455,6 +1466,7 @@ async fn page_diagnostics_snapshot_is_read_only_for_current_inspector_output() { .await .expect("read-only Inspector diagnostics page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn failed_stateful_inspector_command_preserves_v8_state() { let runtime = JsRuntime::initialize(); @@ -1524,6 +1536,7 @@ async fn failed_stateful_inspector_command_preserves_v8_state() { .await .expect("failed inspector state page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn stored_document_start_script_remove_uses_registry_key_namespace() { let runtime = JsRuntime::initialize(); @@ -1629,6 +1642,7 @@ async fn stored_document_start_script_remove_uses_registry_key_namespace() { .await .expect("registry-key stored-preload page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn webcrypto_checkpoint_reconciles_document_replacement_before_restoring_page_residence() { let runtime = JsRuntime::initialize(); @@ -3568,6 +3582,7 @@ async fn document_commit_release_runs_parser_script_location_handoff_in_backgrou .await .expect("parser location handoff page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn command_turn_output_scope_is_removed_after_command_error() { let runtime = JsRuntime::initialize(); @@ -4123,6 +4138,7 @@ fn parse_time_scaffold_lane_is_rejected_on_named_executor_lane() { }); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn pending_expression_publishes_console_output_before_settlement() { let runtime = JsRuntime::initialize(); @@ -4211,6 +4227,7 @@ async fn pending_expression_publishes_console_output_before_settlement() { .expect("close pending-expression page"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn navigation_follow_publishes_command_output_before_replacing_document() { let runtime = JsRuntime::initialize(); diff --git a/moli-renderer-v8/src/runtime/tests/extracted/scoped_runtime_contexts.rs b/moli-renderer-v8/src/runtime/tests/extracted/scoped_runtime_contexts.rs index f78c7bb0449..d7813ff0b61 100644 --- a/moli-renderer-v8/src/runtime/tests/extracted/scoped_runtime_contexts.rs +++ b/moli-renderer-v8/src/runtime/tests/extracted/scoped_runtime_contexts.rs @@ -1,5 +1,6 @@ use super::*; +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_rejects_cross_page_runtime_object_ids() { let runtime = JsRuntime::initialize(); @@ -250,6 +251,7 @@ async fn per_page_isolate_policy_rejects_cross_page_runtime_object_ids() { .await .expect("second runtime-object page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_scopes_same_numeric_runtime_evaluate_context_id_to_page() { let runtime = JsRuntime::initialize(); @@ -418,6 +420,7 @@ async fn per_page_isolate_policy_scopes_same_numeric_runtime_evaluate_context_id .await .expect("second runtime-context page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_scopes_same_numeric_runtime_evaluate_default_context_id_to_page() { let runtime = JsRuntime::initialize(); @@ -571,6 +574,7 @@ async fn per_page_isolate_policy_scopes_same_numeric_runtime_evaluate_default_co .await .expect("second default runtime-context page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_scopes_same_numeric_runtime_evaluate_child_context_id_to_page() { let runtime = JsRuntime::initialize(); @@ -748,6 +752,7 @@ crate::RendererDocumentOptions { ..Default::default() }, .await .expect("second child runtime-context page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_keeps_release_object_group_page_local() { let runtime = JsRuntime::initialize(); @@ -905,6 +910,7 @@ async fn per_page_isolate_policy_keeps_release_object_group_page_local() { .await .expect("second release-group page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_scopes_runtime_bindings_to_page_worlds() { let runtime = JsRuntime::initialize(); @@ -1047,6 +1053,7 @@ async fn per_page_isolate_policy_scopes_runtime_bindings_to_page_worlds() { .await .expect("second runtime-binding page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_scopes_same_numeric_runtime_binding_context_id_to_page() { let runtime = JsRuntime::initialize(); @@ -1240,6 +1247,7 @@ async fn per_page_isolate_policy_scopes_same_numeric_runtime_binding_context_id_ .await .expect("second binding-context page should close"); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn per_page_isolate_policy_keeps_remove_binding_page_local() { let runtime = JsRuntime::initialize(); diff --git a/moli-renderer-v8/src/runtime/tests/extracted/visual_output.rs b/moli-renderer-v8/src/runtime/tests/extracted/visual_output.rs index f802dcf2227..0cebdd4adbd 100644 --- a/moli-renderer-v8/src/runtime/tests/extracted/visual_output.rs +++ b/moli-renderer-v8/src/runtime/tests/extracted/visual_output.rs @@ -137,6 +137,7 @@ async fn capture_screenshot_paints_downloaded_raster_image_pixels() { [0, 255, 0, 255] ); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn screenshot_and_screencast_paint_downloaded_svg_vectors() { let runtime = initialize_layout_test_runtime(); @@ -660,6 +661,7 @@ async fn capture_screenshot_respects_mock_layout_policy() { RendererPageReply::CaptureScreenshot(RendererCaptureScreenshotReply::LayoutDisabled) )); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn screenshot_and_screencast_flush_pending_wheel_actions_before_paint() { let runtime = initialize_layout_test_runtime(); diff --git a/moli-renderer-v8/src/runtime/tests/open_streaming.rs b/moli-renderer-v8/src/runtime/tests/open_streaming.rs index 1363cb85344..2456865a1b8 100644 --- a/moli-renderer-v8/src/runtime/tests/open_streaming.rs +++ b/moli-renderer-v8/src/runtime/tests/open_streaming.rs @@ -57,6 +57,7 @@ async fn recv_timer_console_publication( .expect("the timer must autonomously publish its console output") } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn timer_console_output_during_open_stream_does_not_wait_for_load() { let mut source = OpenStreamingPage::create( @@ -97,6 +98,7 @@ async fn timer_console_output_during_open_stream_does_not_wait_for_load() { ); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "multi_thread")] async fn timer_console_output_after_load_keeps_source_document_when_callback_replaces_it() { let runtime = JsRuntime::initialize(); @@ -434,22 +436,35 @@ setTimeout(() => location.replace(location.href), 0); // Owner commands are ordered after the checked-out navigation task. The // response reached Prepared, but its fallible commit must return a Live // entry with the original context, inspector and parser still resident. - let messages = dispatch_runtime_protocol_for_test( - &source.page, - serde_json::json!({ - "id": 1, - "method": "Runtime.evaluate", - "params": { - "expression": "window === __sourceWindow && document === __sourceDocument && !document.getElementById('replacement')", - "returnByValue": true - } - }), - ) - .await - .expect("commit validation failure must preserve the source Inspector context"); - let response = runtime_protocol_response_by_id(&messages, 1) - .expect("source Inspector evaluation should reply"); - assert_eq!(response["result"]["result"]["value"], true); + let expression = "window === __sourceWindow && document === __sourceDocument && !document.getElementById('replacement')"; + #[cfg(feature = "devtools")] + { + let messages = dispatch_runtime_protocol_for_test( + &source.page, + serde_json::json!({ + "id": 1, + "method": "Runtime.evaluate", + "params": { "expression": expression, "returnByValue": true } + }), + ) + .await + .expect("commit validation failure must preserve the source Inspector context"); + let response = runtime_protocol_response_by_id(&messages, 1) + .expect("source Inspector evaluation should reply"); + assert_eq!(response["result"]["result"]["value"], true); + } + #[cfg(not(feature = "devtools"))] + { + let (reply, _) = source + .page + .run_async_command(RendererPageCommand::EvaluateExpression { + expression: expression.to_owned(), + await_promise: false, + }) + .await + .expect("commit validation failure must preserve the source context"); + assert_eq!(renderer_json_value(reply), Some(serde_json::json!(true))); + } assert_eq!( has_pending_location_navigation_for_test(&source.page).await, Some(false) diff --git a/moli-renderer-v8/src/script_vm.rs b/moli-renderer-v8/src/script_vm.rs index 311e61eba1c..34b8de72a08 100644 --- a/moli-renderer-v8/src/script_vm.rs +++ b/moli-renderer-v8/src/script_vm.rs @@ -1334,7 +1334,7 @@ impl ScriptVm { }); } - #[cfg(test)] + #[cfg(all(test, feature = "devtools"))] pub(super) fn dispatch_inspector_protocol_message( &mut self, raw_json: &str, diff --git a/moli-renderer-v8/src/script_vm/document_environment.rs b/moli-renderer-v8/src/script_vm/document_environment.rs index 26587fabffe..da32570c9a0 100644 --- a/moli-renderer-v8/src/script_vm/document_environment.rs +++ b/moli-renderer-v8/src/script_vm/document_environment.rs @@ -408,6 +408,7 @@ impl ScriptVm { .set_blocked_url_patterns(patterns); } + #[cfg(any(test, feature = "devtools"))] pub(crate) fn set_fetch_subresource_interception( &mut self, classes: SubresourceInterceptionClasses, diff --git a/moli-renderer-v8/src/script_vm/eval_exec.rs b/moli-renderer-v8/src/script_vm/eval_exec.rs index 32177e1c5b3..7c8471c59dd 100644 --- a/moli-renderer-v8/src/script_vm/eval_exec.rs +++ b/moli-renderer-v8/src/script_vm/eval_exec.rs @@ -695,7 +695,7 @@ impl ScriptVm { ); } - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] pub(crate) fn eval(&mut self, source: &str) -> Result { let context_ptr = self.ensure_main_world()?.context_ptr(); self.eval_string_in_context_ptr_runtime_turn(context_ptr, source, false) @@ -770,7 +770,7 @@ impl ScriptVm { self.eval_string_in_context_ptr_runtime_turn(context_ptr, source, true) } - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] pub(super) fn eval_string_in_context_ptr_runtime_turn( &mut self, context_ptr: *const v8::Global, @@ -829,7 +829,7 @@ impl ScriptVm { // Raw string evaluation in a specific context. Keep this private so callers // must choose either the runtime-turn facade or the internal snapshot facade. - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] fn eval_string_in_context_ptr_without_turn_drain( &mut self, context_ptr: *const v8::Global, diff --git a/moli-renderer-v8/src/script_vm/inspector/agent.rs b/moli-renderer-v8/src/script_vm/inspector/agent.rs index 7b304c9b0d9..3745f4159f2 100644 --- a/moli-renderer-v8/src/script_vm/inspector/agent.rs +++ b/moli-renderer-v8/src/script_vm/inspector/agent.rs @@ -418,7 +418,7 @@ impl RendererDevToolsAgent { } } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; use crate::script_vm::inspector::context_registry::DocumentInspectorContextRegistrationId; diff --git a/moli-renderer-v8/src/script_vm/inspector/agent_sessions.rs b/moli-renderer-v8/src/script_vm/inspector/agent_sessions.rs index e9a5557095c..94b686f3ea8 100644 --- a/moli-renderer-v8/src/script_vm/inspector/agent_sessions.rs +++ b/moli-renderer-v8/src/script_vm/inspector/agent_sessions.rs @@ -495,7 +495,7 @@ pub(super) fn inspector_session_key(inspector_session_id: Option<&str>) -> DevTo DevToolsSessionKey::from_wire_session_id(inspector_session_id.filter(|id| !id.is_empty())) } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; use crate::inspector_session::dispatch_with_runtime_defaults; diff --git a/moli-renderer-v8/src/script_vm/inspector/outbound.rs b/moli-renderer-v8/src/script_vm/inspector/outbound.rs index cc5f018231c..25febde0b24 100644 --- a/moli-renderer-v8/src/script_vm/inspector/outbound.rs +++ b/moli-renderer-v8/src/script_vm/inspector/outbound.rs @@ -662,7 +662,7 @@ impl InspectorOutbound { .collect() } - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] pub(in crate::script_vm) fn take_pending_messages(&self) -> Vec { let state = self.state(); let mut guard = state.borrow_mut(); @@ -833,7 +833,7 @@ impl Drop for InspectorInternalDispatchResponseCapture { } } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; use crate::devtools::pause::RendererInspectorPauseBridge; diff --git a/moli-renderer-v8/src/script_vm/inspector/tests.rs b/moli-renderer-v8/src/script_vm/inspector/tests.rs index 685261b8e49..34ca51b2249 100644 --- a/moli-renderer-v8/src/script_vm/inspector/tests.rs +++ b/moli-renderer-v8/src/script_vm/inspector/tests.rs @@ -1,6 +1,7 @@ use super::*; use crate::inspector_session::InspectorSessionOutput; use crate::runtime::RendererRuntimeInspectorResponseSender; +use moli_inspector_json::InspectorJson; fn business_messages(messages: Vec) -> Vec { messages @@ -213,6 +214,7 @@ fn deferred_inspector_response_preserves_protocol_attachment() { ); } +#[cfg(feature = "devtools")] #[test] fn runtime_command_output_only_parks_its_own_response_callback() { let outbound = InspectorOutbound::default(); @@ -311,6 +313,7 @@ fn inspector_outbound_deactivation_cancels_callbacks_owned_by_the_old_backend() ); } +#[cfg(feature = "devtools")] #[test] fn internal_dispatch_response_does_not_consume_same_id_deferred_frontend_callback() { let outbound = InspectorOutbound::default(); @@ -350,6 +353,7 @@ fn internal_dispatch_response_does_not_consume_same_id_deferred_frontend_callbac ); } +#[cfg(feature = "devtools")] #[test] fn internal_dispatch_call_id_avoids_queued_and_active_frontend_ids() { let outbound = InspectorOutbound::default(); @@ -448,6 +452,7 @@ fn renderer_inspector_unique_id_capture_depth_recovers_after_panic() { assert_eq!(state.capture_depth_for_test(), 0); } +#[cfg(feature = "devtools")] #[test] fn replacement_document_binding_does_not_adopt_previous_agent_outbound() { crate::ensure_v8_for_test(); @@ -494,6 +499,7 @@ fn replacement_document_binding_does_not_adopt_previous_agent_outbound() { ); } +#[cfg(feature = "devtools")] #[test] fn dropping_overlapping_peer_binding_does_not_deactivate_current_agent() { crate::ensure_v8_for_test(); @@ -572,4 +578,5 @@ fn inspector_response_id_reads_opaque_metadata_and_tracks_explicit_mutation() { assert_eq!(message.renderer_call_id(), None); } +#[cfg(feature = "devtools")] mod native_cleanup; diff --git a/moli-renderer-v8/src/script_vm/inspector/v8_backend/page_target_tests.rs b/moli-renderer-v8/src/script_vm/inspector/v8_backend/page_target_tests.rs index 355ee0b086b..21ef5a5979f 100644 --- a/moli-renderer-v8/src/script_vm/inspector/v8_backend/page_target_tests.rs +++ b/moli-renderer-v8/src/script_vm/inspector/v8_backend/page_target_tests.rs @@ -190,6 +190,7 @@ fn closing_running_page_leaves_peer_isolate_usable() { run_close_during_script(true); } +#[cfg(feature = "devtools")] #[test] fn closing_peer_preserves_debugger_pause_and_its_resume_route() { use crate::runtime::{ @@ -278,6 +279,7 @@ fn closing_peer_preserves_debugger_pause_and_its_resume_route() { backend.context_destroyed(v8::Local::new(scope, &context)); } +#[cfg(feature = "devtools")] #[tokio::test] async fn owner_shutdown_seals_all_page_queues_and_rejects_new_page() { #[cfg(feature = "devtools")] diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/history_worlds.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/history_worlds.rs index d20604b141c..9e56688ee14 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/history_worlds.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/history_worlds.rs @@ -1202,6 +1202,7 @@ async fn history_worlds_share_mutations_but_keep_wrappers_and_state_caches_separ ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn history_worlds_child_mutations_share_only_the_child_window_history() { let loader = ResourceRequestClient::new(&moli_fetch::FetchConfig::default()).expect("loader"); @@ -1363,6 +1364,7 @@ async fn history_worlds_child_mutations_share_only_the_child_window_history() { ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn history_worlds_preserve_the_shared_backing_when_initial_child_window_is_reused() { let mut vm = new_storage_test_vm("https://example.com/base"); diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/media_player_init.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/media_player_init.rs index 6f7d1c42389..ad05c9b8bc1 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/media_player_init.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/media_player_init.rs @@ -376,6 +376,7 @@ fn media_session_releases_isolated_worlds_and_unregistered_handlers() { } } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn media_session_state_belongs_to_each_window_and_resets_on_navigation() { let mut vm = new_storage_html_test_vm("https://media-session-navigation.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/mod.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/mod.rs index 39a3d036329..fe5485e5991 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/mod.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/mod.rs @@ -130,6 +130,7 @@ mod window_focus; mod web_transport_error_values; mod xpath_result_bindings; +#[cfg(feature = "devtools")] mod native_input_realms; mod attr_node_native_dispatch; diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/navigation/history_traversal.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/navigation/history_traversal.rs index 034f3be65ff..d35148a9ae7 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/navigation/history_traversal.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/navigation/history_traversal.rs @@ -44,6 +44,7 @@ JSON.stringify({ ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn reset_navigation_history_updates_all_live_window_realms() { let mut vm = new_storage_test_vm("https://reset-history-realms.test/page.html"); diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/pointer_capture.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/pointer_capture.rs index 61dcc2ec317..d5f92c6847e 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/pointer_capture.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/pointer_capture.rs @@ -49,6 +49,7 @@ async fn pointer_capture_arguments_use_native_receiver_and_webidl_conversion() { vm.eval("JSON.stringify({errors:__captureResults.errors,failures:__captureResults.rows.filter(row=>Object.values(row.checks).some(value=>value!==true))})").unwrap()); } +#[cfg(feature = "devtools")] #[test] fn pointer_capture_queries_pending_target_before_native_dispatch() { let mut vm = new_rendered_test_vm( diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/popup_hyperlinks.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/popup_hyperlinks.rs index 647c5b1f10d..e342fbaf2ed 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/popup_hyperlinks.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/popup_hyperlinks.rs @@ -232,6 +232,7 @@ fn synthetic_clicks_match_pointer_identity_across_realms_and_adoption() { ); } +#[cfg(feature = "devtools")] #[test] fn accesskey_clicks_use_the_focused_document_and_synthetic_pointer_identity() { let mut vm = new_storage_test_vm("https://accesskey-click-realms.test/"); @@ -306,6 +307,7 @@ for (let index = 0; index < realms.length; index++) { ); } +#[cfg(feature = "devtools")] #[test] fn accesskey_document_is_frozen_before_keydown_adoption() { for owner in 0..2 { @@ -360,6 +362,7 @@ source.focus(); } } +#[cfg(feature = "devtools")] #[test] fn keyboard_activation_uses_trusted_non_pointer_clicks() { let mut vm = new_storage_test_vm("https://keyboard-click-realms.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/web_mcp.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/web_mcp.rs index 0485e6e0506..0acbfba4d42 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/web_mcp.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/web_mcp.rs @@ -305,6 +305,7 @@ fn web_mcp_execution_rechecks_caller_detached_during_input_serialization() { ); } +#[cfg(feature = "devtools")] #[test] fn web_mcp_root_devtools_cannot_invoke_tools_from_a_popup_frame_tree() { let mut vm = new_storage_page_task_executor_test_vm("https://tools.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/canvas_webgl.rs b/moli-renderer-v8/src/script_vm/tests/canvas_webgl.rs index 49c97ad0bfa..49c1d4a81b0 100644 --- a/moli-renderer-v8/src/script_vm/tests/canvas_webgl.rs +++ b/moli-renderer-v8/src/script_vm/tests/canvas_webgl.rs @@ -659,6 +659,7 @@ fn canvas_text_metrics_uses_the_context_realm() { assert_eq!(result, "true|true|true|true"); } +#[cfg(feature = "devtools")] #[test] fn canvas_text_metrics_keep_the_isolated_world_realm() { let mut vm = new_parsed_test_vm( diff --git a/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_geometry_and_input.rs b/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_geometry_and_input.rs index 997496177f5..d5548563875 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_geometry_and_input.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_geometry_and_input.rs @@ -116,6 +116,7 @@ fn fresh_paint_publishes_nested_iframe_content_viewports() { ); assert_eq!(vm.layout_pass_observability_for_test().1, passes_before + 1); } +#[cfg(feature = "devtools")] #[test] fn transformed_constrained_iframe_routes_hover_click_and_wheel_in_child_coordinates() { let mut vm = new_storage_test_vm("https://iframe-input-coordinates.test/"); @@ -324,6 +325,7 @@ fn transformed_constrained_iframe_routes_hover_click_and_wheel_in_child_coordina "800|800" ); } +#[cfg(feature = "devtools")] #[test] fn iframe_native_drag_preserves_screen_coordinates_with_offset_and_scale() { for scale in [1.0, 0.5] { @@ -565,6 +567,7 @@ fn iframe_scrolling_policy_test_vm( vm } +#[cfg(feature = "devtools")] #[test] fn iframe_scrolling_policy_distinguishes_wheel_input_from_scrollbar_appearance() { let positions = "JSON.stringify([child.scrollX,child.scrollY])"; @@ -617,6 +620,7 @@ fn iframe_scrolling_policy_distinguishes_wheel_input_from_scrollbar_appearance() } } +#[cfg(feature = "devtools")] #[test] fn iframe_scrolling_policy_changes_input_permissions_at_next_publication() { let mut vm = iframe_scrolling_policy_test_vm("auto", "none"); @@ -650,6 +654,7 @@ fn iframe_scrolling_policy_changes_input_permissions_at_next_publication() { } } +#[cfg(feature = "devtools")] #[test] fn iframe_input_reuses_one_top_level_snapshot_without_parent_child_ping_pong() { let mut vm = new_storage_test_vm("https://iframe-input-snapshot.test/"); @@ -708,6 +713,7 @@ fn iframe_input_reuses_one_top_level_snapshot_without_parent_child_ping_pong() { .expect("stable child input should retain one snapshot"); assert_eq!(cached.0, vm.document_runtime.document_handle()); } +#[cfg(feature = "devtools")] #[test] fn iframe_wheel_batch_reuses_one_composite_snapshot_for_every_scroll_step() { let mut vm = new_storage_test_vm("https://iframe-wheel-snapshot.test/"); @@ -797,6 +803,7 @@ fn iframe_wheel_batch_reuses_one_composite_snapshot_for_every_scroll_step() { "60|3" ); } +#[cfg(feature = "devtools")] #[test] fn focusing_visible_child_target_does_not_scroll_partially_hidden_transformed_iframe() { let mut vm = new_storage_test_vm("https://iframe-focus-scroll.test/"); @@ -911,6 +918,7 @@ fn focusing_visible_child_target_does_not_scroll_partially_hidden_transformed_if assert!((event["clientY"].as_f64().unwrap() - 40.0).abs() < 0.1); } } +#[cfg(feature = "devtools")] #[test] fn nested_transformed_iframe_input_composes_scroll_border_padding_and_exit_coordinates() { let mut vm = new_storage_test_vm("https://nested-iframe-input.test/"); @@ -1148,6 +1156,7 @@ fn nested_transformed_iframe_input_composes_scroll_border_padding_and_exit_coord assert_eq!(event["screenY"], 10.0); } } +#[cfg(feature = "devtools")] #[test] fn root_classic_scrollbars_stay_viewport_fixed_and_drive_window_scroll() { let mut vm = new_storage_test_vm("https://root-classic-scrollbar.test/"); @@ -1257,6 +1266,7 @@ fn root_classic_scrollbars_stay_viewport_fixed_and_drive_window_scroll() { assert_eq!(result[2], serde_json::json!([])); } +#[cfg(feature = "devtools")] #[tokio::test] async fn iframe_native_and_replayed_drag_events_use_the_receiving_window_realm() { for native in [false, true] { diff --git a/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/geometry_and_scrolling.rs b/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/geometry_and_scrolling.rs index 82593eb98e8..390847a51c9 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/geometry_and_scrolling.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/geometry_and_scrolling.rs @@ -27,6 +27,7 @@ fn element_scroll_into_view_surface_is_available() { r#"{"instanceType":"function","protoType":"function","inElement":true,"ownProperty":false,"callResult":"undefined","protoEnumerable":false}"# ); } +#[cfg(feature = "devtools")] #[test] fn wheel_default_action_scrolls_unless_canceled() { let mut vm = new_storage_test_vm("https://wheel-default-scroll.test/"); @@ -190,6 +191,7 @@ fn intersection_checks_after_scroll_reuse_geometry_until_fresh_paint() { previous = expected; } } +#[cfg(feature = "devtools")] #[test] fn wheel_default_action_scrolls_the_innermost_container_then_chains_to_the_root() { let mut vm = new_storage_test_vm("https://wheel-scroll-chain.test/"); @@ -238,6 +240,7 @@ fn wheel_default_action_scrolls_the_innermost_container_then_chains_to_the_root( "[25,40]" ); } +#[cfg(feature = "devtools")] #[test] fn classic_scrollbar_metrics_and_thumb_drag_match_chromium_without_dom_mouse_events() { let mut vm = new_storage_test_vm("https://classic-scrollbar-input.test/"); @@ -373,6 +376,7 @@ fn classic_scrollbar_metrics_and_thumb_drag_match_chromium_without_dom_mouse_eve assert!(result["top"].as_f64().is_some_and(|value| value > 100.0)); assert_eq!(result["events"], serde_json::json!([])); } +#[cfg(feature = "devtools")] #[test] fn painted_overlay_wins_over_scrollbar_and_corner_consumes_input() { let mut vm = new_storage_test_vm("https://painted-scrollbar-surface.test/"); @@ -532,6 +536,7 @@ fn document_client_size_initializes_layout_once_and_reuses_it_until_capture() { publish_layout_for_test(&mut vm); assert_eq!(vm.eval(query).unwrap(), "[0,0,0,0,0,0,0]"); } +#[cfg(feature = "devtools")] #[test] fn body_overflow_defines_viewport_scrolling_and_default_root_stable_gutters() { let mut vm = new_storage_test_vm("https://viewport-overflow-policy.test/"); @@ -772,6 +777,7 @@ fn physical_scrollbar_insets_cover_box_intrinsic_ratio_and_vertical_writing_layo "[[200,100,160,75,20,5,30,15,140,55],[230,130,190,105,20,5,30,15,170,85],[200,80,170,65,15,0,15,0,400,20],[200,105,170,90,15,0,15,0,400,90],[200,120,170,105,15,0,15,0,400,150],[200,100,170,85,15,0,15,0,170,85],[200,100,185,70,0,15,0,15,185,70]]" ); } +#[cfg(feature = "devtools")] #[test] fn nested_and_sibling_scrollbar_drags_stay_bound_to_the_pressed_scroller() { let mut vm = new_storage_test_vm("https://nested-classic-scrollbar-input.test/"); @@ -935,6 +941,7 @@ fn nested_and_sibling_scrollbar_drags_stay_bound_to_the_pressed_scroller() { assert!(result[7].as_f64().is_some_and(|value| value > 130.0)); assert_eq!(result[8], serde_json::json!([])); } +#[cfg(feature = "devtools")] #[test] fn transformed_scrollbar_drag_uses_local_motion_clamps_and_cancels_on_button_loss() { let mut vm = new_storage_test_vm("https://transformed-classic-scrollbar-input.test/"); @@ -1063,6 +1070,7 @@ fn transformed_scrollbar_drag_uses_local_motion_clamps_and_cancels_on_button_los "post-cancel moves should return to the DOM: {cancelled}" ); } +#[cfg(feature = "devtools")] #[test] fn document_replacement_cancels_old_scrollbar_capture_and_allows_a_new_drag() { let mut vm = new_storage_test_vm("https://replacement-classic-scrollbar-input.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/dom_elements/wrapper_identity.rs b/moli-renderer-v8/src/script_vm/tests/dom_elements/wrapper_identity.rs index 6ea87b0139c..cb1ae5bba7c 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_elements/wrapper_identity.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_elements/wrapper_identity.rs @@ -429,6 +429,7 @@ fn traversal_filter_wraps_unseen_nodes_in_their_document_realm() { assert_eq!(result, "true:true:true:true:true:true"); } +#[cfg(feature = "devtools")] #[test] fn isolated_child_dom_wrappers_use_isolated_intrinsic_prototypes() { let mut vm = new_parsed_test_vm( diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/computed_style_access.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/computed_style_access.rs index 8b8039d1424..b1caf34c149 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/computed_style_access.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/computed_style_access.rs @@ -1,5 +1,6 @@ use super::*; +#[cfg(feature = "devtools")] #[test] fn inspector_runtime_evaluate_uses_child_context_window_surface() { let mut vm = new_storage_test_vm("https://inspector-child-window-viewport.test/"); @@ -85,6 +86,7 @@ fn inspector_runtime_evaluate_uses_child_context_window_surface() { assert_eq!(top_result, "1920|1080"); } +#[cfg(feature = "devtools")] #[test] fn inspector_default_runtime_evaluate_masks_ambient_child_owner_scope() { let mut vm = new_storage_test_vm("https://inspector-top-window-viewport.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/content_and_invalidation.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/content_and_invalidation.rs index 7cc9f327ff5..0c44d4e9f9e 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/content_and_invalidation.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/content_and_invalidation.rs @@ -746,6 +746,7 @@ fn style_observation_reuses_current_world_without_materializing_an_update() { assert_eq!(host.style_world_full_snapshots_for_test(), full_snapshots); } +#[cfg(feature = "devtools")] #[test] fn accessibility_requests_reuse_the_retained_style_world() { let mut vm = new_parsed_test_vm( @@ -1654,6 +1655,7 @@ document.getElementById('isolated-runtime-exec-drain-target').className = 'activ ); } +#[cfg(feature = "devtools")] #[test] fn document_start_run_immediately_drains_pending_style_invalidations_without_computed_style_read() { let mut vm = new_storage_test_vm("https://document-start-run-immediately-style-drain.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/properties_and_selectors.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/properties_and_selectors.rs index 08e9fc1a2c2..1fab15cf1a1 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/properties_and_selectors.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/properties_and_selectors.rs @@ -111,6 +111,7 @@ fn held_computed_style_count_cache_tracks_custom_property_mutations() { assert_eq!(result["afterValue"], serde_json::json!("two")); } +#[cfg(feature = "devtools")] #[test] fn inspector_computed_style_bulk_read_prepares_dirty_world_once_and_reuses_clean_world() { let mut vm = new_storage_test_vm("https://computed-style-inspector-bulk.test/"); @@ -232,6 +233,7 @@ unrelatedHost.attachShadow({ mode: 'open' }).innerHTML = ); } +#[cfg(feature = "devtools")] #[test] fn inspector_computed_style_bulk_read_handles_large_inherited_custom_property_sets() { const CUSTOM_PROPERTY_COUNT: usize = 512; @@ -293,6 +295,7 @@ target.id = 'target'; } } +#[cfg(feature = "devtools")] #[test] fn inspector_computed_style_bulk_read_uses_child_document_scope_and_viewport() { let mut vm = new_storage_test_vm("https://computed-style-inspector-child.test/"); @@ -351,6 +354,7 @@ childDocument.close(); ); } +#[cfg(feature = "devtools")] #[test] fn inspector_computed_style_bulk_read_reuses_clean_shadow_world() { let mut vm = new_storage_test_vm("https://computed-style-inspector-shadow.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom/extracted/cssom_interfaces.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom/extracted/cssom_interfaces.rs index 5b6079ae839..6e0c3c84510 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom/extracted/cssom_interfaces.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom/extracted/cssom_interfaces.rs @@ -1412,6 +1412,7 @@ fn inline_owner_text_replacement_creates_a_new_sheet_and_detaches_the_old_wrappe "true|true|true|true|retained|2|1|#target { color: rgb(4, 5, 6); }|rgb(4, 5, 6)" ); } +#[cfg(feature = "devtools")] #[test] fn inline_cssom_mutation_keeps_owner_text_as_input_only() { let mut vm = new_storage_test_vm("https://inline-sheet-owner-input.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom/extracted/rule_interfaces.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom/extracted/rule_interfaces.rs index 62089651b90..30976648827 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom/extracted/rule_interfaces.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom/extracted/rule_interfaces.rs @@ -498,6 +498,7 @@ fn css_rule_css_text_uses_seeded_pdb_block_for_safe_rules_before_style_wrapper() "div { display: block; opacity: 0.5; }|0% { opacity: 0.5; }|span { --x: 1; display: block; }|100% { opacity: 1; }||display: block; opacity: 0.5;||opacity: 0.5;" ); } +#[cfg(feature = "devtools")] #[test] fn css_rule_list_serialization_uses_rule_owned_pdb_block() { let mut vm = new_storage_test_vm("https://rule-list-pdb-serialization.test/"); @@ -540,6 +541,7 @@ fn css_rule_list_serialization_uses_rule_owned_pdb_block() { }) ); } +#[cfg(feature = "devtools")] #[test] fn css_rule_mixed_style_serialization_uses_rule_owned_pdb_segment() { let mut vm = new_storage_test_vm("https://rule-mixed-pdb-serialization.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom.rs index 6cd821e66f2..f0d0424f960 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom.rs @@ -19,7 +19,9 @@ mod dom_parser; mod element_construction; mod elements_and_events; mod files_and_transfer; +#[cfg(feature = "devtools")] mod mouse_click_target; +#[cfg(feature = "devtools")] mod pointer_and_mouse; mod ranges; mod rendered_text; diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom/files_and_transfer.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom/files_and_transfer.rs index a05233f5bb0..6c06cea677c 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom/files_and_transfer.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom/files_and_transfer.rs @@ -1,5 +1,6 @@ use super::*; +#[cfg(feature = "devtools")] fn install_transfer_view_for_test( vm: &mut StandaloneScriptVmHarness, store: &crate::context_bootstrap::NativeDragDataStore, @@ -26,6 +27,7 @@ fn install_transfer_view_for_test( .unwrap(); } +#[cfg(feature = "devtools")] fn finish_transfer_view_for_test(vm: &mut StandaloneScriptVmHarness, name: &str) -> String { vm.with_default_context_scope_and_checkpoint_for_test(|scope, _| { let global = scope.get_current_context().global(scope); @@ -39,6 +41,7 @@ fn finish_transfer_view_for_test(vm: &mut StandaloneScriptVmHarness, name: &str) .unwrap() } +#[cfg(feature = "devtools")] #[test] fn native_drag_store_initialization_is_distinct_from_external_all_mask() { use crate::context_bootstrap::DragDataStoreMode; @@ -86,6 +89,7 @@ fn native_drag_store_initialization_is_distinct_from_external_all_mask() { r#"["uninitialized","none","all","none"]"#); } +#[cfg(feature = "devtools")] #[test] fn native_drag_store_views_gate_access_without_reviving_retained_items() { use crate::context_bootstrap::DragDataStoreMode; @@ -192,6 +196,7 @@ fn native_drag_store_views_gate_access_without_reviving_retained_items() { finish_transfer_view_for_test(&mut vm, "nextTransfer"); } +#[cfg(feature = "devtools")] #[test] fn native_drag_payload_replacement_preserves_store_and_isolates_event_views() { use crate::context_bootstrap::DragDataStoreMode; @@ -290,6 +295,7 @@ fn native_drag_payload_replacement_preserves_store_and_isolates_event_views() { finish_transfer_view_for_test(&mut vm, "emptyTransfer"); } +#[cfg(feature = "devtools")] #[test] fn drop_default_actions_do_not_expose_private_views_to_author_readers() { use crate::runtime::{RendererDragData, RendererDragDataItem, RendererDraggedFile}; @@ -637,6 +643,7 @@ fn input_files_nullable_setter_preserves_current_file_list() { assert_eq!(result, "note.txt|note.txt|TypeError|TypeError"); } +#[cfg(feature = "devtools")] #[test] fn input_file_list_cache_refreshes_after_external_file_selection_replacement() { let mut vm = new_storage_test_vm("https://input-files-external-replace.test/"); @@ -1000,6 +1007,7 @@ fn data_transfer_declared_slots_ignore_prototype_spoofing() { ); } +#[cfg(feature = "devtools")] #[test] fn data_transfer_directory_entries_use_private_slots_for_reflection_and_spoofing() { use crate::runtime::{RendererDragData, RendererDraggedDirectory, RendererDraggedFile}; @@ -1442,6 +1450,7 @@ fn data_transfer_file_list_reference_tracks_item_mutations() { assert_eq!(result, "true:2:true:true|true:1:true:true:true"); } +#[cfg(feature = "devtools")] #[test] fn mouse_dragstart_bubbles_to_window_once() { let mut vm = new_rendered_test_vm( diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/file_input.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/file_input.rs index db8e5557b70..f54a29530bb 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/file_input.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/file_input.rs @@ -182,6 +182,7 @@ fn input_files_accessors_reject_incompatible_receivers() { assert_eq!(result, "ok"); } +#[cfg(feature = "devtools")] #[test] fn directory_selected_files_keep_relative_paths_in_wrappers_clones_and_file_lists() { let mut vm = new_parsed_test_vm( diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/file_input/state_styles.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/file_input/state_styles.rs index 6dd620430cc..48904fcd78b 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/file_input/state_styles.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/file_input/state_styles.rs @@ -122,6 +122,7 @@ fn input_files_web_assignment_refreshes_held_validity_style_in_the_same_call() { } } +#[cfg(feature = "devtools")] #[test] fn input_files_native_commit_refreshes_style_before_input_and_change_callbacks() { for policy in [LayoutPolicy::Mock, LayoutPolicy::OnDemand] { diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms.rs index 4acabca303f..d2848991ea0 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms.rs @@ -3823,6 +3823,7 @@ fn anchor_top_and_parent_targets_queue_plain_top_level_navigation() { ); } } +#[cfg(feature = "devtools")] #[test] fn anchor_download_click_returns_pending_download_without_navigation() { let mut vm = new_parsed_test_vm( @@ -3889,6 +3890,7 @@ fn anchor_download_synthetic_click_records_pending_download_without_navigation() ); } +#[cfg(feature = "devtools")] #[test] fn trusted_alt_click_downloads_an_anchor_without_a_download_attribute() { let mut vm = new_rendered_test_vm( @@ -3946,6 +3948,7 @@ fn trusted_alt_click_downloads_an_anchor_without_a_download_attribute() { assert!(vm.take_pending_popup_activations().is_empty()); } +#[cfg(feature = "devtools")] #[test] fn alt_input_does_not_turn_window_open_into_a_download_or_background_popup() { let mut vm = new_storage_test_vm("https://alt-window-open.test/path/index.html"); @@ -4005,6 +4008,7 @@ fn alt_input_does_not_turn_window_open_into_a_download_or_background_popup() { ); } +#[cfg(feature = "devtools")] #[test] fn window_open_in_click_listener_uses_current_input_event() { #[cfg(target_os = "macos")] @@ -4106,6 +4110,7 @@ fn window_open_in_click_listener_uses_current_input_event() { ); } +#[cfg(feature = "devtools")] #[test] fn current_mouseup_input_covers_pointer_mouse_click_and_microtask_callbacks() { #[cfg(target_os = "macos")] @@ -4199,6 +4204,7 @@ fn current_mouseup_input_covers_pointer_mouse_click_and_microtask_callbacks() { ); } +#[cfg(feature = "devtools")] #[test] fn middle_auxclick_runs_the_anchor_default_action_in_the_background() { let mut vm = new_storage_test_vm("https://middle-auxclick.test/path/index.html"); @@ -4252,6 +4258,7 @@ fn middle_auxclick_runs_the_anchor_default_action_in_the_background() { assert!(vm.take_pending_location_navigation_with_seed().is_none()); } +#[cfg(feature = "devtools")] #[test] fn canceling_middle_auxclick_suppresses_the_anchor_default_action() { let mut vm = new_storage_test_vm("https://middle-auxclick-canceled.test/path/index.html"); @@ -4282,6 +4289,7 @@ fn canceling_middle_auxclick_suppresses_the_anchor_default_action() { assert!(vm.take_pending_location_navigation_with_seed().is_none()); } +#[cfg(feature = "devtools")] #[test] fn enter_key_window_open_inherits_the_real_input_modifiers() { #[cfg(target_os = "macos")] @@ -4322,6 +4330,7 @@ fn enter_key_window_open_inherits_the_real_input_modifiers() { ); } +#[cfg(feature = "devtools")] #[test] fn keyboard_activation_click_preserves_modifiers() { let mut vm = new_parsed_test_vm( @@ -4395,6 +4404,7 @@ fn keyboard_activation_click_preserves_modifiers() { ); } +#[cfg(feature = "devtools")] #[test] fn image_submit_click_coordinates_use_live_layout_geometry() { let mut vm = new_rendered_test_vm( @@ -4443,6 +4453,7 @@ form.addEventListener('submit', event => { assert_eq!(entries, r#"[["photo.x","25"],["photo.y","19"]]"#); } +#[cfg(feature = "devtools")] #[test] fn button_click_listener_window_open_self_reports_top_level_navigation() { let mut vm = new_rendered_test_vm( @@ -4550,6 +4561,7 @@ anchor.click(); assert_eq!(result, "false:push|"); } +#[cfg(feature = "devtools")] #[test] fn file_input_click_returns_pending_file_chooser_activation() { const FILE_INPUT_HIT_X: f64 = 20.0; @@ -4697,6 +4709,7 @@ picker.click(); } } +#[cfg(feature = "devtools")] #[test] fn webdriver_bidi_file_prompt_handler_dispatches_trusted_cancel_without_pending_chooser() { let mut vm = new_parsed_test_vm( @@ -4743,6 +4756,7 @@ fn webdriver_bidi_file_prompt_handler_dispatches_trusted_cancel_without_pending_ ); } +#[cfg(feature = "devtools")] #[test] fn label_click_for_file_input_returns_pending_file_chooser_activation() { const LABEL_HIT_X: f64 = 20.0; @@ -4897,6 +4911,7 @@ async fn summary_activation_toggles_details_and_queues_toggle_event() { assert_eq!(result, "closed:open:true"); } +#[cfg(feature = "devtools")] #[test] fn pointer_click_enters_shadow_root_for_label_activation() { const LABEL_HIT_X: f64 = 10.0; @@ -4984,6 +4999,7 @@ fn submit_button_click_queues_pending_top_level_location_navigation() { ); } +#[cfg(feature = "devtools")] #[test] fn enter_implicitly_submits_single_search_input_without_a_submit_button() { let mut vm = new_parsed_test_vm( @@ -5026,6 +5042,7 @@ document.getElementById('query').focus(); ); } +#[cfg(feature = "devtools")] #[test] fn enter_implicitly_clicks_the_default_submit_button() { let mut vm = new_parsed_test_vm( @@ -5072,6 +5089,7 @@ document.getElementById('query').focus(); ); } +#[cfg(feature = "devtools")] #[test] fn enter_does_not_implicitly_submit_multiple_blocking_inputs_without_a_submit_button() { let mut vm = new_parsed_test_vm( @@ -5106,6 +5124,7 @@ document.getElementById('query').focus(); assert!(vm.take_pending_location_navigation_with_seed().is_none()); } +#[cfg(feature = "devtools")] #[test] fn canceling_an_implicit_submit_event_prevents_navigation() { let mut vm = new_parsed_test_vm( @@ -5142,6 +5161,7 @@ document.getElementById('query').focus(); assert!(vm.take_pending_location_navigation_with_seed().is_none()); } +#[cfg(feature = "devtools")] #[test] fn disabled_default_submit_button_suppresses_implicit_submission() { let mut vm = new_parsed_test_vm( @@ -5175,6 +5195,7 @@ document.getElementById('query').focus(); assert!(vm.take_pending_location_navigation_with_seed().is_none()); } +#[cfg(feature = "devtools")] #[test] fn external_form_owned_submit_button_participates_in_document_tree_order() { let mut vm = new_parsed_test_vm( @@ -5215,6 +5236,7 @@ document.getElementById('query').focus(); assert!(vm.take_pending_location_navigation_with_seed().is_none()); } +#[cfg(feature = "devtools")] #[test] fn image_input_is_the_default_submit_button_and_serializes_click_coordinates() { let mut vm = new_parsed_test_vm( @@ -5258,6 +5280,7 @@ document.getElementById('query').focus(); ); } +#[cfg(feature = "devtools")] #[test] fn raw_keydown_waits_for_the_character_phase_before_implicit_submission() { let mut vm = new_parsed_test_vm( @@ -5294,6 +5317,7 @@ document.getElementById('query').focus(); assert!(vm.take_pending_location_navigation_with_seed().is_none()); } +#[cfg(feature = "devtools")] #[test] fn canceling_keydown_or_keypress_prevents_implicit_submission() { for canceled_event in ["keydown", "keypress"] { @@ -5325,6 +5349,7 @@ query.focus(); } } +#[cfg(feature = "devtools")] #[test] fn enter_beforeinput_precedes_implicit_submission_and_can_cancel_it() { for with_button in [false, true] { @@ -5409,6 +5434,7 @@ query.focus(); } } +#[cfg(feature = "devtools")] #[test] fn canceled_raw_keydown_suppresses_only_its_following_implicit_submit_char_phase() { let mut vm = new_parsed_test_vm( @@ -5456,6 +5482,7 @@ query.focus(); assert!(vm.take_pending_location_navigation_with_seed().is_none()); } +#[cfg(feature = "devtools")] #[test] fn implicit_submission_runs_constraint_validation() { let mut vm = new_parsed_test_vm( @@ -5487,6 +5514,7 @@ document.getElementById('query').focus(); assert!(vm.take_pending_location_navigation_with_seed().is_none()); } +#[cfg(feature = "devtools")] #[test] fn textarea_enter_inserts_one_newline_during_the_character_phase_without_submitting() { let mut vm = new_parsed_test_vm( @@ -5522,6 +5550,7 @@ editor.setSelectionRange(1, 1); assert!(vm.take_pending_location_navigation_with_seed().is_none()); } +#[cfg(feature = "devtools")] #[test] fn carriage_return_in_character_text_preserves_text_without_implicit_submission() { for (control, expected_value) in [ @@ -5582,6 +5611,7 @@ editor.focus(); } } +#[cfg(feature = "devtools")] #[test] fn standalone_carriage_return_character_preserves_enter_default_actions() { for (control, expected_value, expected_submit_count) in [ diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/blob_download.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/blob_download.rs index 584d6247e17..129bcaa27d0 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/blob_download.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/blob_download.rs @@ -132,6 +132,7 @@ async fn blob_download_authorizes_the_initiating_document_storage_key_and_partit } } +#[cfg(feature = "devtools")] #[test] fn keyboard_blob_download_retains_the_backing_before_revocation() { let mut vm = new_parsed_test_vm( diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/dialog.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/dialog.rs index b99198b96b1..40119a83926 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/dialog.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/dialog.rs @@ -2,6 +2,7 @@ use super::*; // Match the real-input Chromium probe: Escape itself does not grant history // activation, so establish it with an ordinary trusted key first. +#[cfg(feature = "devtools")] fn press_dialog_escape(vm: &mut ScriptVm) { for (event, key, code) in [ ("keydown", "a", "KeyA"), @@ -236,6 +237,7 @@ fn dialog_form_submission_distinguishes_absent_and_empty_submitter_values() { ); } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_keydown_light_dismisses_modal_dialog() { let mut vm = new_storage_test_vm("https://dialog-escape-modal.test/"); @@ -283,6 +285,7 @@ fn dialog_escape_keydown_light_dismisses_modal_dialog() { ); } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_keydown_respects_prevent_default() { let mut vm = new_storage_test_vm("https://dialog-escape-prevent-default.test/"); @@ -345,6 +348,7 @@ fn dialog_escape_keydown_respects_prevent_default() { ); } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_keydown_does_not_close_non_modal_dialog() { let mut vm = new_storage_test_vm("https://dialog-escape-non-modal.test/"); @@ -377,6 +381,7 @@ fn dialog_escape_keydown_does_not_close_non_modal_dialog() { ); } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_follows_modal_open_order() { for (options, expected) in [ @@ -425,6 +430,7 @@ fn dialog_escape_follows_modal_open_order() { } } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_cancellation_preserves_modal_order() { let mut vm = new_storage_test_vm("https://dialog-cancel-modal-order.test/"); @@ -457,6 +463,7 @@ fn dialog_escape_cancellation_preserves_modal_order() { } } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_is_scoped_to_keyboard_dispatch_document() { for owner in 0..2 { @@ -498,6 +505,7 @@ for (let i = 0; i < realms.length; i++) { } } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_untrusted_keydown_keeps_modal_order() { let mut vm = new_storage_test_vm("https://dialog-untrusted-escape.test/"); @@ -520,6 +528,7 @@ fn dialog_escape_untrusted_keydown_keeps_modal_order() { ); } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_uses_internal_keyboard_key() { for replace_prototype in [false, true] { @@ -555,6 +564,7 @@ document.addEventListener('keydown', event => {{ } } +#[cfg(feature = "devtools")] #[tokio::test] async fn dialog_escape_cancel_reentry_is_bound_to_original_opening() { for (action, expected, queues_close) in [ @@ -634,6 +644,7 @@ dialogProbe.dialogs.first.addEventListener('cancel', () => {{ } } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_after_adoption_uses_destination_registration() { for explicit_removal in [false, true] { @@ -660,6 +671,7 @@ dialog.querySelector('button').focus(); } } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_after_atomic_move_keeps_original_opening_order() { let mut vm = new_storage_test_vm("https://dialog-escape-atomic-move.test/"); @@ -687,6 +699,7 @@ dialogProbe.dialogs.second.querySelector('button').focus(); ); } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_respects_closedby_policy() { for (attribute, expected_open) in [ @@ -721,6 +734,7 @@ if (closedby !== null) dialogProbe.dialogs.first.setAttribute('closedby', closed } } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_rechecks_closedby_after_keyboard_and_cancel_listeners() { for (event, initial, action, expected_open, expected_cancels) in [ @@ -761,6 +775,7 @@ target.addEventListener('{event}', () => dialog.{action}); } } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_closedby_ignores_namespaced_attributes() { for (on_cancel, policy, expected_open) in [ @@ -815,6 +830,7 @@ else setPolicy(); } } +#[cfg(feature = "devtools")] #[test] fn dialog_escape_does_not_bypass_top_modal_closedby_none() { // This covers the current modal-only close-request selection. Chromium can diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/event_activation.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/event_activation.rs index 143a2c93b5f..ed058ce5c59 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/event_activation.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/event_activation.rs @@ -1,5 +1,6 @@ use super::*; +#[cfg(feature = "devtools")] #[test] fn script_control_click_preserves_focus_and_pending_text_commit() { for dispatch in [false, true] { @@ -113,6 +114,7 @@ return JSON.stringify({{active:document.activeElement.id, checked:check.checked, } } +#[cfg(feature = "devtools")] #[test] fn pointer_release_does_not_reapply_canceled_mouse_focus() { for canceled_event in ["none", "mousedown", "pointerdown"] { diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/select_state_styles.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/select_state_styles.rs index 4bc5b424dcd..581fedb9c21 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/select_state_styles.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/forms/select_state_styles.rs @@ -201,6 +201,7 @@ fn selection_changes_refresh_required_select_and_container_validity_styles() { ); } +#[cfg(feature = "devtools")] #[test] fn select_autofill_refreshes_selected_peer_and_has_styles_before_callbacks() { for policy in [LayoutPolicy::Mock, LayoutPolicy::OnDemand] { diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/misc.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/misc.rs index a09f6a49e61..39b828de409 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/misc.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/misc.rs @@ -629,6 +629,7 @@ fn detached_document_shadow_root_inner_html_setter_updates_query_surface() { assert_eq!(result, "1|shadow"); } +#[cfg(feature = "devtools")] #[test] fn child_document_content_type_uses_resource_mime() { let mut vm = new_storage_test_vm("https://child-content-type.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/mod.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/mod.rs index eae0070fb45..532d7434846 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/mod.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/mod.rs @@ -10,6 +10,7 @@ mod data_response; mod dom; mod file_input; mod forms; +#[cfg(feature = "devtools")] mod interception_route; mod json_response; mod misc; diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/style_invalidation.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/style_invalidation.rs index a8f8b717389..f94ac043788 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/style_invalidation.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/style_invalidation.rs @@ -68,6 +68,7 @@ fn dom_content_loaded_page_task_drains_pending_style_invalidations_after_listene assert_eq!(resolved, "rgb(30, 40, 50)"); } +#[cfg(feature = "devtools")] #[test] fn style_element_text_mutations_cache_owner_stylesheet_text() { let mut vm = new_storage_test_vm("https://style-text-cache.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/element_click.rs b/moli-renderer-v8/src/script_vm/tests/element_click.rs index 1ebfa41bcf4..1a0a1469543 100644 --- a/moli-renderer-v8/src/script_vm/tests/element_click.rs +++ b/moli-renderer-v8/src/script_vm/tests/element_click.rs @@ -1,6 +1,7 @@ use super::*; use crate::runtime::{RendererElementClickTarget, RendererPointerEventProperties}; +#[cfg(feature = "devtools")] #[test] fn native_element_click_initializes_layout_once() { let mut vm = new_parsed_test_vm( @@ -18,6 +19,7 @@ fn native_element_click_initializes_layout_once() { } } +#[cfg(feature = "devtools")] #[test] fn native_element_click_reuses_frozen_layout_after_dom_and_style_changes() { for mutation in [ @@ -102,6 +104,7 @@ fn native_element_click_reuses_frozen_layout_after_dom_and_style_changes() { } } +#[cfg(feature = "devtools")] #[test] fn native_element_click_mock_preparation_does_not_build_layout() { let mut vm = new_parsed_test_vm( @@ -118,6 +121,7 @@ fn native_element_click_mock_preparation_does_not_build_layout() { assert_eq!(vm.layout_pass_observability_for_test().1, before); } +#[cfg(feature = "devtools")] #[test] fn native_element_click_does_not_publish_after_scrolling_an_offscreen_target() { let mut vm = new_rendered_test_vm( diff --git a/moli-renderer-v8/src/script_vm/tests/extracted/page_runtime.rs b/moli-renderer-v8/src/script_vm/tests/extracted/page_runtime.rs index 86b4d15f1e5..34247434b47 100644 --- a/moli-renderer-v8/src/script_vm/tests/extracted/page_runtime.rs +++ b/moli-renderer-v8/src/script_vm/tests/extracted/page_runtime.rs @@ -848,6 +848,7 @@ async fn child_detach_retires_document_modulator_at_owner_boundary() { "detach transition must retire ScriptVm modulator state at the enclosing owner boundary" ); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn runtime_protocol_retains_connected_style_event_bodies_without_numeric_termination() { const STYLE_COUNT: usize = 129; diff --git a/moli-renderer-v8/src/script_vm/tests/extracted/realms_and_teardown.rs b/moli-renderer-v8/src/script_vm/tests/extracted/realms_and_teardown.rs index 9b6560dcae1..6f547bee6b7 100644 --- a/moli-renderer-v8/src/script_vm/tests/extracted/realms_and_teardown.rs +++ b/moli-renderer-v8/src/script_vm/tests/extracted/realms_and_teardown.rs @@ -1494,6 +1494,7 @@ fn runtime_binding_calls_freeze_the_invoking_realm_generation() { ); assert_ne!(calls[0].execution_context_id, calls[1].execution_context_id); } +#[cfg(feature = "devtools")] #[tokio::test] async fn opaque_child_isolated_world_projects_only_its_own_document() { let mut vm = new_storage_test_vm("https://opaque-child-isolated-world.test/"); @@ -1610,6 +1611,7 @@ async fn opaque_child_isolated_world_projects_only_its_own_document() { "isolated child navigator.storage must use the child opaque storage owner" ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn initial_empty_child_isolated_world_rebinds_committed_document() { let mut vm = new_storage_test_vm("https://initial-empty-isolated-world.test/"); @@ -3201,6 +3203,7 @@ fn inspector_context_created_matches_same_name_child_isolated_world_by_frame_id( ); assert_eq!(vm.page_isolated_world_contexts.len(), 2); } +#[cfg(feature = "devtools")] #[test] fn same_name_isolated_worlds_are_scoped_to_devtools_session_and_detach() { let mut vm = new_storage_test_vm("https://isolated-world-session.test/"); @@ -3400,6 +3403,7 @@ async fn commit_opaque_child_for_test(vm: &mut StandaloneScriptVmHarness, elemen .unwrap_or_else(|| panic!("{element_id}: opaque child realm should exist")) } +#[cfg(feature = "devtools")] fn child_context_weak_for_test( vm: &mut StandaloneScriptVmHarness, context_id: i64, @@ -3430,6 +3434,7 @@ fn context_weak_was_collected_for_test( .expect("parent context should remain usable") } +#[cfg(feature = "devtools")] fn expose_real_top_window_for_test(vm: &mut StandaloneScriptVmHarness, context_id: i64) { // Exercise the native access-check handlers on the actual top WindowProxy. vm.with_child_frame_realm_context_scope(context_id, |scope, host_ptr| { @@ -3449,6 +3454,7 @@ fn expose_real_top_window_for_test(vm: &mut StandaloneScriptVmHarness, context_i .expect("real top Window should be reachable from the opaque child"); } +#[cfg(feature = "devtools")] #[tokio::test] async fn borrowed_cross_origin_window_accessors_follow_the_receiver() { let mut vm = new_storage_test_vm("https://cross-origin-window-receiver.test/"); @@ -3498,6 +3504,7 @@ async fn borrowed_cross_origin_window_accessors_follow_the_receiver() { ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn native_cross_origin_bindings_release_removed_accessor_realm() { let mut vm = new_storage_test_vm("https://cross-origin-surface-cache.test/"); @@ -3561,6 +3568,7 @@ document.getElementById("accessor-frame").remove(); ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn native_cross_origin_bindings_ignore_author_weak_map_overrides() { let mut vm = new_storage_test_vm("https://cross-origin-cache-intrinsics.test/"); @@ -3619,6 +3627,7 @@ Object.getPrototypeOf(savedPostMessage) === Function.prototype ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn cross_origin_window_keys_follow_frame_removal() { let mut vm = new_storage_test_vm("https://cross-origin-window-keys.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/extracted/script_execution.rs b/moli-renderer-v8/src/script_vm/tests/extracted/script_execution.rs index 4d1d30c6c87..59c99bcb6f6 100644 --- a/moli-renderer-v8/src/script_vm/tests/extracted/script_execution.rs +++ b/moli-renderer-v8/src/script_vm/tests/extracted/script_execution.rs @@ -159,6 +159,7 @@ fn microtask_checkpoint_watchdog_terminates_runaway_queue_and_recovers_isolate() "4" ); } +#[cfg(feature = "devtools")] #[test] fn runtime_await_promise_sync_result_survives_queued_allocation_gc() { let mut vm = new_parsed_test_vm( diff --git a/moli-renderer-v8/src/script_vm/tests/frame_element_security.rs b/moli-renderer-v8/src/script_vm/tests/frame_element_security.rs index f86ae6d28bc..9b5616aeb11 100644 --- a/moli-renderer-v8/src/script_vm/tests/frame_element_security.rs +++ b/moli-renderer-v8/src/script_vm/tests/frame_element_security.rs @@ -54,6 +54,7 @@ globalThis.__frameElementResult = null; assert_eq!(server.finish_targets().await, vec!["/child.html"; 6]); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn frame_element_uses_the_isolated_world_access_policy() { for cross_origin in [false, true] { diff --git a/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces.rs b/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces.rs index bd8ab5d6070..6efdb7d3eaf 100644 --- a/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces.rs +++ b/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces.rs @@ -91,6 +91,7 @@ fn default_trusted_types_materialized(vm: &mut ScriptVm) -> bool { .expect("Trusted Types lazy-state diagnostics") } +#[cfg(feature = "devtools")] #[test] fn child_default_and_isolated_bootstrap_keep_expensive_window_surfaces_lazy() { let mut vm = new_storage_test_vm("https://lazy-window-bootstrap.test/"); @@ -1029,6 +1030,7 @@ fn performance_clock_access_keeps_nested_state_lazy_until_its_own_api_is_used() ); } +#[cfg(feature = "devtools")] #[test] fn child_isolated_world_materializes_realm_local_wrappers_only_on_access() { let mut vm = new_storage_test_vm("https://lazy-window-isolated.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces/rebind.rs b/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces/rebind.rs index 24259b3c02b..169a02cb991 100644 --- a/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces/rebind.rs +++ b/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces/rebind.rs @@ -1,5 +1,6 @@ use super::*; +#[cfg(feature = "devtools")] #[tokio::test] async fn initial_about_blank_rebind_keeps_child_window_surfaces_lazy() { let mut vm = new_storage_test_vm("https://lazy-window-rebind.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces/seeds.rs b/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces/seeds.rs index 0929a9978c0..825d6137d0b 100644 --- a/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces/seeds.rs +++ b/moli-renderer-v8/src/script_vm/tests/lazy_window_surfaces/seeds.rs @@ -112,6 +112,7 @@ async fn navigator_identity_seed_keeps_window_metadata_and_network_profile_coher ); } +#[cfg(feature = "devtools")] #[test] fn child_default_and_isolated_navigator_materialize_from_the_loader_seed() { const USER_AGENT: &str = "Moli-Lazy-Child-Navigator/1.0"; diff --git a/moli-renderer-v8/src/script_vm/tests/mod.rs b/moli-renderer-v8/src/script_vm/tests/mod.rs index 824c1ede5d7..3c294e8a939 100644 --- a/moli-renderer-v8/src/script_vm/tests/mod.rs +++ b/moli-renderer-v8/src/script_vm/tests/mod.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "devtools")] mod baseline_drag_views; mod beforeinput_target_validation; mod fetch_cache_modes; @@ -6,20 +7,27 @@ mod selection_worlds; mod child_document_web_fonts; mod credential_container; mod credential_json_options; +#[cfg(feature = "devtools")] mod cross_document_drag_events; mod cross_origin_navigation; mod current_pass_css_fonts; mod document_encodings; mod document_location_activity; +#[cfg(feature = "devtools")] mod drag_drop_outcomes; mod idb_transaction_gc; mod message_port_transfer; +#[cfg(feature = "devtools")] mod native_drag_payloads; +#[cfg(feature = "devtools")] mod native_drag_pointer_coordinates; +#[cfg(feature = "devtools")] mod native_drag_pointer_suppression; +#[cfg(feature = "devtools")] mod native_drag_source_events; mod picture_in_picture_interfaces; mod touch_native_receivers; +#[cfg(feature = "devtools")] mod touch_snapshot; mod visual_viewport_receiver; mod writable_stream_native_receivers; @@ -2299,6 +2307,7 @@ mod svg_matrix_native_receivers; mod lazy_window_surfaces; mod midi_owner_interfaces; +#[cfg(feature = "devtools")] mod mouse_snapshot; mod multipart_encoding; mod native_bridge_identity; @@ -2397,6 +2406,7 @@ mod window_immutable_prototype_chain; mod window_getter_consolidation; mod window_node_events; +#[cfg(feature = "devtools")] mod window_node_worlds; mod window_receiver_access; mod worklet_interfaces; diff --git a/moli-renderer-v8/src/script_vm/tests/mouse_snapshot.rs b/moli-renderer-v8/src/script_vm/tests/mouse_snapshot.rs index 0fce9dc55e6..de2a8cc2968 100644 --- a/moli-renderer-v8/src/script_vm/tests/mouse_snapshot.rs +++ b/moli-renderer-v8/src/script_vm/tests/mouse_snapshot.rs @@ -1,6 +1,7 @@ use super::*; use crate::RendererInputDispatchOutcome; +#[cfg(feature = "devtools")] fn mouse( vm: &mut StandaloneScriptVmHarness, event: &str, @@ -158,6 +159,7 @@ fn mouse_handler_geometry_reads_reuse_the_published_snapshot() { assert_eq!(vm.layout_pass_observability_for_test().1, before); } +#[cfg(feature = "devtools")] #[test] fn mouse_wheel_updates_scroll_without_refreshing_the_rendered_world() { let mut vm = new_parsed_test_vm( diff --git a/moli-renderer-v8/src/script_vm/tests/native_node_event_outcomes.rs b/moli-renderer-v8/src/script_vm/tests/native_node_event_outcomes.rs index b69514abeed..1218b8e2ebb 100644 --- a/moli-renderer-v8/src/script_vm/tests/native_node_event_outcomes.rs +++ b/moli-renderer-v8/src/script_vm/tests/native_node_event_outcomes.rs @@ -1,13 +1,22 @@ -use super::window_node_worlds::child_node_world; use super::*; +pub(super) async fn attach_child_target(vm: &mut ScriptVm) { + vm.eval( + "globalThis.frame=document.createElement('iframe');\ + frame.srcdoc='child';\ + (document.body||document.documentElement||document).appendChild(frame);'ready'", + ) + .unwrap(); + run_child_navigation_commit_and_host_load_for_test(vm, "child Node target").await; +} + pub(super) async fn native_outcome_vm( policy: moli_page_types::LayoutPolicy, ) -> StandaloneScriptVmHarness { let mut vm = new_storage_test_vm("https://native-node-outcomes.test/"); vm.set_layout_policy(policy); vm.eval("if(!document.body){const root=document.documentElement||document.appendChild(document.createElement('html'));root.appendChild(document.createElement('body'));}'ready'").unwrap(); - child_node_world(&mut vm, "native-node-outcomes").await; + attach_child_target(&mut vm).await; vm } diff --git a/moli-renderer-v8/src/script_vm/tests/selection_worlds.rs b/moli-renderer-v8/src/script_vm/tests/selection_worlds.rs index 826b6cbf04c..f5d25d448b4 100644 --- a/moli-renderer-v8/src/script_vm/tests/selection_worlds.rs +++ b/moli-renderer-v8/src/script_vm/tests/selection_worlds.rs @@ -115,6 +115,7 @@ fn selection_worlds_share_live_ranges_with_local_wrappers() { } } +#[cfg(feature = "devtools")] #[tokio::test] async fn selection_worlds_keep_child_documents_independent() { let mut vm = new_storage_html_test_vm("https://selection-child-worlds.test/"); @@ -143,6 +144,7 @@ async fn selection_worlds_keep_child_documents_independent() { ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn selection_worlds_native_input_uses_the_focused_child_document() { let mut vm = new_storage_html_test_vm("https://selection-child-input.test/"); @@ -192,6 +194,7 @@ async fn selection_worlds_native_input_uses_the_focused_child_document() { ); } +#[cfg(feature = "devtools")] #[tokio::test] async fn selection_worlds_rebind_initial_child_document_together() { let mut vm = new_storage_html_test_vm("https://selection-worlds-rebind.test/"); diff --git a/moli-renderer-v8/src/script_vm/tests/window_execution_context.rs b/moli-renderer-v8/src/script_vm/tests/window_execution_context.rs index 172a2b09d10..6598d3b99b8 100644 --- a/moli-renderer-v8/src/script_vm/tests/window_execution_context.rs +++ b/moli-renderer-v8/src/script_vm/tests/window_execution_context.rs @@ -113,6 +113,7 @@ async fn assert_document_retains_window_identity_after_close(replacement: bool) } } +#[cfg(feature = "devtools")] #[test] fn strict_window_binding_resolves_registry_policy_and_rejects_retired_realm() { let mut vm = new_storage_test_vm("https://strict-window-binding.test/"); @@ -1006,6 +1007,7 @@ fn isolated_window_world_for_test( .expect("isolated wrapper-world identity") } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn isolated_window_world_ids_reuse_names_across_frames_but_separate_isolates() { for policy in [ @@ -1172,6 +1174,7 @@ fn inherited_isolated_world_identity_does_not_authorize_an_unregistered_context( .unwrap(); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn foreign_window_callbacks_use_the_target_context_in_the_listener_world() { for policy in [ @@ -1281,6 +1284,7 @@ async fn foreign_window_callbacks_use_the_target_context_in_the_listener_world() } } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn implicit_window_world_members_retire_independently_and_release_the_host() { for policy in [ @@ -1421,6 +1425,7 @@ fn failed_target_window_world_bootstrap_does_not_publish_a_partial_realm() { ); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn isolated_window_proxies_follow_child_navigation_in_surviving_worlds() { for policy in [ @@ -1634,6 +1639,7 @@ async fn isolated_proxy_navigation_rechecks_origin_and_universal_access() { } } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn closed_isolated_session_proxies_are_not_restored_by_navigation() { let mut vm = new_storage_test_vm("https://isolated-proxy-session.test/"); @@ -1718,6 +1724,7 @@ fn reused_isolated_proxy_recovers_after_bootstrap_fails_after_attachment() { assert!(weak.upgrade().is_none()); } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn named_inspector_world_promotes_implicit_members_within_its_session() { for policy in [ @@ -1801,6 +1808,7 @@ async fn named_inspector_world_promotes_implicit_members_within_its_session() { } } +#[cfg(feature = "devtools")] #[test] fn renderer_output_settlement_records_contexts_without_materializing_ordinary_messages() { use crate::runtime::{ diff --git a/moli-renderer-v8/src/script_vm/tests/window_node_events.rs b/moli-renderer-v8/src/script_vm/tests/window_node_events.rs index 7ae20b2b2c1..503d2f5343f 100644 --- a/moli-renderer-v8/src/script_vm/tests/window_node_events.rs +++ b/moli-renderer-v8/src/script_vm/tests/window_node_events.rs @@ -1,6 +1,8 @@ +#[cfg(feature = "devtools")] use super::window_node_worlds::child_node_world; use super::*; +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn isolated_node_events_project_receivers_targets_and_share_dispatch_state() { for policy in [ @@ -65,6 +67,7 @@ async fn isolated_node_events_project_receivers_targets_and_share_dispatch_state } } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn adopted_node_events_use_current_document_window_in_the_listener_world() { for policy in [ @@ -99,6 +102,7 @@ async fn adopted_node_events_use_current_document_window_in_the_listener_world() } } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn inert_document_factories_preserve_native_execution_context_for_node_events() { for policy in [ @@ -193,6 +197,7 @@ fn template_owner_document_clones_inherit_execution_context() { } } +#[cfg(feature = "devtools")] #[tokio::test(flavor = "current_thread")] async fn retired_frame_nodes_and_inert_factories_distinguish_execution_context_presence() { for policy in [ diff --git a/moli-renderer-v8/src/script_vm/tests/window_node_worlds.rs b/moli-renderer-v8/src/script_vm/tests/window_node_worlds.rs index 386b5599a7e..e51644243b6 100644 --- a/moli-renderer-v8/src/script_vm/tests/window_node_worlds.rs +++ b/moli-renderer-v8/src/script_vm/tests/window_node_worlds.rs @@ -1,13 +1,7 @@ use super::*; pub(super) async fn child_node_world(vm: &mut ScriptVm, name: &str) -> i64 { - vm.eval( - "globalThis.frame=document.createElement('iframe');\ - frame.srcdoc='child';\ - (document.body||document.documentElement||document).appendChild(frame);'ready'", - ) - .unwrap(); - run_child_navigation_commit_and_host_load_for_test(vm, "child Node world").await; + super::native_node_event_outcomes::attach_child_target(vm).await; let frame_id = vm .live_child_default_runtime_realm_inventory() .into_iter() diff --git a/moli-renderer-v8/src/script_vm/text_search.rs b/moli-renderer-v8/src/script_vm/text_search.rs index cb10d449455..113a692f43b 100644 --- a/moli-renderer-v8/src/script_vm/text_search.rs +++ b/moli-renderer-v8/src/script_vm/text_search.rs @@ -175,7 +175,7 @@ fn resource_urls_match(left: &str, right: &str) -> bool { } } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; diff --git a/moli-renderer-v8/src/service_worker_runtime/service/context_shutdown.rs b/moli-renderer-v8/src/service_worker_runtime/service/context_shutdown.rs index 67242e5dd91..2fbf49af141 100644 --- a/moli-renderer-v8/src/service_worker_runtime/service/context_shutdown.rs +++ b/moli-renderer-v8/src/service_worker_runtime/service/context_shutdown.rs @@ -18,8 +18,24 @@ impl ServiceWorkerRuntimeService { #[cfg(test)] pub(crate) fn stop_all_running_hosts_for_test(&self) { - self.devtools_stop_all_workers() - .expect("test host stop should use the production ServiceWorker retirement path"); + self.stop_running_workers("test_stop_all"); + } + + #[cfg(any(test, feature = "devtools"))] + pub(super) fn stop_running_workers(&self, reason: &'static str) -> usize { + let hosts = { + let mut state = self.inner.state.lock(); + let version_ids = state.versions.keys().copied().collect::>(); + version_ids + .into_iter() + .filter_map(|version_id| stop_worker_version_locked(&mut state, version_id, reason)) + .collect::>() + }; + let stopped_count = hosts.len(); + for host in hosts { + host.terminate_without_join(); + } + stopped_count } fn take_context_shutdown_work( @@ -93,6 +109,19 @@ impl ServiceWorkerRuntimeService { } } +#[cfg(any(test, feature = "devtools"))] +pub(super) fn stop_worker_version_locked( + state: &mut ServiceWorkerRuntimeState, + version_id: ServiceWorkerVersionId, + reason: &'static str, +) -> Option { + let version = state.versions.get_mut(&version_id)?; + let host = version.running_state.take_host_for_shutdown()?; + version.idle_timeout_token = None; + state.record_target_stopped(version_id, host.run_identity(), reason); + Some(host) +} + fn take_running_hosts_for_shutdown_locked( state: &mut ServiceWorkerRuntimeState, ) -> Vec { diff --git a/moli-renderer-v8/src/service_worker_runtime/service/devtools_commands.rs b/moli-renderer-v8/src/service_worker_runtime/service/devtools_commands.rs index 64300dc6623..7909381ecff 100644 --- a/moli-renderer-v8/src/service_worker_runtime/service/devtools_commands.rs +++ b/moli-renderer-v8/src/service_worker_runtime/service/devtools_commands.rs @@ -1,3 +1,4 @@ +use super::context_shutdown::stop_worker_version_locked; use super::*; impl ServiceWorkerRuntimeService { @@ -363,24 +364,7 @@ impl ServiceWorkerRuntimeService { } pub(crate) fn devtools_stop_all_workers(&self) -> Result { - let hosts = { - let mut state = self.inner.state.lock(); - let version_ids = state.versions.keys().copied().collect::>(); - let mut hosts = Vec::new(); - for version_id in version_ids { - if let Some(host) = - stop_worker_version_locked(&mut state, version_id, "devtools_stop_all") - { - hosts.push(host); - } - } - hosts - }; - let stopped_count = hosts.len(); - for host in hosts { - host.terminate_without_join(); - } - Ok(stopped_count) + Ok(self.stop_running_workers("devtools_stop_all")) } pub(crate) fn devtools_skip_waiting_for_scope(&self, scope_url: &Url) -> Result { @@ -662,18 +646,3 @@ fn active_registration_for_devtools_locked( registration.storage_key.clone(), )) } - -fn stop_worker_version_locked( - state: &mut ServiceWorkerRuntimeState, - version_id: ServiceWorkerVersionId, - reason: &'static str, -) -> Option { - let host = { - let version = state.versions.get_mut(&version_id)?; - let host = version.running_state.take_host_for_shutdown()?; - version.idle_timeout_token = None; - host - }; - state.record_target_stopped(version_id, host.run_identity(), reason); - Some(host) -} diff --git a/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/fetch_events.rs b/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/fetch_events.rs index 4cd43cf7e58..194b7a70fba 100644 --- a/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/fetch_events.rs +++ b/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/fetch_events.rs @@ -2542,6 +2542,7 @@ fn fetch_completion_schedules_idle_timeout_for_running_active_worker() { assert_eq!(completion.internal_id, 77); assert_eq!(completion.result.err().as_deref(), Some("handled")); } +#[cfg(feature = "devtools")] #[test] fn devtools_force_update_on_page_load_enqueues_update_for_controlled_page_load() { let service = new_service_worker_runtime_service(); diff --git a/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/registration_jobs.rs b/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/registration_jobs.rs index 9700066f8e3..509b76d7881 100644 --- a/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/registration_jobs.rs +++ b/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/registration_jobs.rs @@ -1020,6 +1020,7 @@ fn stored_registration_resources_use_serialized_storage_key() { ServiceWorkerRegistrationKey::storage_key_for_scope_url(&scope_url) ); } +#[cfg(feature = "devtools")] #[test] fn devtools_unregister_scope_uses_owner_unregistration_path() { let service = new_service_worker_runtime_service(); @@ -1063,6 +1064,7 @@ fn devtools_unregister_scope_uses_owner_unregistration_path() { "DevTools unregister should destroy the runtime-owned target: {target_events:?}" ); } +#[cfg(feature = "devtools")] #[test] fn devtools_update_registration_enters_existing_registration_job_queue() { let service = new_service_worker_runtime_service(); @@ -1107,6 +1109,7 @@ fn devtools_update_registration_enters_existing_registration_job_queue() { assert_eq!(diagnostics.queued_register_job_count, 1); assert!(!completion_queue.has_ready_task()); } +#[cfg(feature = "devtools")] #[test] fn devtools_functional_event_dispatch_uses_active_registration_owner() { let service = new_service_worker_runtime_service(); diff --git a/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/runtime_owners.rs b/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/runtime_owners.rs index d07b9758f35..b6038df9d3c 100644 --- a/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/runtime_owners.rs +++ b/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/runtime_owners.rs @@ -23,6 +23,7 @@ fn restored_launch_config_resolves_the_current_browser_resource_runtime() { ); assert!(!replacement_client.shares_resource_runtime_with(&first_client)); } +#[cfg(feature = "devtools")] #[test] fn devtools_pause_on_start_marks_non_released_launch_for_evaluation_pause() { let service = new_service_worker_runtime_service(); @@ -59,6 +60,7 @@ fn devtools_pause_on_start_marks_non_released_launch_for_evaluation_pause() { ); service.terminate_all_for_context_shutdown(); } +#[cfg(feature = "devtools")] #[test] fn devtools_pause_on_start_pauses_attached_stopped_worker_restart() { let service = new_service_worker_runtime_service(); @@ -94,6 +96,7 @@ fn devtools_pause_on_start_pauses_attached_stopped_worker_restart() { ); service.terminate_all_for_context_shutdown(); } +#[cfg(feature = "devtools")] #[test] fn devtools_pause_on_start_does_not_pause_unattached_stopped_worker_restart() { let service = new_service_worker_runtime_service(); @@ -128,6 +131,7 @@ fn devtools_pause_on_start_does_not_pause_unattached_stopped_worker_restart() { ); service.terminate_all_for_context_shutdown(); } +#[cfg(feature = "devtools")] #[test] fn devtools_pause_on_start_does_not_retroactively_pause_existing_stopped_worker() { let service = new_service_worker_runtime_service(); @@ -155,6 +159,7 @@ fn devtools_pause_on_start_does_not_retroactively_pause_existing_stopped_worker( ); service.terminate_all_for_context_shutdown(); } +#[cfg(feature = "devtools")] #[test] fn devtools_released_launch_does_not_double_pause_evaluation() { let service = new_service_worker_runtime_service(); @@ -182,6 +187,7 @@ fn devtools_released_launch_does_not_double_pause_evaluation() { ); service.terminate_all_for_context_shutdown(); } +#[cfg(feature = "devtools")] #[test] fn devtools_run_if_prereleases_starting_worker_evaluation_before_host_running() { let service = new_service_worker_runtime_service(); @@ -241,6 +247,7 @@ fn devtools_run_if_prereleases_starting_worker_evaluation_before_host_running() } service.terminate_all_for_context_shutdown(); } +#[cfg(feature = "devtools")] #[test] fn devtools_stop_worker_records_target_stopped() { let service = new_service_worker_runtime_service(); diff --git a/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/script_updates_and_storage.rs b/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/script_updates_and_storage.rs index e3c81e6dbf6..b38954f50f9 100644 --- a/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/script_updates_and_storage.rs +++ b/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/script_updates_and_storage.rs @@ -174,6 +174,7 @@ fn resource_store_restores_imported_resources_for_update_check() { ); assert_eq!(diagnostics.registrations[0].id, restored_registration_id); } +#[cfg(feature = "devtools")] #[test] fn devtools_pause_on_start_defers_main_script_update_check_after_target_creation() { let service = new_service_worker_runtime_service_with_resource_store( @@ -228,6 +229,7 @@ fn devtools_pause_on_start_defers_main_script_update_check_after_target_creation "deferred update check should still expose the precreated installing target: {target_events:?}" ); } +#[cfg(feature = "devtools")] #[test] fn devtools_related_pause_on_start_defers_matching_update_check() { let service = new_service_worker_runtime_service_with_resource_store( diff --git a/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/version_lifecycle.rs b/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/version_lifecycle.rs index acb5e73daf3..c3d287f128c 100644 --- a/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/version_lifecycle.rs +++ b/moli-renderer-v8/src/service_worker_runtime/service/tests/extracted/version_lifecycle.rs @@ -704,6 +704,7 @@ fn stale_worker_start_completion_does_not_advance_version_state() { assert_eq!(diagnostics.versions[0].final_script_url, None); assert_eq!(diagnostics.versions[0].main_script_status, None); } +#[cfg(feature = "devtools")] #[test] fn devtools_pause_on_start_defers_initial_install_launch_after_target_creation() { let service = new_service_worker_runtime_service(); @@ -1151,6 +1152,7 @@ fn imported_script_update_check_change_creates_installing_version() { ); assert!(!completion_queue.has_ready_task()); } +#[cfg(feature = "devtools")] #[test] fn devtools_skip_waiting_scope_uses_activation_progress() { let service = new_service_worker_runtime_service(); diff --git a/moli-renderer-v8/src/style_engine/source/mod.rs b/moli-renderer-v8/src/style_engine/source/mod.rs index 661cd1c57e4..f338283e4c1 100644 --- a/moli-renderer-v8/src/style_engine/source/mod.rs +++ b/moli-renderer-v8/src/style_engine/source/mod.rs @@ -203,7 +203,7 @@ impl MoliStyleEngine { } } - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] pub(crate) fn owner_style_sheet_text_with_host( &self, host: &DomHost, diff --git a/moli-renderer-v8/src/style_engine/source_owner_text.rs b/moli-renderer-v8/src/style_engine/source_owner_text.rs index 4d910765af1..ffb056f50ba 100644 --- a/moli-renderer-v8/src/style_engine/source_owner_text.rs +++ b/moli-renderer-v8/src/style_engine/source_owner_text.rs @@ -173,14 +173,14 @@ impl OwnerStyleSheetSources { self.csp_suppressed_owners.contains(&owner) } - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] pub(super) fn text(&self, owner: DomHandle) -> Option<&str> { self.sources_by_owner .get(&owner) .map(|installed| installed.processing_source.css_text()) } - #[cfg(feature = "devtools")] + #[cfg(any(test, feature = "devtools"))] pub(super) fn text_owned(&self, owner: DomHandle) -> Option { self.text(owner).map(str::to_owned) } diff --git a/moli-renderer-v8/src/worker/handle.rs b/moli-renderer-v8/src/worker/handle.rs index 7c8dbaaf78c..2ab6279ebe3 100644 --- a/moli-renderer-v8/src/worker/handle.rs +++ b/moli-renderer-v8/src/worker/handle.rs @@ -44,7 +44,7 @@ use std::sync::{ use tokio::sync::mpsc; #[cfg(test)] use tokio::sync::mpsc::error::TryRecvError; -#[cfg(feature = "devtools")] +#[cfg(any(test, feature = "devtools"))] use tokio::sync::oneshot; use url::Url; diff --git a/moli-renderer-v8/src/worker/inspector_task_runner.rs b/moli-renderer-v8/src/worker/inspector_task_runner.rs index c6b2d04bd5e..4346a8e34aa 100644 --- a/moli-renderer-v8/src/worker/inspector_task_runner.rs +++ b/moli-renderer-v8/src/worker/inspector_task_runner.rs @@ -166,6 +166,7 @@ impl WorkerInspectorSessionLifetime { self.0.retirement.lock().complete(result); } + #[cfg(feature = "devtools")] #[cfg(test)] pub(crate) fn retirement(&self) -> oneshot::Receiver> { self.0.retirement.lock().subscribe() @@ -740,8 +741,51 @@ impl std::fmt::Debug for WorkerInspectorTaskRunner { } #[cfg(test)] +#[test] +fn environment_bursts_and_interrupt_consumption_keep_the_owner_wake_bounded() { + use moli_v8_platform::ProcessEnvironmentInvalidation::{DateTime, LocaleAndDateTime}; + + let (wake_tx, mut wake_rx) = mpsc::unbounded_channel(); + let runner = WorkerInspectorTaskRunner::new(wake_tx, Arc::new(Mutex::new(None))); + let notifier = runner.environment_notifier(); + for _ in 0..10_000 { + notifier.notify(DateTime); + notifier.notify(LocaleAndDateTime); + } + assert!(matches!( + wake_rx.try_recv(), + Ok(super::WorkerMessage::RunEnvironmentNotification) + )); + assert!(wake_rx.try_recv().is_err()); + assert!(runner.shared.state.lock().interrupting_tasks.is_empty()); + + // Simulate JS repeatedly accepting V8 interrupts while the ordinary + // owner loop has not handled the already-posted fallback wake. + for _ in 0..1_000 { + notifier.notify(LocaleAndDateTime); + assert!(matches!( + runner.claim_interrupt_task(), + Some(WorkerInspectorTask::EnvironmentInvalidation( + LocaleAndDateTime + )) + )); + } + assert!(wake_rx.try_recv().is_err()); + assert!(runner.claim_environment_for_owner().is_none()); + notifier.notify(DateTime); + assert!(matches!( + wake_rx.try_recv(), + Ok(super::WorkerMessage::RunEnvironmentNotification) + )); + assert!(matches!( + runner.claim_environment_for_owner(), + Some(DateTime) + )); + assert!(wake_rx.try_recv().is_err()); +} + +#[cfg(all(test, feature = "devtools"))] mod tests { - #[cfg(feature = "devtools")] use super::WorkerInspectorProtocolTask; use crate::runtime::WorkerInspectorError; use anyhow::Result; @@ -909,48 +953,6 @@ mod tests { )); } - #[test] - fn environment_bursts_and_interrupt_consumption_keep_the_owner_wake_bounded() { - use moli_v8_platform::ProcessEnvironmentInvalidation::{DateTime, LocaleAndDateTime}; - - let (runner, mut wake_rx) = runner(); - let notifier = runner.environment_notifier(); - for _ in 0..10_000 { - notifier.notify(DateTime); - notifier.notify(LocaleAndDateTime); - } - assert!(matches!( - wake_rx.try_recv(), - Ok(super::WorkerMessage::RunEnvironmentNotification) - )); - assert!(wake_rx.try_recv().is_err()); - assert!(runner.shared.state.lock().interrupting_tasks.is_empty()); - - // Simulate JS repeatedly accepting V8 interrupts while the ordinary - // owner loop has not handled the already-posted fallback wake. - for _ in 0..1_000 { - notifier.notify(LocaleAndDateTime); - assert!(matches!( - runner.claim_interrupt_task(), - Some(WorkerInspectorTask::EnvironmentInvalidation( - LocaleAndDateTime - )) - )); - } - assert!(wake_rx.try_recv().is_err()); - assert!(runner.claim_environment_for_owner().is_none()); - notifier.notify(DateTime); - assert!(matches!( - wake_rx.try_recv(), - Ok(super::WorkerMessage::RunEnvironmentNotification) - )); - assert!(matches!( - runner.claim_environment_for_owner(), - Some(DateTime) - )); - assert!(wake_rx.try_recv().is_err()); - } - #[test] fn pending_environment_does_not_consume_an_ordinary_command_wake() { use moli_v8_platform::ProcessEnvironmentInvalidation::LocaleAndDateTime; diff --git a/moli-renderer-v8/src/worker/thread/runtime_inspector.rs b/moli-renderer-v8/src/worker/thread/runtime_inspector.rs index 256d1d35313..ead4ba7ae22 100644 --- a/moli-renderer-v8/src/worker/thread/runtime_inspector.rs +++ b/moli-renderer-v8/src/worker/thread/runtime_inspector.rs @@ -33,13 +33,13 @@ use crate::worker::inspector_task_runner::{ }; use tokio::sync::mpsc; -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] use super::dispatch::perform_worker_microtask_checkpoint_and_report_pending_promise_rejections; const WORKER_INSPECTOR_CONTEXT_GROUP_ID: i32 = 1; const DEFAULT_WORKER_INSPECTOR_SESSION_KEY: &str = ""; -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod pause_detach_tests; #[derive(Default)] @@ -1124,7 +1124,7 @@ fn worker_runtime_inspector_message_batch( } } -#[cfg(test)] +#[cfg(all(test, feature = "devtools"))] mod tests { use super::*; use crate::worker::inspector_task_runner::WorkerInspectorTaskMode; diff --git a/moli-renderer-v8/src/worker/thread/test_resource_driver.rs b/moli-renderer-v8/src/worker/thread/test_resource_driver.rs index c141374ec5f..41844a3846f 100644 --- a/moli-renderer-v8/src/worker/thread/test_resource_driver.rs +++ b/moli-renderer-v8/src/worker/thread/test_resource_driver.rs @@ -1,5 +1,7 @@ use super::*; -use crate::{RendererPageCommand as C, RendererSyntheticResponseBody}; +use crate::RendererSyntheticResponseBody; +use crate::network::interception_control::{InterceptionPhase, ResourceInterceptionDecision}; + impl WorkerTestHandle { pub(crate) async fn native_response_body( &self, @@ -16,51 +18,54 @@ impl WorkerTestHandle { body.capture(64 * 1024 * 1024).await.unwrap() } - fn decide(&self, id: u64, command: C) { + fn decide(&self, id: u64, phase: InterceptionPhase, decision: ResourceInterceptionDecision) { self.native_pauses .lock() .get(&id) .expect("a test decision requires its exact native pause") - .dispatch(command) - .expect("native test decision"); + .send_test_decision(id, phase, decision); } + pub(crate) fn continue_pending_fetch(&self, r: crate::worker::WorkerPendingFetchContinue) { - let id = r.fetch_id; - let command = match r.auth { - Some(auth) => C::ContinuePendingSubresourceAuth { - internal_id: id, - auth, - }, - None => C::ContinuePendingSubresourceFetch { - internal_id: id, - url: Some(r.url), - method: Some(r.method), - body: Some(r.body), - headers: Some(r.headers.into()), - intercept_response: r.intercept_response, - handle_auth_requests: r.handle_auth_requests, - }, + let (phase, decision) = match r.auth { + Some(auth) => ( + InterceptionPhase::Auth, + ResourceInterceptionDecision::Auth(auth), + ), + None => ( + InterceptionPhase::Request, + ResourceInterceptionDecision::ContinueRequest { + url: Some(r.url), + method: Some(r.method), + body: Some(r.body), + headers: Some(r.headers.into()), + intercept_response: r.intercept_response, + handle_auth_requests: r.handle_auth_requests, + }, + ), }; - self.decide(id, command); + self.decide(r.fetch_id, phase, decision); } + pub(crate) fn continue_pending_xhr(&self, r: crate::worker::WorkerPendingXhrContinue) { - let id = r.xhr_id; - let command = match r.auth { - Some(auth) => C::ContinuePendingSubresourceAuth { - internal_id: id, - auth, - }, - None => C::ContinuePendingSubresourceFetch { - internal_id: id, - url: Some(r.url), - method: Some(r.method), - body: Some(r.body), - headers: Some(r.headers.into()), - intercept_response: r.intercept_response, - handle_auth_requests: r.handle_auth_requests, - }, + let (phase, decision) = match r.auth { + Some(auth) => ( + InterceptionPhase::Auth, + ResourceInterceptionDecision::Auth(auth), + ), + None => ( + InterceptionPhase::Request, + ResourceInterceptionDecision::ContinueRequest { + url: Some(r.url), + method: Some(r.method), + body: Some(r.body), + headers: Some(r.headers.into()), + intercept_response: r.intercept_response, + handle_auth_requests: r.handle_auth_requests, + }, + ), }; - self.decide(id, command); + self.decide(r.xhr_id, phase, decision); } pub(crate) fn fulfill_pending_fetch( &self, @@ -89,12 +94,12 @@ impl WorkerTestHandle { ) { self.decide( id, - C::FulfillPendingSubresourceFetch { - internal_id: id, + InterceptionPhase::Request, + ResourceInterceptionDecision::Fulfill { request_overrides: None, - response_code: status, - response_headers: headers, - response_body: body, + status, + headers, + body, }, ); } @@ -106,10 +111,8 @@ impl WorkerTestHandle { ) { self.decide( r.xhr_id, - C::FailPendingSubresourceFetch { - internal_id: r.xhr_id, - error_text, - }, + InterceptionPhase::Request, + ResourceInterceptionDecision::Fail(error_text), ); } pub(crate) fn fail_pending_fetch_auth( @@ -119,10 +122,8 @@ impl WorkerTestHandle { ) { self.decide( r.fetch_id, - C::FailPendingSubresourceAuth { - internal_id: r.fetch_id, - error_text, - }, + InterceptionPhase::Auth, + ResourceInterceptionDecision::Fail(error_text), ); } pub(crate) fn fail_pending_xhr_auth( @@ -132,10 +133,8 @@ impl WorkerTestHandle { ) { self.decide( r.xhr_id, - C::FailPendingSubresourceAuth { - internal_id: r.xhr_id, - error_text, - }, + InterceptionPhase::Auth, + ResourceInterceptionDecision::Fail(error_text), ); } pub(crate) fn continue_pending_fetch_response( @@ -146,11 +145,8 @@ impl WorkerTestHandle { ) { self.decide( r.fetch_id, - C::ContinuePendingSubresourceResponse { - internal_id: r.fetch_id, - response_code: status, - response_headers: headers, - }, + InterceptionPhase::Response, + ResourceInterceptionDecision::ContinueResponse { status, headers }, ); } pub(crate) fn continue_pending_xhr_response( @@ -161,11 +157,8 @@ impl WorkerTestHandle { ) { self.decide( r.xhr_id, - C::ContinuePendingSubresourceResponse { - internal_id: r.xhr_id, - response_code: status, - response_headers: headers, - }, + InterceptionPhase::Response, + ResourceInterceptionDecision::ContinueResponse { status, headers }, ); } } diff --git a/moli-renderer-v8/src/worker/thread/tests/lifecycle/worker_and_fetch_lifecycle.rs b/moli-renderer-v8/src/worker/thread/tests/lifecycle/worker_and_fetch_lifecycle.rs index a1723210a4e..6e94ae5ad38 100644 --- a/moli-renderer-v8/src/worker/thread/tests/lifecycle/worker_and_fetch_lifecycle.rs +++ b/moli-renderer-v8/src/worker/thread/tests/lifecycle/worker_and_fetch_lifecycle.rs @@ -359,6 +359,7 @@ async fn worker_bootstrap_can_be_released_without_an_inspector_command() { handle.terminate_and_join(); } +#[cfg(feature = "devtools")] #[tokio::test] async fn worker_pause_evaluation_until_debugger_exposes_context_before_bootstrap() { ensure_v8(); @@ -471,6 +472,7 @@ async fn worker_pause_evaluation_until_debugger_exposes_context_before_bootstrap handle.terminate_and_join(); } +#[cfg(feature = "devtools")] #[tokio::test] async fn worker_attach_before_runtime_enable_preserves_script_loaded_after_resume() { ensure_v8(); @@ -532,6 +534,7 @@ async fn worker_attach_before_runtime_enable_preserves_script_loaded_after_resum handle.terminate_and_join(); } +#[cfg(feature = "devtools")] #[tokio::test] async fn worker_inspector_interrupt_overtakes_js_running_command_during_active_javascript() { ensure_v8(); diff --git a/moli-renderer-v8/src/worker/thread/tests/mod.rs b/moli-renderer-v8/src/worker/thread/tests/mod.rs index 9fb4e0eda27..9ae13eb174f 100644 --- a/moli-renderer-v8/src/worker/thread/tests/mod.rs +++ b/moli-renderer-v8/src/worker/thread/tests/mod.rs @@ -2,6 +2,7 @@ mod abort_signal_events; mod callback_execution; mod error_reporting_guard; mod geometry_matrix_constructor_union; +#[cfg(feature = "devtools")] mod indexed_db_gc; mod exception_constructor_strings; diff --git a/tools/devtools-size-ab.py b/tools/devtools-size-ab.py index 64e15cf4105..460244a5733 100644 --- a/tools/devtools-size-ab.py +++ b/tools/devtools-size-ab.py @@ -4,7 +4,7 @@ Uses this checkout's patches and local moli-core. Both variants share a lockfile, target directory and release profile; the existing Limo executable is preserved. Run from the Moli root: python3 tools/devtools-size-ab.py --limo-root ../limo -API contracts need no Limo checkout: python3 tools/devtools-size-ab.py --check-only +Standalone checks need no Limo checkout: python3 tools/devtools-size-ab.py --check-only --runtime-smoke """ import argparse @@ -81,6 +81,8 @@ def main(): parser.add_argument('--order', choices=('on-first', 'off-first'), default='off-first') parser.add_argument('--skip-contracts', action='store_true', help='Reuse previously checked API contracts') parser.add_argument('--check-only', action='store_true', help='Check feature/API contracts without linking') + parser.add_argument('--runtime-smoke', action='store_true', + help='Also build and run the standalone probe with DevTools disabled in check-only mode') args = parser.parse_args() if args.limo_root is None and not args.check_only: parser.error('--limo-root is required for the release comparison; use --check-only for standalone API checks') @@ -95,7 +97,6 @@ def main(): if limo: for source in ('main.rs', 'server.rs'): shutil.copyfile(limo / 'src' / source, app / 'src' / source) - shutil.copyfile(moli / 'tools/devtools-size-probe.rs', app / 'src/devtools_probe.rs') manifest = (limo / 'Cargo.toml').read_text().split('[patch.crates-io]')[0] else: (app / 'src/main.rs').write_text('fn main() {}\n') @@ -119,12 +120,19 @@ codegen-units = 1 dependency_end = next(i for i, line in enumerate(lines) if line.startswith('[profile.')) lines.insert(dependency_end, f'moli-command-types = {{ path = "{moli / "moli-types/moli-command-types"}", default-features = false }}\n') lines.insert(dependency_end, f'moli-renderer-v8 = {{ path = "{moli / "moli-renderer-v8"}", default-features = false }}\n') + if not limo and args.runtime_smoke: + lines[dependency_end:dependency_end] = [ + 'anyhow = "1"', + 'axum = "0.8"', + 'tokio = { version = "1", features = ["net", "rt", "time"] }', + ] manifest = '\n'.join(lines) + '\n\n[workspace]\n\n[features]\ndefault = []\ndevtools = ["moli-core/devtools", "moli-command-types/devtools"]\ntypes-devtools-only = ["moli-command-types/devtools"]\nrenderer-devtools-only = ["moli-renderer-v8/devtools"]\nace-only = ["moli-core/ace-protocol"]\n\n' patches = (moli / 'Cargo.toml').read_text() patches = patches[patches.index('[patch.crates-io]'):patches.index('[workspace.lints.clippy]')] patches = patches.replace('path = "vendor/', f'path = "{moli}/vendor/') manifest += patches - if limo: + if limo or args.runtime_smoke: + shutil.copyfile(moli / 'tools/devtools-size-probe.rs', app / 'src/devtools_probe.rs') manifest += '\n[[bin]]\nname = "devtools-probe"\npath = "src/devtools_probe.rs"\n' contracts = { 'runtime-contract': '''fn main() { @@ -184,6 +192,12 @@ fn main() { 'page-dispatch': ('moli_core::page::Page::start_runtime_protocol_message', 'start_runtime_protocol_message'), 'input': ('moli_core::page::Page::start_dispatch_key_event_with_location_outcome', 'start_dispatch_key_event_with_location_outcome'), 'network': ('moli_core::page::Page::start_set_fetch_subresource_interception', 'start_set_fetch_subresource_interception'), + 'dedicated-worker-pause': ('moli_core::runtime::RendererBrowserContextRuntime::set_dedicated_worker_pause_on_start_for_devtools', 'set_dedicated_worker_pause_on_start_for_devtools'), + 'shared-worker-pause': ('moli_core::runtime::RendererBrowserContextRuntime::set_shared_worker_pause_on_start_for_devtools', 'set_shared_worker_pause_on_start_for_devtools'), + 'navigation-interception': ('moli_core::runtime::NavigationEngine::set_subresource_interception', 'set_subresource_interception'), + 'commit-interception': ('|config: &moli_core::runtime::PreparedDocumentPageCommitConfiguration| config.fetch_subresource_interception', 'fetch_subresource_interception'), + 'network-policy-interception': ('moli_renderer_v8::network::PageNetworkPolicy::set_subresource_interception', 'set_subresource_interception'), + 'worker-policy-interception': ('moli_renderer_v8::network::ResourceInterceptionPolicy::set_interception', 'set_interception'), } for name, (expression, _) in removed_apis.items(): contracts[f'devtools-{name}-contract'] = f'fn main() {{ let _ = {expression}; }}' @@ -231,7 +245,13 @@ fn main() { if result.returncode == 0 or expected not in diagnostic: raise RuntimeError(f'{name}: expected an unavailable DevTools API in the off build; see {output}') if args.check_only: - print('Feature contracts passed: runtime APIs compile; DevTools types/APIs exist only with devtools.') + if not args.skip_contracts: + print('Feature contracts passed. Runtime APIs compile, and DevTools APIs require the feature.') + if args.runtime_smoke: + run(['cargo', 'build', *common, '--bin', 'devtools-probe'], 'probe-build-off') + probe = 'devtools-probe.exe' if os.name == 'nt' else 'devtools-probe' + run([str(target.resolve() / 'debug' / probe)], 'probe-off', timeout=30) + print((output / 'probe-off.log').read_text().strip()) return results = {} order = ('off', 'on') if args.order == 'off-first' else ('on', 'off') diff --git a/tools/devtools-size-probe.rs b/tools/devtools-size-probe.rs index dc85c698ebb..e931e278071 100644 --- a/tools/devtools-size-probe.rs +++ b/tools/devtools-size-probe.rs @@ -1,17 +1,10 @@ -#[allow(dead_code)] // The shared Limo router also supports file entry points. -mod server; - use anyhow::{Result, ensure}; +use axum::{Router, http::header::CONTENT_TYPE, response::Html, routing::get}; use moli_core::LayoutPolicy; use moli_core::page::{RendererCaptureScreenshotReply, RendererPrintToPdfReply}; use moli_core::runtime::{Browser, BrowserConfig, RenderedDomWaitUntil}; use std::time::Duration; - -#[derive(Clone, Copy)] -enum InputType { - Script, - Module, -} +use tokio::net::TcpListener; fn main() -> Result<()> { tokio::runtime::Builder::new_current_thread() @@ -24,10 +17,10 @@ fn main() -> Result<()> { async fn run() -> Result<()> { let browser = Browser::new(BrowserConfig::default().with_layout_policy(LayoutPolicy::OnDemand))?; - let mode = if std::env::args().any(|arg| arg == "script") { - InputType::Script + let script_attributes = if std::env::args().any(|arg| arg == "script") { + "defer" } else { - InputType::Module + r#"type="module""# }; let source = r#" const b = document.createElement('button'); @@ -44,23 +37,48 @@ input.value = 'abc'; input.setSelectionRange(1, 2); input.setRangeText('Z'); if (input.value !== 'aZc') throw new Error('text selection failed'); globalThis.__probeDomOK = true; "#; - let router = server::source_router(source.into(), mode).route( - "/probe-sw.js", - axum::routing::get(|| async { - ( - [("content-type", "application/javascript")], - "self.addEventListener('install', e => e.waitUntil(self.skipWaiting())); self.addEventListener('activate', e => e.waitUntil(self.clients.claim()));", - ) - }), - ); - let router = router.route( - "/probe-worker-resource", - axum::routing::get(|| async { "native-worker-network" }), - ); - let server = server::LocalServer::start(router, 0).await?; + let router = Router::new() + .route( + "/", + get(move || async move { + Html(format!( + r#""# + )) + }), + ) + .route( + "/probe.js", + get(move || async move { ([(CONTENT_TYPE, "text/javascript")], source) }), + ) + .route( + "/probe-sw.js", + get(|| async { + ( + [(CONTENT_TYPE, "text/javascript")], + "self.addEventListener('install', e => e.waitUntil(self.skipWaiting())); self.addEventListener('activate', e => e.waitUntil(self.clients.claim()));", + ) + }), + ) + .route( + "/probe-shared-worker.js", + get(|| async { + ( + [(CONTENT_TYPE, "text/javascript")], + r#"self.onconnect = ({ports: [port]}) => { + port.onmessage = async () => { + port.postMessage(await (await fetch('/probe-worker-resource')).text()); + }; + };"#, + ) + }), + ) + .route("/probe-worker-resource", get(|| async { "native-worker-network" })); + let listener = TcpListener::bind("127.0.0.1:0").await?; + let base_url = format!("http://{}", listener.local_addr()?); + tokio::spawn(async move { axum::serve(listener, router).await }); let mut page = browser .fetch_with_wait_until( - server.base_url(), + &base_url, RenderedDomWaitUntil::Idle, Duration::from_secs(5), ) @@ -94,6 +112,32 @@ globalThis.__probeDomOK = true; value == Some(42), "unexpected promise evaluation: {promise}" ); + let page_and_shared_worker_fetch = page + .evaluate_runtime_expression_with_await_async( + r#"(() => { + const worker = new SharedWorker('/probe-shared-worker.js'); + globalThis.__probeSharedWorker = worker; + globalThis.__probeSharedWorkerFetch = () => new Promise((resolve, reject) => { + worker.onerror = reject; + worker.port.onmessage = event => resolve(event.data); + worker.port.postMessage('network'); + }); + return Promise.all([ + fetch('/probe-worker-resource').then(response => response.text()), + __probeSharedWorkerFetch() + ]).then(results => results.join('|')); + })()"#, + true, + ) + .await?; + ensure!( + ["/result/result/value", "/result/value", "/value"] + .into_iter() + .find_map(|path| page_and_shared_worker_fetch.pointer(path)) + .and_then(|value| value.as_str()) + == Some("native-worker-network|native-worker-network"), + "unexpected Page or SharedWorker fetch result: {page_and_shared_worker_fetch}" + ); let environment = moli_core::ProcessEnvironmentOwner::default(); page.evaluate_runtime_expression_with_await_async( r#"new Promise(resolve => { @@ -172,6 +216,27 @@ globalThis.__probeDomOK = true; == Some(true), "service worker registration failed: {registration}" ); + browser + .wait_for_script_truthy( + &mut page, + "navigator.serviceWorker.controller !== null", + Duration::from_secs(5), + ) + .await?; + let controlled_worker = page + .evaluate_runtime_expression_with_await_async( + "__probeSharedWorkerFetch().finally(() => __probeSharedWorker.port.close())", + true, + ) + .await?; + ensure!( + ["/result/result/value", "/result/value", "/value"] + .into_iter() + .find_map(|path| controlled_worker.pointer(path)) + .and_then(|value| value.as_str()) + == Some("native-worker-network"), + "SharedWorker fetch failed after ServiceWorker claim: {controlled_worker}" + ); let screenshot = page.start_capture_screenshot()?.wait().await?; let screenshot = page.finish_capture_screenshot(screenshot)?; match screenshot { @@ -204,7 +269,7 @@ globalThis.__probeDomOK = true; .await?; } println!( - "probe-ok devtools={} host_eval=true promise=true wait=true environment=true worker_environment=true service_worker=true png=true pdf=true", + "probe-ok devtools={} host_eval=true promise=true wait=true environment=true page_fetch=true dedicated_worker=true shared_worker=true service_worker=true png=true pdf=true", cfg!(feature = "devtools") ); Ok(())