-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Document-write.html
74 lines (67 loc) · 2.38 KB
/
Document-write.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
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/helper.sub.js"></script>
<body>
<script>
// TrustedHTML assignments do not throw.
test(t => {
let p = createHTML_policy(window, 1);
let html = p.createHTML(INPUTS.HTML);
document.write(html);
assert_true(document.body.innerText.indexOf(RESULTS.HTML) !== -1);
}, "document.write with html assigned via policy (successful transformation).");
test(t => {
document.body.innerText = '';
let p = createHTML_policy(window, 1);
let html = p.createHTML(INPUTS.HTML);
document.writeln(html);
assert_true(document.body.innerText.indexOf(RESULTS.HTML) !== -1);
}, "document.writeln with html assigned via policy (successful transformation).");
test(t => {
document.body.innerText = '';
let p = createHTML_policy(window, 1);
let a = p.createHTML("abcdef");
let b = p.createHTML("ghijkl");
document.write(a, b);
assert_equals(document.body.innerText, "abcdefghijkl");
}, "document.write(TrustedHTML, TrustedHTML)");
test(t => {
document.body.innerText = '';
let p = createHTML_policy(window, 1);
let a = p.createHTML("abcdef");
let b = p.createHTML("ghijkl");
document.writeln(a, b);
assert_equals(document.body.innerText, "abcdefghijkl");
}, "document.writeln(TrustedHTML, TrustedHTML)");
test(t => {
document.body.innerText = '';
let p = createHTML_policy(window, 1);
let a = p.createHTML("abcdef");
let b = "ghijkl";
document.write(a, b);
assert_equals(document.body.innerText, "abcdefghijkl");
}, "document.write(TrustedHTML, String)");
test(t => {
document.body.innerText = '';
let p = createHTML_policy(window, 1);
let a = p.createHTML("abcdef");
let b = "ghijkl";
document.writeln(a, b);
assert_equals(document.body.innerText, "abcdefghijkl");
}, "document.writeln(TrustedHTML, String)");
test(t => {
document.body.innerText = '';
let a = "abcdef";
let b = "ghijkl";
document.write(a, b);
assert_equals(document.body.innerText, "abcdefghijkl");
}, "document.write(String, String)");
test(t => {
document.body.innerText = '';
let a = "abcdef";
let b = "ghijkl";
document.writeln(a, b);
assert_equals(document.body.innerText, "abcdefghijkl");
}, "document.writeln(String, String)");
</script>