Skip to content

Commit 78ae542

Browse files
committed
[Site Isolation] Web Inspector: Match frame documents to their owner iframe by frameId instead of URL
https://bugs.webkit.org/show_bug.cgi?id=320933 rdar://problem/183966415 Reviewed by Qianlang Chen. Under Site Isolation, the Elements tab splices each frame target's document under its owner <iframe> in the page tree. It matched them by comparing the iframe's src attribute to the document URL. That broke after pushState, replaceState, fragment changes and redirects, could splice into a hidden frame target tree (the main frame's, or an in-process ancestor frame's), and could not follow a frame that moved between processes. Nested cross-origin frames could disappear from the Elements tree after reopening Web Inspector (rdar://188011181). Add DOM.Node.contentFrameId to frame owner elements, and send frameId on frame target documents. The frontend now splices only by FrameIdentifier, and only into owners in the visible page tree. It finds owners through an index instead of scanning every node. Only the FrameIdentifier is compared because the hosting-process part of a frame ID can be stale in a process that holds a RemoteFrame: that process is not told when the frame moves between two other processes. When a frame switches between local and remote in its owner's process, re-send the owner element so the frontend drops the stale in-process contentDocument and splices the frame target's document instead. Spliced documents now return to pending instead of being destroyed when their owner is removed or re-sent, the page document resets, or a parent frame target goes away. Stale DOM.getDocument replies for a frame target are ignored. There is no URL fallback for backends that send frame targets without frameId. Tests: http/tests/site-isolation/inspector/dom/frame-document-splicing-hidden-tree-frame-target.html http/tests/site-isolation/inspector/dom/frame-document-splicing-redirect-frame-target.html http/tests/site-isolation/inspector/dom/frame-document-splicing-remote-transition-frame-target.html http/tests/site-isolation/inspector/dom/frame-document-splicing-teardown-frame-target.html http/tests/site-isolation/inspector/dom/frame-document-splicing-url-change-frame-target.html * LayoutTests/http/tests/site-isolation/inspector/dom/frame-document-splicing-hidden-tree-frame-target-expected.txt: Added. * LayoutTests/http/tests/site-isolation/inspector/dom/frame-document-splicing-hidden-tree-frame-target.html: Added. * LayoutTests/http/tests/site-isolation/inspector/dom/frame-document-splicing-redirect-frame-target-expected.txt: Added. * LayoutTests/http/tests/site-isolation/inspector/dom/frame-document-splicing-redirect-frame-target.html: Added. * LayoutTests/http/tests/site-isolation/inspector/dom/frame-document-splicing-remote-transition-frame-target-expected.txt: Added. * LayoutTests/http/tests/site-isolation/inspector/dom/frame-document-splicing-remote-transition-frame-target.html: Added. * LayoutTests/http/tests/site-isolation/inspector/dom/frame-document-splicing-teardown-frame-target-expected.txt: Added. * LayoutTests/http/tests/site-isolation/inspector/dom/frame-document-splicing-teardown-frame-target.html: Added. * LayoutTests/http/tests/site-isolation/inspector/dom/frame-document-splicing-url-change-frame-target-expected.txt: Added. * LayoutTests/http/tests/site-isolation/inspector/dom/frame-document-splicing-url-change-frame-target.html: Added. * LayoutTests/http/tests/site-isolation/inspector/dom/resources/frame-document-splicing-test-utilities.js: Added. (TestPage.registerInitializer.window.frameTargetForURLContainingWhenReady.async frameTargetForURLContainingWhenReady): (TestPage.registerInitializer.window.childElement.async childElement): (TestPage.registerInitializer.window.descendFromPageBody.async descendFromPageBody): (TestPage.registerInitializer.window.treeContainingNode): (TestPage.registerInitializer.window.isFrameTargetWithDOM): (TestPage.registerInitializer.window.simulateInspectorReopen.async simulateInspectorReopen): (TestPage.registerInitializer.window.evaluateInFrameTarget.async evaluateInFrameTarget): (TestPage.registerInitializer.window.pushNodeIntoFrameTargetTree.async pushNodeIntoFrameTargetTree): * LayoutTests/http/tests/site-isolation/inspector/dom/resources/splice-same-origin-middle-frame.html: Added. * Source/JavaScriptCore/inspector/protocol/DOM.json: * Source/WebCore/inspector/InspectorIdentifierRegistry.cpp: (Inspector::IdentifierRegistry::protocolFrameId): (Inspector::BackendIdentifierRegistry::frameId): (Inspector::BackendIdentifierRegistry::takeFrame): * Source/WebCore/inspector/InspectorIdentifierRegistry.h: * Source/WebCore/inspector/InspectorInstrumentation.cpp: (WebCore::InspectorInstrumentation::didCommitLoadImpl): (WebCore::InspectorInstrumentation::frameOwnerContentFrameChangedImpl): * Source/WebCore/inspector/InspectorInstrumentation.h: (WebCore::InspectorInstrumentation::frameOwnerContentFrameChanged): * Source/WebCore/inspector/agents/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::buildObjectForNode): (WebCore::InspectorDOMAgent::didCommitLoad): (WebCore::InspectorDOMAgent::frameOwnerContentFrameChanged): (WebCore::InspectorDOMAgent::resendFrameOwner): * Source/WebCore/inspector/agents/InspectorDOMAgent.h: * Source/WebCore/inspector/agents/frame/FrameDOMAgent.cpp: (WebCore::FrameDOMAgent::buildObjectForNode): (WebCore::FrameDOMAgent::frameOwnerContentFrameChanged): * Source/WebCore/inspector/agents/frame/FrameDOMAgent.h: * Source/WebCore/page/Frame.cpp: (WebCore::Frame::setOwnerElement): * Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js: (WI.DOMManager): (WI.DOMManager.prototype._spliceFrameDocumentIntoPageTree): (WI.DOMManager._frameKey): (WI.DOMManager.prototype._registerFrameOwnerElement): (WI.DOMManager.prototype._unregisterFrameOwnerElement): (WI.DOMManager.prototype._willDestroyFrameOwnerElement): (WI.DOMManager.prototype._trySpliceFrameDocumentIntoNode): (WI.DOMManager.prototype._isSplicedFrameDocument): (WI.DOMManager.prototype._unspliceFrameDocument): (WI.DOMManager.prototype._unspliceFrameDocumentsUnder): (WI.DOMManager.prototype._isInPageTree): (WI.DOMManager.prototype._trySpliceUnsplicedFrameDocuments): (WI.DOMManager.prototype._cleanupFrameTarget): (WI.DOMManager.prototype._frameTargetUnbind): (WI.DOMManager.prototype._frameTargetWillDestroyDOMNode): (WI.DOMManager.prototype._setDocument): (WI.DOMManager.prototype._unbind): * Source/WebInspectorUI/UserInterface/Models/DOMNode.js: (WI.DOMNode.prototype.get frameIdentifier): (WI.DOMNode.prototype.get contentFrameIdentifier): * Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js: (WI.SpreadsheetCSSStyleDeclarationSection.prototype._highlightNodesWithSelector): Canonical link: https://commits.webkit.org/323975@main
1 parent a112286 commit 78ae542

25 files changed

Lines changed: 905 additions & 60 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Test that a nested cross-origin frame's document is spliced into the page tree, not into a hidden frame target tree that happened to load its <iframe> first.
2+
3+
4+
5+
== Running test suite: SiteIsolation.DOM.FrameDocumentSplicing.HiddenTree
6+
-- Running test case: Setup
7+
PASS: Should find the main frame target.
8+
PASS: Should find the middle frame target.
9+
PASS: Should find the inner frame target.
10+
PASS: All three frame targets should be distinct.
11+
12+
-- Running test case: SiteIsolation.DOM.FrameDocumentSplicing.HiddenTree.MainFrameTargetTreeFirst
13+
PASS: The inner frame's document should not be spliced in yet.
14+
PASS: Should push the inner frame's <iframe> into the main frame target's tree.
15+
PASS: Should find the inner frame's <iframe> in the page tree.
16+
PASS: The inner frame's document should be in the page tree.
17+
PASS: The inner frame's document should be spliced into the page tree's <iframe>.
18+
19+
-- Running test case: SiteIsolation.DOM.FrameDocumentSplicing.HiddenTree.MiddleFrameTargetTreeFirst
20+
PASS: The inner frame's document should not be spliced in yet.
21+
PASS: Should push the inner frame's <iframe> into the middle frame target's tree.
22+
PASS: Should find the inner frame's <iframe> in the page tree.
23+
PASS: The inner frame's document should be in the page tree.
24+
PASS: The inner frame's document should be spliced into the page tree's <iframe>.
25+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<!-- webkit-test-runner [ SiteIsolationEnabled=true ] -->
2+
<script src="../../../inspector/resources/inspector-test.js"></script>
3+
<script src="../debugger/resources/site-isolation-debugger-test-utilities.js"></script>
4+
<script src="resources/frame-document-splicing-test-utilities.js"></script>
5+
<script>
6+
function test() {
7+
let suite = InspectorTest.createAsyncSuite("SiteIsolation.DOM.FrameDocumentSplicing.HiddenTree");
8+
9+
let mainFrameTarget = null;
10+
let middleTarget = null;
11+
let innerTarget = null;
12+
let targetNames = new Map;
13+
14+
async function pageTreeInnerIframeElement(pageDocument) {
15+
let middleIframe = await descendFromPageBody(pageDocument, (node) => node.nodeName() === "IFRAME");
16+
let middleDocument = await childElement(middleIframe, (node) => node.nodeType() === Node.DOCUMENT_NODE);
17+
let middleHTML = await childElement(middleDocument, (node) => node.nodeName() === "HTML");
18+
let middleBody = await childElement(middleHTML, (node) => node.nodeName() === "BODY");
19+
return childElement(middleBody, (node) => node.nodeName() === "IFRAME");
20+
}
21+
22+
async function runCase(hiddenTarget, expression) {
23+
let pageDocument = await simulateInspectorReopen();
24+
25+
let innerDocument = WI.domManager.frameTargetDocumentForTarget(innerTarget);
26+
InspectorTest.expectNull(innerDocument.parentNode, "The inner frame's document should not be spliced in yet.");
27+
28+
let hiddenIframe = await pushNodeIntoFrameTargetTree(hiddenTarget, expression);
29+
InspectorTest.expectNotNull(hiddenIframe, `Should push the inner frame's <iframe> into the ${targetNames.get(hiddenTarget)}'s tree.`);
30+
31+
let pageIframe = await pageTreeInnerIframeElement(pageDocument);
32+
InspectorTest.expectNotNull(pageIframe, "Should find the inner frame's <iframe> in the page tree.");
33+
34+
InspectorTest.expectEqual(treeContainingNode(innerDocument, targetNames), "page", "The inner frame's document should be in the page tree.");
35+
InspectorTest.expectEqual(innerDocument.parentNode, pageIframe, "The inner frame's document should be spliced into the page tree's <iframe>.");
36+
}
37+
38+
suite.addTestCase({
39+
name: "Setup",
40+
description: "Find the main, middle, and inner frame targets.",
41+
async test() {
42+
mainFrameTarget = await frameTargetForURLContainingWhenReady("frame-document-splicing-hidden-tree-frame-target.html");
43+
middleTarget = await frameTargetForURLContainingWhenReady("splice-same-origin-middle-frame.html");
44+
innerTarget = await frameTargetForURLContainingWhenReady("dom-frame.html");
45+
46+
InspectorTest.expectNotNull(mainFrameTarget, "Should find the main frame target.");
47+
InspectorTest.expectNotNull(middleTarget, "Should find the middle frame target.");
48+
InspectorTest.expectNotNull(innerTarget, "Should find the inner frame target.");
49+
InspectorTest.expectEqual(new Set([mainFrameTarget, middleTarget, innerTarget]).size, 3, "All three frame targets should be distinct.");
50+
51+
targetNames.set(mainFrameTarget, "main frame target");
52+
targetNames.set(middleTarget, "middle frame target");
53+
targetNames.set(innerTarget, "inner frame target");
54+
}
55+
});
56+
57+
suite.addTestCase({
58+
name: "SiteIsolation.DOM.FrameDocumentSplicing.HiddenTree.MainFrameTargetTreeFirst",
59+
description: "The inner <iframe> reaching the main frame target's tree first should not capture the inner frame's document.",
60+
async test() {
61+
await runCase(mainFrameTarget, `document.querySelector("iframe").contentDocument.querySelector("iframe")`);
62+
}
63+
});
64+
65+
suite.addTestCase({
66+
name: "SiteIsolation.DOM.FrameDocumentSplicing.HiddenTree.MiddleFrameTargetTreeFirst",
67+
description: "The inner <iframe> reaching the middle frame target's tree first should not capture the inner frame's document.",
68+
async test() {
69+
await runCase(middleTarget, `document.querySelector("iframe")`);
70+
}
71+
});
72+
73+
suite.runTestCasesAndFinish();
74+
}
75+
</script>
76+
77+
<body onload="runTest()">
78+
<p>Test that a nested cross-origin frame's document is spliced into the page tree, not into a hidden frame target tree that happened to load its &lt;iframe&gt; first.</p>
79+
<iframe src="resources/splice-same-origin-middle-frame.html"></iframe>
80+
</body>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Test that a frame target's document is spliced under its <iframe> when the <iframe>'s src redirected cross-origin.
2+
3+
4+
5+
== Running test suite: SiteIsolation.DOM.FrameDocumentSplicing.Redirect
6+
-- Running test case: SiteIsolation.DOM.FrameDocumentSplicing.Redirect.CrossOriginRedirect
7+
PASS: Should find the cross-origin frame target.
8+
PASS: Should find the page's <iframe>.
9+
PASS: The <iframe>'s src should differ from the frame's document URL.
10+
PASS: The frame's document should be spliced into the <iframe>.
11+
PASS: The frame's document should be in the page tree.
12+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!-- webkit-test-runner [ SiteIsolationEnabled=true ] -->
2+
<script src="../../../inspector/resources/inspector-test.js"></script>
3+
<script src="../debugger/resources/site-isolation-debugger-test-utilities.js"></script>
4+
<script src="resources/frame-document-splicing-test-utilities.js"></script>
5+
<script>
6+
function test() {
7+
let suite = InspectorTest.createAsyncSuite("SiteIsolation.DOM.FrameDocumentSplicing.Redirect");
8+
9+
suite.addTestCase({
10+
name: "SiteIsolation.DOM.FrameDocumentSplicing.Redirect.CrossOriginRedirect",
11+
description: "A frame whose src redirected cross-origin should still be spliced under its <iframe>.",
12+
async test() {
13+
let frameTarget = await frameTargetForURLContainingWhenReady("dom-frame.html");
14+
InspectorTest.expectNotNull(frameTarget, "Should find the cross-origin frame target.");
15+
16+
let pageDocument = await WI.domManager.requestDocument();
17+
let iframeElement = await descendFromPageBody(pageDocument, (node) => node.nodeName() === "IFRAME");
18+
InspectorTest.expectNotNull(iframeElement, "Should find the page's <iframe>.");
19+
20+
let frameDocument = WI.domManager.frameTargetDocumentForTarget(frameTarget);
21+
InspectorTest.expectNotEqual(iframeElement?.getAttribute("src"), frameDocument.documentURL, "The <iframe>'s src should differ from the frame's document URL.");
22+
InspectorTest.expectEqual(frameDocument.parentNode, iframeElement, "The frame's document should be spliced into the <iframe>.");
23+
InspectorTest.expectEqual(treeContainingNode(frameDocument, new Map([[frameTarget, "frame target"]])), "page", "The frame's document should be in the page tree.");
24+
}
25+
});
26+
27+
suite.runTestCasesAndFinish();
28+
}
29+
</script>
30+
<body onload="runTest()">
31+
<p>Test that a frame target's document is spliced under its &lt;iframe&gt; when the &lt;iframe&gt;'s src redirected cross-origin.</p>
32+
<iframe src="/resources/redirect.py?url=http://localhost:8000/site-isolation/inspector/dom/resources/dom-frame.html"></iframe>
33+
</body>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Test that an <iframe> in the page tree holds its frame's current document as the frame moves between processes, and that removing an <iframe> unsplices its frame target's document.
2+
3+
4+
5+
== Running test suite: SiteIsolation.DOM.FrameDocumentSplicing.RemoteTransition
6+
-- Running test case: Setup
7+
PASS: Should find #late-frame.
8+
PASS: #late-frame should have a content document.
9+
PASS: #late-frame's child should be a document.
10+
PASS: #late-frame's document should come from the page agent.
11+
12+
-- Running test case: SiteIsolation.DOM.FrameDocumentSplicing.RemoteTransition.NavigateCrossOrigin
13+
PASS: Should find the cross-origin frame target.
14+
PASS: Should still find #late-frame.
15+
PASS: The cross-origin frame's document should be spliced into #late-frame.
16+
PASS: #late-frame should have exactly one child.
17+
PASS: #late-frame's only child should be the cross-origin frame's document.
18+
PASS: The cross-origin frame's document should be in the page tree.
19+
20+
-- Running test case: SiteIsolation.DOM.FrameDocumentSplicing.RemoteTransition.NavigateToAnotherRemoteProcess
21+
PASS: Should find the frame target in the third process.
22+
PASS: Should still find #late-frame.
23+
PASS: The third-process frame's document should be spliced into #late-frame.
24+
PASS: #late-frame should have exactly one child.
25+
PASS: #late-frame's only child should be the third-process frame's document.
26+
PASS: The third-process frame's document should be in the page tree.
27+
28+
-- Running test case: SiteIsolation.DOM.FrameDocumentSplicing.RemoteTransition.RemoveOwnerElement
29+
PASS: Should find #removed-frame's frame target.
30+
PASS: #removed-frame's document should be spliced into it.
31+
PASS: #removed-frame should be gone from the page tree.
32+
PASS: #removed-frame's document should no longer be spliced.
33+
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<!-- webkit-test-runner [ SiteIsolationEnabled=true ] -->
2+
<script src="../../../inspector/resources/inspector-test.js"></script>
3+
<script src="../debugger/resources/site-isolation-debugger-test-utilities.js"></script>
4+
<script src="resources/frame-document-splicing-test-utilities.js"></script>
5+
<script>
6+
function test() {
7+
let suite = InspectorTest.createAsyncSuite("SiteIsolation.DOM.FrameDocumentSplicing.RemoteTransition");
8+
9+
let pageDocument = null;
10+
let targetNames = new Map;
11+
12+
async function flushPageDOMAgent() {
13+
let pageTarget = WI.assumingMainTarget();
14+
await pageTarget.DOMAgent.getSupportedEventNames();
15+
await pageTarget.DOMAgent.getSupportedEventNames();
16+
}
17+
18+
function pageBodyChildWithId(id) {
19+
return pageDocument.body.children?.find((node) => node.getAttribute("id") === id) ?? null;
20+
}
21+
22+
function lateFrameElement() {
23+
return pageBodyChildWithId("late-frame");
24+
}
25+
26+
async function waitUntil(predicate, maxAttempts = 50) {
27+
for (let attempt = 0; attempt < maxAttempts; ++attempt) {
28+
if (predicate())
29+
return true;
30+
await new Promise((resolve) => setTimeout(resolve, 100));
31+
}
32+
return false;
33+
}
34+
35+
function expectSplicedIntoLateFrame(frameDocument, label) {
36+
let iframeElement = lateFrameElement();
37+
InspectorTest.expectNotNull(iframeElement, "Should still find #late-frame.");
38+
InspectorTest.expectEqual(frameDocument.parentNode, iframeElement, `The ${label} frame's document should be spliced into #late-frame.`);
39+
InspectorTest.expectEqual(iframeElement?.children?.length, 1, "#late-frame should have exactly one child.");
40+
InspectorTest.expectEqual(iframeElement?.children?.[0], frameDocument, `#late-frame's only child should be the ${label} frame's document.`);
41+
InspectorTest.expectEqual(treeContainingNode(frameDocument, targetNames), "page", `The ${label} frame's document should be in the page tree.`);
42+
}
43+
44+
suite.addTestCase({
45+
name: "Setup",
46+
description: "Load the <iframe> while its about:blank document is still in the page's process.",
47+
async test() {
48+
pageDocument = await WI.domManager.requestDocument();
49+
50+
let iframeElement = await descendFromPageBody(pageDocument, (node) => node.getAttribute("id") === "late-frame");
51+
InspectorTest.expectNotNull(iframeElement, "Should find #late-frame.");
52+
53+
let blankDocument = iframeElement.children?.[0] ?? null;
54+
InspectorTest.expectNotNull(blankDocument, "#late-frame should have a content document.");
55+
InspectorTest.expectEqual(blankDocument?.nodeType(), Node.DOCUMENT_NODE, "#late-frame's child should be a document.");
56+
InspectorTest.expectEqual(blankDocument?.owningTarget ?? null, null, "#late-frame's document should come from the page agent.");
57+
}
58+
});
59+
60+
suite.addTestCase({
61+
name: "SiteIsolation.DOM.FrameDocumentSplicing.RemoteTransition.NavigateCrossOrigin",
62+
description: "After the <iframe> navigates cross-origin, its frame target's document should be spliced under it.",
63+
async test() {
64+
await InspectorTest.evaluateInPage(`document.getElementById("late-frame").src = "http://localhost:8000/site-isolation/inspector/dom/resources/dom-frame.html?late=http"`);
65+
66+
let frameTarget = await frameTargetForURLContainingWhenReady("late=http");
67+
InspectorTest.expectNotNull(frameTarget, "Should find the cross-origin frame target.");
68+
targetNames.set(frameTarget, "cross-origin frame target");
69+
70+
await flushPageDOMAgent();
71+
72+
expectSplicedIntoLateFrame(WI.domManager.frameTargetDocumentForTarget(frameTarget), "cross-origin");
73+
}
74+
});
75+
76+
suite.addTestCase({
77+
name: "SiteIsolation.DOM.FrameDocumentSplicing.RemoteTransition.NavigateToAnotherRemoteProcess",
78+
description: "After the remote frame moves to a third process, the page's process is not told, so only the frame's identity can splice its new document.",
79+
async test() {
80+
await InspectorTest.evaluateInPage(`document.getElementById("late-frame").src = "https://localhost:8443/site-isolation/inspector/dom/resources/dom-frame.html?late=https"`);
81+
82+
let frameTarget = await frameTargetForURLContainingWhenReady("late=https");
83+
InspectorTest.expectNotNull(frameTarget, "Should find the frame target in the third process.");
84+
targetNames.set(frameTarget, "third-process frame target");
85+
86+
let frameDocument = WI.domManager.frameTargetDocumentForTarget(frameTarget);
87+
await waitUntil(() => frameDocument.parentNode);
88+
await flushPageDOMAgent();
89+
90+
expectSplicedIntoLateFrame(frameDocument, "third-process");
91+
}
92+
});
93+
94+
suite.addTestCase({
95+
name: "SiteIsolation.DOM.FrameDocumentSplicing.RemoteTransition.RemoveOwnerElement",
96+
description: "Removing an <iframe> whose frame target's document is spliced under it should unsplice that document.",
97+
async test() {
98+
let frameTarget = await frameTargetForURLContainingWhenReady("removed=1");
99+
InspectorTest.expectNotNull(frameTarget, "Should find #removed-frame's frame target.");
100+
targetNames.set(frameTarget, "removed frame target");
101+
102+
let frameDocument = WI.domManager.frameTargetDocumentForTarget(frameTarget);
103+
InspectorTest.expectEqual(frameDocument.parentNode, pageBodyChildWithId("removed-frame"), "#removed-frame's document should be spliced into it.");
104+
105+
await InspectorTest.evaluateInPage(`document.getElementById("removed-frame").remove()`);
106+
await waitUntil(() => !pageBodyChildWithId("removed-frame") && !frameDocument.parentNode);
107+
await flushPageDOMAgent();
108+
109+
InspectorTest.expectNull(pageBodyChildWithId("removed-frame"), "#removed-frame should be gone from the page tree.");
110+
InspectorTest.expectNull(frameDocument.parentNode, "#removed-frame's document should no longer be spliced.");
111+
}
112+
});
113+
114+
suite.runTestCasesAndFinish();
115+
}
116+
</script>
117+
118+
<body onload="runTest()">
119+
<p>Test that an &lt;iframe&gt; in the page tree holds its frame's current document as the frame moves between processes, and that removing an &lt;iframe&gt; unsplices its frame target's document.</p>
120+
<iframe id="late-frame"></iframe>
121+
<iframe id="removed-frame" src="http://localhost:8000/site-isolation/inspector/dom/resources/dom-frame.html?removed=1"></iframe>
122+
</body>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Test that a spliced frame document returns to pending, without being destroyed, when the tree holding its <iframe> is rebuilt, and splices again once the <iframe> arrives.
2+
3+
4+
5+
== Running test suite: SiteIsolation.DOM.FrameDocumentSplicing.Teardown
6+
-- Running test case: Setup
7+
PASS: Should find the child frame target.
8+
PASS: Should find the grandchild frame target.
9+
PASS: The child frame's document should be spliced into the page's <iframe>.
10+
PASS: The grandchild frame's document should be spliced into the child frame's <iframe>.
11+
12+
-- Running test case: SiteIsolation.DOM.FrameDocumentSplicing.Teardown.PageDocumentReset
13+
PASS: The child frame's document should be unspliced.
14+
PASS: The child frame's document should not be destroyed.
15+
PASS: Should find the page's new <iframe>.
16+
PASS: The child frame target should keep the same document.
17+
PASS: The child frame's document should be spliced into the new <iframe>.
18+
19+
-- Running test case: SiteIsolation.DOM.FrameDocumentSplicing.Teardown.ParentFrameDocumentReset
20+
PASS: The grandchild frame's document should be unspliced.
21+
PASS: The grandchild frame's document should not be destroyed.
22+
PASS: The grandchild frame's document should still be registered.
23+
PASS: The child frame target should produce a new document.
24+
PASS: Should find the child frame's new <iframe>.
25+
PASS: The grandchild frame target should keep the same document.
26+
PASS: The grandchild frame's document should be spliced into the child frame's new <iframe>.
27+

0 commit comments

Comments
 (0)