fix(devtools): close optional configuration gates

Compile renderer tests without DevTools and run the standalone consumer against a local fixture. Route Service Worker client notifications through WorkerNavigator in worker realms.
This commit is contained in:
ldm0
2026-11-18 19:09:35 +08:00
committed by Donough Liu
parent 3ce8ad6cd8
commit 2c4f149c30
135 changed files with 874 additions and 520 deletions
+7 -2
View File
@@ -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
+12 -6
View File
@@ -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.
@@ -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<i32>,
@@ -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<i32>,
@@ -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<PendingPageCommand> {
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<String>,
@@ -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<String>,
@@ -241,7 +225,6 @@ impl Page {
)
}
#[cfg(feature = "devtools")]
pub fn start_accessibility_partial_tree_payloads_for_object_id(
&self,
inspector_session_id: Option<String>,
@@ -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,
-29
View File
@@ -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<Rend
/// Decodes a completed renderer turn shared by mouse, touch, drag, and key dispatches.
#[doc(hidden)]
#[cfg(feature = "devtools")]
pub fn decode_input_dispatch_outcome_completion(
completion: RendererCommandTurnCompletion,
operation: &str,
@@ -212,7 +210,6 @@ pub trait PageInputExt {
}
impl PageInputExt for Page {
#[cfg(feature = "devtools")]
async fn dispatch_mouse_event_at_point_with_outcome_async(
&mut self,
x: f64,
@@ -229,7 +226,6 @@ impl PageInputExt for Page {
.await
}
#[cfg(feature = "devtools")]
async fn dispatch_mouse_event_at_point_async(
&mut self,
x: f64,
@@ -246,7 +242,6 @@ impl PageInputExt for Page {
.await
}
#[cfg(feature = "devtools")]
fn start_dispatch_mouse_event_at_point_with_outcome(
&self,
x: f64,
@@ -272,7 +267,6 @@ impl PageInputExt for Page {
)
}
#[cfg(feature = "devtools")]
fn start_dispatch_mouse_event_at_point_with_pointer_outcome(
&self,
x: f64,
@@ -302,7 +296,6 @@ impl PageInputExt for Page {
})
}
#[cfg(feature = "devtools")]
fn finish_dispatch_mouse_event_at_point_with_outcome(
&mut self,
completion: CompletedPageCommand,
@@ -311,7 +304,6 @@ impl PageInputExt for Page {
decode_input_dispatch_outcome_reply(reply, "mouse event page command")
}
#[cfg(feature = "devtools")]
async fn dispatch_touch_event_at_point_with_outcome_async(
&mut self,
x: f64,
@@ -323,7 +315,6 @@ impl PageInputExt for Page {
.await
}
#[cfg(feature = "devtools")]
async fn dispatch_touch_event_at_point_async(
&mut self,
x: f64,
@@ -334,7 +325,6 @@ impl PageInputExt for Page {
Page::dispatch_touch_event_at_point_async(self, x, y, event_name, activate).await
}
#[cfg(feature = "devtools")]
fn start_dispatch_touch_event_at_point_with_outcome(
&self,
x: f64,
@@ -349,7 +339,6 @@ impl PageInputExt for Page {
)
}
#[cfg(feature = "devtools")]
fn start_dispatch_touch_event_at_points_with_outcome(
&self,
points: Vec<RendererTouchPoint>,
@@ -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<PendingPageCommand> {
self.start_page_command(RendererPageCommand::ClearActiveDragDataTransfer)
}
#[cfg(feature = "devtools")]
fn start_cancel_dragging(&self) -> Result<PendingPageCommand> {
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<bool> {
Page::insert_text_into_active_control_async(self, text).await
}
#[cfg(feature = "devtools")]
fn start_insert_text_into_active_control(&self, text: &str) -> Result<PendingPageCommand> {
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<String>,
@@ -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<Result<RendererInputDispatchOutcome, super::RendererElementClickError>> {
@@ -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,
+30 -50
View File
@@ -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<String>,
@@ -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<PendingPageCommand> {
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<String>,
@@ -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<String>,
@@ -617,7 +608,6 @@ impl Page {
)
}
#[cfg(feature = "devtools")]
pub fn start_routable_runtime_protocol_message_for_inspector_session(
&self,
inspector_session_id: Option<String>,
@@ -664,7 +654,6 @@ impl Page {
}
}
#[cfg(feature = "devtools")]
pub fn start_runtime_inspector_io_message_without_response(
&self,
inspector_session_id: Option<String>,
@@ -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<Vec<RendererRuntimeInspectorMessage>> {
@@ -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<PendingPageCommand> {
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<RendererRuntimeHeapUsage> {
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<PendingPageCommand> {
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<PendingPageCommand> {
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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -1078,7 +1067,6 @@ impl Page {
)
}
#[cfg(feature = "devtools")]
pub fn start_dom_debugger_configure_xhr_breakpoint(
&self,
inspector_session_id: Option<String>,
@@ -1092,7 +1080,6 @@ impl Page {
})
}
#[cfg(feature = "devtools")]
pub fn start_dom_debugger_configure_dom_breakpoint(
&self,
inspector_session_id: Option<String>,
@@ -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<PendingPageCommand> {
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<String>,
@@ -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<PendingPageCommand> {
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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -1425,7 +1404,6 @@ impl Page {
.await
}
#[cfg(feature = "devtools")]
pub fn start_set_runtime_binding_state(
&self,
inspector_session_id: Option<String>,
@@ -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,
+15 -88
View File
@@ -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<String>,
@@ -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<PendingPageCommand> {
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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -935,7 +895,6 @@ impl Page {
))
}
#[cfg(feature = "devtools")]
pub fn start_request_document_node_for_object_id(
&self,
inspector_session_id: Option<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -1267,7 +1226,6 @@ impl Page {
)
}
#[cfg(feature = "devtools")]
pub fn start_child_frame_document_query_selector_for_node(
&self,
inspector_session_id: Option<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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<String>,
@@ -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,
+25 -4
View File
@@ -54,9 +54,20 @@ struct DocumentPageLoadOptions {
pub viewport_surface: Option<ViewportSurface>,
pub network_offline: bool,
pub blocked_url_patterns: Vec<String>,
/// 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<String>,
#[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,
@@ -2130,6 +2130,7 @@ mod tests {
});
}
#[cfg(feature = "devtools")]
#[test]
fn event_views_share_records_without_reviving_closed_view_permissions() {
with_transfer_scope(|scope| {
@@ -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)]
@@ -1646,22 +1646,26 @@ fn navigator_runtime_data_object<'s>(
.and_then(|value| v8::Local::<v8::Object>::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<v8::Local<'s, v8::Object>> {
// 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::<v8::Object>::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::<v8::Object>::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()
@@ -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<v8::Local<'s, v8::Object>> {
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<v8::Local<'s, v8::Object>> {
service_worker_container_for_window(scope, window)
service_worker_container_for_client(scope, client)
}
fn service_worker_container_registration_cache<'s>(
+13 -14
View File
@@ -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,
+3 -3
View File
@@ -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;
+1 -4
View File
@@ -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,
};
@@ -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::*;
@@ -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,
@@ -12,7 +12,7 @@ use std::sync::{
pub(crate) struct VisualResourceGeneration(Arc<AtomicU64>);
impl VisualResourceGeneration {
#[cfg(feature = "devtools")]
#[cfg(any(test, feature = "devtools"))]
pub(crate) fn current(&self) -> u64 {
self.0.load(Ordering::Acquire)
}
@@ -259,6 +259,7 @@ mod tests {
);
}
#[cfg(feature = "devtools")]
#[test]
fn only_navigation_capable_real_input_supplies_an_input_policy() {
assert_eq!(
@@ -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;
@@ -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::{
@@ -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<u32> {
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<u32> {
})
}
#[cfg(feature = "devtools")]
#[cfg(any(test, feature = "devtools"))]
fn single_ascii_digit(value: &str) -> Option<u8> {
if value.len() != 1 {
return None;
@@ -325,7 +325,7 @@ fn single_ascii_digit(value: &str) -> Option<u8> {
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<u32> {
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,
@@ -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("<div id=target class=sized></div>");
@@ -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();
@@ -6,6 +6,7 @@ use std::collections::BTreeMap;
const GRID: &str = r#"<div id=target class=sized style="display:grid;grid-template-columns:30px 1fr;grid-template-rows:20px 1fr"></div>"#;
#[cfg(feature = "devtools")]
fn inspector_properties(host: &PageScriptHost, target: DomHandle) -> BTreeMap<String, String> {
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<St
.collect()
}
#[cfg(feature = "devtools")]
#[test]
fn computed_size_inspector_enumeration_waits_for_explicit_publication() {
for real in [false, true] {
@@ -120,6 +122,7 @@ fn computed_size_observation_stays_cold_regardless_of_grid_read_order() {
}
}
#[cfg(feature = "devtools")]
#[test]
fn computed_size_document_batch_never_publishes_layout_regardless_of_grid_order() {
for grid_first in [false, true] {
@@ -1,7 +1,8 @@
use std::sync::Arc;
use anyhow::{Result, anyhow};
#[cfg(feature = "devtools")]
use anyhow::{Result, anyhow, bail, ensure};
use anyhow::{bail, ensure};
use parking_lot::Mutex;
use tokio::sync::oneshot;
use url::Url;
@@ -150,10 +151,29 @@ impl ResourceInterceptionPause {
},
InterceptionPhase::Auth => 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<ResourceInterceptionReply> {
#[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)
}
}
@@ -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);
+31 -11
View File
@@ -95,6 +95,8 @@ impl PageNetworkConditionsState {
pub struct PageNetworkPolicy {
state: Arc<Mutex<PageNetworkPolicyState>>,
network_conditions: Arc<Mutex<PageNetworkConditionsState>>,
// Unit-test fixtures also use native pauses to supply synthetic network responses.
#[cfg(any(test, feature = "devtools"))]
subresource_interception: Arc<Mutex<SubresourceInterceptionClasses>>,
}
@@ -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<Arc<moli_browser_profile::BrowserIdentityProfile>>,
@@ -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();
+1
View File
@@ -310,6 +310,7 @@ mod tests {
use super::*;
#[cfg(feature = "devtools")]
#[test]
fn raw_owner_admission_rejects_inspector_page_commands() {
let handle = RenderRuntimeHandle::disconnected();
@@ -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<AtomicBool>,
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<HashMap<u64, DedicatedWorkerDevToolsTarget>>,
#[cfg(feature = "devtools")]
dedicated_worker_pause_on_start_for_devtools: AtomicBool,
#[cfg(feature = "devtools")]
shared_worker_pause_on_start_for_devtools: Arc<AtomicBool>,
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]
@@ -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<WorkerDevToolsHandle> {
@@ -266,7 +275,7 @@ impl RendererBrowserContextRuntime {
}
}
#[cfg(test)]
#[cfg(all(test, feature = "devtools"))]
mod tests {
use super::*;
@@ -266,5 +266,5 @@ impl RendererDocumentPreparationTarget {
}
}
#[cfg(test)]
#[cfg(all(test, feature = "devtools"))]
mod tests;
+1
View File
@@ -125,6 +125,7 @@ pub struct RendererPreparedDocumentCommitConfiguration {
pub bypass_service_worker: bool,
pub cache_disabled: bool,
pub blocked_url_patterns: Vec<String>,
/// Applied only when renderer DevTools is enabled.
pub fetch_subresource_interception_classes: crate::SubresourceInterceptionClasses,
}
@@ -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);
@@ -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()
@@ -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;
@@ -157,6 +157,7 @@ impl PageVm {
Ok(false)
}
#[cfg(feature = "devtools")]
pub(crate) fn set_fetch_subresource_interception(
&mut self,
classes: crate::SubresourceInterceptionClasses,
@@ -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,
+17 -3
View File
@@ -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<RuntimeConsoleMessageSnapshot>),
#[cfg(feature = "devtools")]
#[cfg(any(test, feature = "devtools"))]
RuntimeHeapUsage(Box<RendererRuntimeHeapUsage>),
#[cfg(feature = "devtools")]
PerformanceMetricSnapshot(Box<RendererPerformanceMetricSnapshot>),
@@ -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!(
@@ -260,7 +260,7 @@ fn url_without_fragment(value: &str) -> Option<Url> {
})
}
#[cfg(test)]
#[cfg(all(test, feature = "devtools"))]
mod tests {
use super::*;
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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::{
@@ -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();
@@ -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::{
@@ -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();
@@ -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;
@@ -3,6 +3,7 @@ use super::*;
mod image_repeat;
mod planar_transforms;
mod print;
#[cfg(feature = "devtools")]
mod print_isolation;
mod transform_precision;
@@ -220,6 +220,7 @@ child.contentDocument.body.innerHTML = '<p>Iframe text</p>';
}).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 {
@@ -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 {
@@ -385,6 +385,7 @@ document.body.innerHTML = '<div id=target></div>';
.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 {
@@ -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 {
@@ -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 {
@@ -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()
@@ -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&amp;" }.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)))",
@@ -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", || {
+15
View File
@@ -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<Vec<serde_json::Value>> {
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<String>,
@@ -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;
@@ -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] {
@@ -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();
@@ -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();
@@ -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();
@@ -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();
@@ -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();
@@ -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();
@@ -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)
+1 -1
View File
@@ -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,
@@ -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,
+3 -3
View File
@@ -695,7 +695,7 @@ impl ScriptVm {
);
}
#[cfg(feature = "devtools")]
#[cfg(any(test, feature = "devtools"))]
pub(crate) fn eval(&mut self, source: &str) -> Result<String> {
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<v8::Context>,
@@ -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<v8::Context>,
@@ -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;
@@ -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;
@@ -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<InspectorJson> {
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;
@@ -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<InspectorJson>) -> Vec<Value> {
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;
@@ -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")]
@@ -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");
@@ -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/");
@@ -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;
@@ -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");
@@ -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(
@@ -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/");
@@ -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/");
@@ -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(
@@ -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] {
@@ -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/");
@@ -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(
@@ -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/");
@@ -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/");
@@ -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/");
@@ -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/");
@@ -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/");
@@ -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;
@@ -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(
@@ -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(
@@ -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] {
@@ -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 [
@@ -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(
@@ -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
@@ -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"] {
@@ -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] {
@@ -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/");

Some files were not shown because too many files have changed in this diff Show More