-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
inserting-iframe-should-not-perform-microtask-checkpoint.html
62 lines (53 loc) · 1.6 KB
/
inserting-iframe-should-not-perform-microtask-checkpoint.html
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
<!DOCTYPE html>
<html>
<body>
<p>This tests inserting an empty iframe after scheduling a microtask.<br>
WebKit should not perform a microtask checkpoint.</p>
<pre id="log"></pre>
<script>
let logCount = 0;
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.dumpAsText();
}
const testCases = [
{name: 'empty', test: (iframe) => {}},
{name: 'about:blank', test: (iframe) => iframe.src = 'about:blank'},
{name: 'hello.html', test: (iframe) => iframe.src = 'resources/hello.html'},
{name: 'data URL', test: (iframe) => iframe.src = 'data:text/html,<!DOCTYPE html>data'},
{name: 'srcdoc', test: (iframe) => iframe.srcdoc = '<!DOCTYPE html>srcdoc'},
]
function test(name, testFunction) {
function log(message) {
document.getElementById('log').textContent += `${message}\n`;
}
return new Promise((resolve) => {
document.getElementById('log').textContent += `\n${name}\n`;
queueMicrotask(() => {
log('microtask');
});
const iframe = document.createElement("iframe");
iframe.onload = () => {
log('load event');
setTimeout(nextTest);
}
testFunction(iframe);
log('begin inserting iframe');
document.body.appendChild(iframe);
log('end inserting iframe');
});
}
onload = nextTest;
let testIndex = 0;
function nextTest() {
if (testIndex >= testCases.length) {
if (window.testRunner)
testRunner.notifyDone();
return;
}
test(testCases[testIndex].name, testCases[testIndex].test);
testIndex++;
}
</script>
</body>
</html>