mirror of
https://github.com/lexmount/moli.git
synced 2026-11-21 00:03:15 +00:00
fix(runtime): adapt retained WPT surfaces to native main APIs
Use native Document ownership, mutation plans, event outcomes and resource APIs. Remove duplicate declarations and obsolete adapters while retaining the existing behavior coverage. Validation: cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast. Checks cover the integrated workspace with 32-way concurrency and no automatic retries.
This commit is contained in:
@@ -62,9 +62,9 @@ impl DomHost {
|
||||
source: &mut Self,
|
||||
root: DomHandle,
|
||||
) -> Result<DomSubtreeTransfer, DomSubtreeTransferError> {
|
||||
if !self.node(document).is_some_and(Node::is_document) {
|
||||
let Some(target_document) = self.node(document).and_then(Node::as_document) else {
|
||||
return Err(DomSubtreeTransferError::InvalidTargetDocument(document));
|
||||
}
|
||||
};
|
||||
let plan = source.preflight_subtree_transfer(root)?;
|
||||
let needs_template_document = plan
|
||||
.nodes
|
||||
@@ -77,12 +77,10 @@ impl DomHost {
|
||||
.and_then(|count| {
|
||||
count.checked_add(usize::from(
|
||||
needs_template_document
|
||||
&& !self.node(document).and_then(Node::as_document).is_some_and(
|
||||
|document| {
|
||||
document.is_inert_template_document()
|
||||
|| document.associated_inert_template_document().is_some()
|
||||
},
|
||||
),
|
||||
&& !target_document.is_inert_template_document()
|
||||
&& target_document
|
||||
.associated_inert_template_document()
|
||||
.is_none(),
|
||||
))
|
||||
});
|
||||
if capacity.is_none_or(|count| count > u32::MAX as usize) {
|
||||
|
||||
@@ -12,18 +12,6 @@ const CONSTRUCTOR_SPECS_BEFORE_STREAMS: &[ConstructorSpec] = &[
|
||||
interface: web_api_interfaces::NetworkInformation::DESCRIPTOR,
|
||||
kind: ConstructorKind::Illegal,
|
||||
},
|
||||
ConstructorSpec {
|
||||
interface: web_api_interfaces::ServiceWorkerContainer::DESCRIPTOR,
|
||||
kind: ConstructorKind::Illegal,
|
||||
},
|
||||
ConstructorSpec {
|
||||
interface: web_api_interfaces::ServiceWorkerRegistration::DESCRIPTOR,
|
||||
kind: ConstructorKind::Illegal,
|
||||
},
|
||||
ConstructorSpec {
|
||||
interface: web_api_interfaces::ServiceWorker::DESCRIPTOR,
|
||||
kind: ConstructorKind::Illegal,
|
||||
},
|
||||
ConstructorSpec {
|
||||
interface: web_api_interfaces::PaymentRequestUpdateEvent::DESCRIPTOR,
|
||||
kind: ConstructorKind::PaymentRequestUpdateEvent,
|
||||
@@ -96,14 +84,6 @@ const CONSTRUCTOR_SPECS_BEFORE_STREAMS: &[ConstructorSpec] = &[
|
||||
interface: web_api_interfaces::LockManager::DESCRIPTOR,
|
||||
kind: ConstructorKind::Illegal,
|
||||
},
|
||||
ConstructorSpec {
|
||||
interface: web_api_interfaces::MIDIConnectionEvent::DESCRIPTOR,
|
||||
kind: ConstructorKind::Shell { length: 1 },
|
||||
},
|
||||
ConstructorSpec {
|
||||
interface: web_api_interfaces::MIDIMessageEvent::DESCRIPTOR,
|
||||
kind: ConstructorKind::Shell { length: 1 },
|
||||
},
|
||||
ConstructorSpec {
|
||||
interface: web_api_interfaces::MediaKeyMessageEvent::DESCRIPTOR,
|
||||
kind: ConstructorKind::MediaKeyMessageEvent,
|
||||
|
||||
@@ -406,7 +406,12 @@ pub(crate) fn perform_drop_default_action<'s>(
|
||||
}
|
||||
|
||||
if let Some(focus_handle) = focus_handle {
|
||||
update_focus_preserving_selection(scope, runtime_ptr, Some(focus_handle));
|
||||
if editing_host.is_some() {
|
||||
// Keep the drop's selection when its editing host gains focus.
|
||||
update_focus_preserving_selection(scope, runtime_ptr, Some(focus_handle));
|
||||
} else {
|
||||
update_focus(scope, runtime_ptr, Some(focus_handle));
|
||||
}
|
||||
}
|
||||
|
||||
if is_file_input {
|
||||
|
||||
@@ -61,6 +61,18 @@ globalThis.emptyMedia = document.createElement({kind:?});
|
||||
emptyMedia.defaultMuted = true;
|
||||
emptyMedia.muted = false;
|
||||
emptyMedia.volume = 0.25;
|
||||
"#,
|
||||
))?;
|
||||
// Finish setup changes before observing loading notifications.
|
||||
while page
|
||||
.run_exact_selected_page_task_for_test(
|
||||
PageSelectedTaskTestSelector::MediaElementEvent,
|
||||
&loader,
|
||||
)
|
||||
.await?
|
||||
{}
|
||||
page.vm_mut().eval(&format!(
|
||||
r#"
|
||||
for (const type of ['loadstart', 'loadedmetadata', 'loadeddata', 'canplay', 'volumechange']) {{
|
||||
emptyMedia.addEventListener(type, () => emptyMediaTrace.push(type));
|
||||
}}
|
||||
|
||||
@@ -187,6 +187,8 @@ fn create_html_document_reference_children_remain_attached_after_root_removal()
|
||||
#[test]
|
||||
fn create_html_document_keeps_initial_child_wrappers_lazy() {
|
||||
let mut vm = new_vm();
|
||||
// The main Document is itself lazy on the native Window accessor.
|
||||
vm.eval("void document; 'ready'").unwrap();
|
||||
let retained_cache = vm
|
||||
.with_default_context_scope_and_checkpoint_for_test(|scope, _runtime_ptr| {
|
||||
Ok(crate::native_bridge::identity::retain_context_wrapper_cache_for_test(scope))
|
||||
|
||||
@@ -3,7 +3,7 @@ use super::selection_order::order_font_data;
|
||||
use super::*;
|
||||
|
||||
fn assert_anonymous_space_demand(display: &str, whitespace: &str, setup: &str, expected: &str) {
|
||||
let mut vm = font_usage_vm();
|
||||
let (mut vm, mut completions) = font_usage_vm();
|
||||
let (_, wide) = order_font_data();
|
||||
vm.eval(&format!(r#"
|
||||
globalThis.face = new FontFace('AnonymousFace', 'url(data:font/ttf;base64,{wide})', {{unicodeRange:'U+0020'}});
|
||||
@@ -17,8 +17,8 @@ fn assert_anonymous_space_demand(display: &str, whitespace: &str, setup: &str, e
|
||||
document.body.replaceChildren(container);
|
||||
{setup}
|
||||
"#)).unwrap();
|
||||
vm.prime_document_lifecycle_processing_and_record_stylesheet_network_results();
|
||||
run_font_tasks(&mut vm);
|
||||
vm.reconcile_document_font_resources();
|
||||
complete_local_font_resources(&mut vm, &mut completions);
|
||||
assert_eq!(
|
||||
vm.eval("face.status").unwrap(),
|
||||
expected,
|
||||
@@ -26,7 +26,7 @@ fn assert_anonymous_space_demand(display: &str, whitespace: &str, setup: &str, e
|
||||
);
|
||||
vm.eval("document.fonts.ready.then(() => globalThis.ready = true)")
|
||||
.unwrap();
|
||||
run_font_tasks(&mut vm);
|
||||
complete_local_font_resources(&mut vm, &mut completions);
|
||||
assert_eq!(vm.eval("globalThis.ready === true").unwrap(), "true");
|
||||
assert_eq!(vm.eval("face.status").unwrap(), expected);
|
||||
if expected == "unloaded" {
|
||||
@@ -201,7 +201,7 @@ fn font_usage_matches_retained_anonymous_item_text() {
|
||||
(" A ", " A", " A"),
|
||||
(" \u{00a0} ", " \u{00a0}", " \u{00a0}"),
|
||||
] {
|
||||
let mut vm = font_usage_vm();
|
||||
let (mut vm, _completions) = font_usage_vm();
|
||||
let markup = serde_json::to_string(markup).unwrap();
|
||||
vm.eval(&format!(r#"
|
||||
document.body.innerHTML = '<div id="container"></div>';
|
||||
|
||||
@@ -789,7 +789,7 @@ async fn storage_bucket_caches_are_bucket_scoped_usage_metadata() {
|
||||
)
|
||||
.await;
|
||||
let result = vm
|
||||
.eval("String(globalThis.__storageBucketCacheProbe)")
|
||||
.eval_without_microtask_checkpoint_for_test("String(globalThis.__storageBucketCacheProbe)")
|
||||
.expect("storage bucket CacheStorage probe should settle");
|
||||
|
||||
assert_eq!(
|
||||
@@ -1121,7 +1121,9 @@ async fn storage_bucket_cache_put_enforces_bucket_quota() {
|
||||
)
|
||||
.await;
|
||||
let result = vm
|
||||
.eval("String(globalThis.__storageBucketCacheQuotaProbe)")
|
||||
.eval_without_microtask_checkpoint_for_test(
|
||||
"String(globalThis.__storageBucketCacheQuotaProbe)",
|
||||
)
|
||||
.expect("storage bucket CacheStorage quota probe should settle");
|
||||
|
||||
assert_eq!(
|
||||
|
||||
@@ -193,14 +193,18 @@ async fn window_service_worker_response_filter_survives_streaming_clone_and_cach
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn window_filtered_fetch_preserves_internal_head_through_clone_and_cache() {
|
||||
#[tokio::test]
|
||||
async fn window_filtered_fetch_preserves_internal_head_through_clone_and_cache() {
|
||||
let loader = static_http_loader(std::iter::empty::<String>());
|
||||
for streaming in [false, true] {
|
||||
for (mode, redirect, status, response_type) in [
|
||||
("no-cors", "follow", 200, "opaque"),
|
||||
("cors", "manual", 302, "opaqueredirect"),
|
||||
] {
|
||||
let mut vm = new_storage_test_vm("https://opaque-response.test/");
|
||||
let mut vm = new_storage_page_task_executor_test_vm_with_loader(
|
||||
"https://opaque-response.test/",
|
||||
&loader,
|
||||
);
|
||||
vm.set_fetch_subresource_interception(
|
||||
crate::types::SubresourceInterceptionClasses::for_resource_type(
|
||||
crate::types::SubresourceResourceType::Fetch,
|
||||
@@ -308,6 +312,14 @@ fn window_filtered_fetch_preserves_internal_head_through_clone_and_cache() {
|
||||
.unwrap();
|
||||
}
|
||||
vm.exec("0", None).unwrap();
|
||||
advance_page_task_executor_until_eval_equals(
|
||||
&mut vm,
|
||||
&loader,
|
||||
"String(opaqueResult !== 'pending')",
|
||||
"true",
|
||||
"window_filtered_fetch_preserves_internal_head_through_clone_and_cache",
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
vm.eval("opaqueResult").unwrap(),
|
||||
"ok",
|
||||
|
||||
@@ -124,7 +124,7 @@ fn metadata_candidates_preserve_cache_payloads_and_handle_identity_without_cloni
|
||||
.get_mut(&StorageBucketCacheName::from("assets"))
|
||||
.unwrap()
|
||||
.push(StorageBucketCacheEntry {
|
||||
request_url: "resource".into(),
|
||||
request_url: "https://a.test/resource".into(),
|
||||
usage_bytes: 1_048_576,
|
||||
request: StorageBucketCachedRequest::default(),
|
||||
response: StorageBucketCachedResponse {
|
||||
|
||||
@@ -30,8 +30,10 @@ interfaces! {
|
||||
Lock;
|
||||
LockManager;
|
||||
MIDIAccess: EventTarget;
|
||||
MIDIConnectionEvent: Event;
|
||||
MIDIInput: MIDIPort;
|
||||
MIDIInputMap;
|
||||
MIDIMessageEvent: Event;
|
||||
MIDIOutput: MIDIPort;
|
||||
MIDIOutputMap;
|
||||
MIDIPort: EventTarget;
|
||||
@@ -152,8 +154,6 @@ interfaces! {
|
||||
ConvolverNode: AudioNode;
|
||||
Blob;
|
||||
BlobEvent: Event;
|
||||
MIDIConnectionEvent: Event;
|
||||
MIDIMessageEvent: Event;
|
||||
BroadcastChannel: EventTarget;
|
||||
ByteLengthQueuingStrategy;
|
||||
CDATASection: Text;
|
||||
|
||||
Reference in New Issue
Block a user