1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<!DOCTYPE html>
<meta charset="UTF-8">
<title>
Content synchronously added to iframe/opened window's document after creation
won't get replaced asynchronously when staying on the initial empty document
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<body></body>
<script>
"use strict";
// Asserts the document on |w| stays the same after waiting 100ms.
function assertDocumentStaysTheSame(t, w) {
const initialDocument = w.document;
initialDocument.body.innerHTML = "foo";
return new Promise((resolve) => {
t.step_timeout(() => {
assert_equals(w.document.body.innerHTML, "foo");
assert_equals(w.document, initialDocument);
resolve();
}, 100);
});
}
promise_test(async t => {
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
await assertDocumentStaysTheSame(t, iframe.contentWindow);
}, "Content synchronously added to <iframe> with no src won't get replaced");
promise_test(async t => {
const iframe = document.createElement("iframe");
iframe.src = "";
document.body.appendChild(iframe);
await assertDocumentStaysTheSame(t, iframe.contentWindow);
}, "Content synchronously added to <iframe> with src='' won't get replaced");
promise_test(async t => {
const iframe = document.createElement("iframe");
iframe.src = "about:blank";
document.body.appendChild(iframe);
await assertDocumentStaysTheSame(t, iframe.contentWindow);
}, "Content synchronously added to <iframe> with src='about:blank' won't get replaced");
promise_test(async t => {
const iframe = document.createElement("iframe");
iframe.src = "about:blank#foo";
document.body.appendChild(iframe);
await assertDocumentStaysTheSame(t, iframe.contentWindow);
}, "Content synchronously added to <iframe> with src='about:blank#foo' won't get replaced");
promise_test(async t => {
const iframe = document.createElement("iframe");
iframe.src = "about:blank?foo";
document.body.appendChild(iframe);
await assertDocumentStaysTheSame(t, iframe.contentWindow);
}, "Content synchronously added to <iframe> with src='about:blank?foo' won't get replaced");
promise_test(async t => {
const w = window.open();
await assertDocumentStaysTheSame(t, w);
}, "Content synchronously added to window.open()-ed document won't get replaced");
promise_test(async t => {
const w = window.open("");
await assertDocumentStaysTheSame(t, w);
}, "Content synchronously added to window.open('')-ed document won't get replaced");
promise_test(async t => {
const w = window.open("about:blank");
await assertDocumentStaysTheSame(t, w);
}, "Content synchronously added to window.open('about:blank')-ed document won't get replaced");
promise_test(async t => {
const w = window.open("about:blank#foo");
await assertDocumentStaysTheSame(t, w);
}, "Content synchronously added to window.open('about:blank#foo')-ed document won't get replaced");
promise_test(async t => {
const w = window.open("about:blank?foo");
await assertDocumentStaysTheSame(t, w);
}, "Content synchronously added to window.open('about:blank?foo')-ed document won't get replaced");
</script>
|