From 8b32ef9227da80e021a9359e00858bdb3726f8ce Mon Sep 17 00:00:00 2001
From: ldm0
Date: Fri, 4 Sep 2026 13:25:10 +0800
Subject: [PATCH] fix(iframe): reuse initial document for about blank variants
---
..._browsing_context_navigation_identity.html | 36 +++++-----
..._context_pending_navigation_coherence.html | 6 +-
.../child_documents/initial_empty.rs | 9 ++-
.../child_frame_navigation/history_seed.rs | 5 ++
.../context_host/child_frames/discovery.rs | 3 +
.../context_host/child_frames/registry.rs | 9 +++
.../extracted/frame_navigation_and_history.rs | 67 +++++++++++++++++++
7 files changed, 114 insertions(+), 21 deletions(-)
diff --git a/moli-core/tests/fixtures/runtime/window_child_browsing_context_navigation_identity.html b/moli-core/tests/fixtures/runtime/window_child_browsing_context_navigation_identity.html
index c07f2fe0d49..a711d316a55 100644
--- a/moli-core/tests/fixtures/runtime/window_child_browsing_context_navigation_identity.html
+++ b/moli-core/tests/fixtures/runtime/window_child_browsing_context_navigation_identity.html
@@ -10,31 +10,31 @@
const iframe = document.createElement('iframe');
iframe.id = 'child';
iframe.src = 'about:blank';
+ let child = null;
+ let loadCount = 0;
+ iframe.addEventListener('load', () => {
+ loadCount += 1;
+ if (loadCount === 1) {
+ iframe.src = '/compat/window-child-browsing-context-target-name-a';
+ return;
+ }
+ document.body.dataset.windowSame = String(child === iframe.contentWindow);
+ document.body.dataset.locationUpdated = String(
+ iframe.contentWindow?.location?.href ?? 'null'
+ );
+ document.body.dataset.documentUpdated = String(
+ iframe.contentWindow?.document?.body?.textContent?.trim() ?? 'null'
+ );
+ iframe.contentWindow?.postMessage('kept', '*');
+ });
document.body.appendChild(iframe);
-
- const child = iframe.contentWindow;
+ child = iframe.contentWindow;
if (!child) {
document.body.dataset.windowSame = 'no-child';
} else {
- let loadCount = 0;
child.addEventListener('message', (event) => {
document.body.dataset.listenerPreserved = String(event.data);
});
- iframe.addEventListener('load', () => {
- loadCount += 1;
- if (loadCount === 1) {
- iframe.src = '/compat/window-child-browsing-context-target-name-a';
- return;
- }
- document.body.dataset.windowSame = String(child === iframe.contentWindow);
- document.body.dataset.locationUpdated = String(
- iframe.contentWindow?.location?.href ?? 'null'
- );
- document.body.dataset.documentUpdated = String(
- iframe.contentWindow?.document?.body?.textContent?.trim() ?? 'null'
- );
- iframe.contentWindow?.postMessage('kept', '*');
- });
}
-