Skip to content

Commit 9ae5417

Browse files
TimothyGumoz-wptsync-bot
authored andcommitted
Bug 1485521 [wpt PR 12636] - HTML: document.open() and document's URL, a=testonly
Automatic update from web-platform-testsHTML: document.open() and document's URL (#12636) For whatwg/html#3946. Adapts the basic test in web-platform-tests/wpt#10817 for a number of advanced scenarios regarding document activity. Co-authored-by: Anne van Kesteren <annevk@annevk.nl> -- wpt-commits: 312d71258a26bfa420f7eef100df4ef92d961483 wpt-pr: 12636
1 parent c158539 commit 9ae5417

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

testing/web-platform/meta/MANIFEST.json

+10
Original file line numberDiff line numberDiff line change
@@ -365683,6 +365683,12 @@
365683365683
{}
365684365684
]
365685365685
],
365686+
"html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url.window.js": [
365687+
[
365688+
"/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url.window.html",
365689+
{}
365690+
]
365691+
],
365686365692
"html/webappapis/microtask-queuing/queue-microtask-exceptions.any.js": [
365687365693
[
365688365694
"/html/webappapis/microtask-queuing/queue-microtask-exceptions.any.html",
@@ -606806,6 +606812,10 @@
606806606812
"e275a4987a0859b160a0f91de6c8896b90bdab31",
606807606813
"testharness"
606808606814
],
606815+
"html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url.window.js": [
606816+
"282e58e9c380fc214365522163c8bc09a67afc3b",
606817+
"testharness"
606818+
],
606809606819
"html/webappapis/microtask-queuing/queue-microtask-exceptions.any.js": [
606810606820
"01f32ac9ba14962fa99d4b263a8ca0f5a0daa161",
606811606821
"testharness"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
test(t => {
2+
const frame = document.body.appendChild(document.createElement("iframe"));
3+
t.add_cleanup(() => frame.remove());
4+
assert_equals(frame.contentDocument.URL, "about:blank");
5+
assert_equals(frame.contentWindow.location.href, "about:blank");
6+
frame.contentDocument.open();
7+
assert_equals(frame.contentDocument.URL, document.URL);
8+
assert_equals(frame.contentWindow.location.href, document.URL);
9+
}, "document.open() changes document's URL (fully active document)");
10+
11+
async_test(t => {
12+
const blankURL = new URL("/common/blank.html", document.URL).href;
13+
const frameURL = new URL("resources/page-with-frame.html", document.URL).href;
14+
const frame = document.body.appendChild(document.createElement("iframe"));
15+
t.add_cleanup(() => frame.remove());
16+
frame.onload = t.step_func(() => {
17+
assert_equals(frame.contentDocument.URL, frameURL);
18+
assert_equals(frame.contentWindow.location.href, frameURL);
19+
const childFrame = frame.contentDocument.querySelector("iframe");
20+
const childDoc = childFrame.contentDocument;
21+
const childWin = childFrame.contentWindow;
22+
assert_equals(childDoc.URL, blankURL);
23+
assert_equals(childWin.location.href, blankURL);
24+
25+
// Right now childDoc is still fully active.
26+
27+
frame.onload = t.step_func_done(() => {
28+
// Now childDoc is still active but no longer fully active.
29+
childDoc.open();
30+
assert_equals(childDoc.URL, blankURL);
31+
assert_equals(childWin.location.href, blankURL);
32+
});
33+
frame.src = "/common/blank.html";
34+
});
35+
frame.src = frameURL;
36+
}, "document.open() does not change document's URL (active but not fully active document)");
37+
38+
test(t => {
39+
const frame = document.body.appendChild(document.createElement("iframe"));
40+
t.add_cleanup(() => frame.remove());
41+
const doc = frame.contentDocument;
42+
43+
// Right now the frame is connected and it has an active document.
44+
assert_equals(doc.URL, "about:blank");
45+
46+
frame.remove();
47+
48+
// Now the frame is no longer connected. Its document is no longer active.
49+
assert_equals(doc.URL, "about:blank");
50+
assert_equals(doc.open(), doc);
51+
assert_equals(doc.URL, "about:blank");
52+
}, "document.open() does not change document's URL (non-active document with an associated Window object; frame is removed)");
53+
54+
async_test(t => {
55+
const frame = document.createElement("iframe");
56+
t.add_cleanup(() => frame.remove());
57+
58+
frame.onload = t.step_func(() => {
59+
const doc = frame.contentDocument;
60+
// Right now the frame is connected and it has an active document.
61+
assert_equals(doc.URL, "about:blank");
62+
63+
frame.onload = t.step_func_done(() => {
64+
// Now even though the frame is still connected, its document is no
65+
// longer active.
66+
assert_not_equals(frame.contentDocument, doc);
67+
assert_equals(doc.URL, "about:blank");
68+
assert_equals(doc.open(), doc);
69+
assert_equals(doc.URL, "about:blank");
70+
});
71+
72+
frame.src = "/common/blank.html";
73+
});
74+
75+
// We need to connect the frame after the load event is set up to mitigate
76+
// against https://crbug.com/569511.
77+
document.body.appendChild(frame);
78+
}, "document.open() does not change document's URL (non-active document with an associated Window object; navigated away)");
79+
80+
test(t => {
81+
const frame = document.body.appendChild(document.createElement("iframe"));
82+
t.add_cleanup(() => frame.remove());
83+
const doc = frame.contentDocument.implementation.createHTMLDocument();
84+
assert_equals(doc.URL, "about:blank");
85+
assert_equals(doc.open(), doc);
86+
assert_equals(doc.URL, "about:blank");
87+
}, "document.open() does not change document's URL (non-active document without an associated Window object)");

0 commit comments

Comments
 (0)