mirror of
https://github.com/lexmount/moli.git
synced 2026-11-24 16:02:53 +00:00
fix(scripts): execute child inline classics synchronously
Prepare connected script candidates after DOM mutation borrows are released and execute child inline classics before the inserting DOM call returns. Reuse the child realm runner for CSP, error reporting and execution cleanup; remove the obsolete queued DynamicClassic work and preserve currentScript on the execution Document across nested scripts and adoption. Cover initial about:blank, srcdoc, reentrant fragments, script errors, Shadow DOM, retirement and microtask order. Move three location WPT cases to passed and the newly observable window.open referrer failure to failed. Validation: cargo fmt --all; full workspace clippy with all targets and features and -D warnings; cargo nextest run --no-fail-fast (19457 passed, 13 skipped). 35 related WPT cases show no previously passing regression; 104 timing/CSP checks pass against Chromium. The running-script shadow movement probe follows the HTML currentScript algorithm and differs from Chromium 145; both official Shadow DOM WPT cases pass.
This commit is contained in:
@@ -172,13 +172,9 @@ impl PageScriptHost {
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
job.script_nonce = self
|
||||
.dom_host()
|
||||
.node(script_handle)
|
||||
.and_then(crate::dom::native::Node::as_element)
|
||||
.and_then(|element| element.cryptographic_nonce())
|
||||
.map(str::to_owned)
|
||||
.or_else(|| self.dom_host().get_attribute(script_handle, "nonce"));
|
||||
job.script_nonce =
|
||||
crate::host::script_element_nonce_for_csp(self.dom_host(), script_handle)
|
||||
.map(str::to_owned);
|
||||
job.script_integrity = self.dom_host().get_attribute(script_handle, "integrity");
|
||||
// Commit before entering V8: the script can remove and reinsert itself,
|
||||
// mutate another pending script, or replace its preparation Document.
|
||||
|
||||
@@ -132,7 +132,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::frame_owner_model::{
|
||||
DocumentId, FrameDocumentRealmBoundScriptWork, FrameSchedulerLaneId, LocalWindowId,
|
||||
PendingChildDynamicDocumentScript,
|
||||
PendingChildExternalClassicDocumentScript,
|
||||
};
|
||||
|
||||
fn owner(document: u64) -> FrameDocumentTaskOwner {
|
||||
@@ -144,14 +144,15 @@ mod tests {
|
||||
}
|
||||
|
||||
fn work(owner: FrameDocumentTaskOwner, node: DomHandle) -> FrameDocumentScriptReadyTaskWork {
|
||||
FrameDocumentRealmBoundScriptWork::DynamicClassic(PendingChildDynamicDocumentScript {
|
||||
FrameDocumentRealmBoundScriptWork::ExternalClassic(PendingChildExternalClassicDocumentScript {
|
||||
child_handle: DomHandle::new(1),
|
||||
owner,
|
||||
realm_id: Some(FrameRealmId(2)),
|
||||
script_handle: node,
|
||||
source: String::new(),
|
||||
script_nonce: None,
|
||||
script_integrity: None,
|
||||
load_delay: crate::frame_owner_model::ChildDocumentAsyncClassicScriptLoadDelay::AlreadyUnblocked,
|
||||
source_result: Ok(String::new()),
|
||||
script_url: url::Url::parse("https://child-script-order.test/script.js").unwrap(),
|
||||
script_base_url: url::Url::parse("https://child-script-order.test/").unwrap(),
|
||||
})
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ async fn bitmap_task_uses_child_intrinsics_and_retires_when_the_child_window_is_
|
||||
'scheduled'
|
||||
"#)?;
|
||||
run_expected_child_realm_materialization_for_wait(&mut page_vm, "child bitmap realm").await;
|
||||
assert!(page_vm.run_exact_selected_page_task_for_test(PageSelectedTaskTestSelector::ChildDocumentScriptReady, &loader).await?);
|
||||
assert!(!page_vm.run_exact_selected_page_task_for_test(PageSelectedTaskTestSelector::ChildDocumentScriptReady, &loader).await?, "inline execution must not leave a queued script task");
|
||||
run_ready_bitmap_task(&mut page_vm).await?;
|
||||
assert_eq!(page_vm.vm_mut().eval("JSON.stringify(bitmapChildOutcome)")?, "[3,4,true]");
|
||||
assert!(page_vm.vm().has_pending_bitmap_tasks());
|
||||
|
||||
Reference in New Issue
Block a user