blob: bc7f8882f1a759b800364f62b7c5d3acdd258221 (
plain) (
blame)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>document.write test</title>
<script>
window.onload = function() {
const success = document.body.innerHTML == document.querySelector("style").textContent;
while (document.body.childNodes[0])
document.body.childNodes[0].remove();
document.body.innerHTML = success ? "Success" : "Fail";
}
let checkpointCounter = 0;
function checkpoint(n) {
if (++checkpointCounter != n)
throw new TypeError(`Checkpoint failed: expected ${n} but got ${checkpointCounter}`);
}
</script>
<style><h1>Main title</h1>
<p>Text.</p>
<script>
document.write(`<h2>Subtitle</h2>
<script>
checkpoint(1);
</scr` + `ipt>
`);
checkpoint(2);
document.write(`
<script>
checkpoint(3);
document.write(
'<p>before subtext</p>\\n' +
'<script>\\n' +
'checkpoint(4);\\n' +
'document.write("third nest");\\n' +
'</scr' + 'ipt>\\n'
);
</scr` + `ipt>
<p>fin</p>
`);
</script><h2>Subtitle</h2>
<script>
checkpoint(1);
</script>
<script>
checkpoint(3);
document.write(
'<p>before subtext</p>\n' +
'<script>\n' +
'checkpoint(4);\n' +
'document.write("third nest");\n' +
'</scr' + 'ipt>\n'
);
</script><p>before subtext</p>
<script>
checkpoint(4);
document.write("third nest");
</script>third nest
<p>fin</p>
<p>Subtext.</p>
</style>
<script>
document.write("<h1>Main title</h1>");
</script>
</head>
<body>
<p>Text.</p>
<script>
document.write(`<h2>Subtitle</h2>
<script>
checkpoint(1);
</scr` + `ipt>
`);
checkpoint(2);
document.write(`
<script>
checkpoint(3);
document.write(
'<p>before subtext</p>\\n' +
'<script>\\n' +
'checkpoint(4);\\n' +
'document.write("third nest");\\n' +
'</scr' + 'ipt>\\n'
);
</scr` + `ipt>
<p>fin</p>
`);
</script>
<p>Subtext.</p>
</body>
</html>
|