forked from devpunks/snuggsi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.spec.html
47 lines (45 loc) · 1.43 KB
/
index.spec.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
<meta charset=UTF-8>
<title>javascript URL string return values</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
const testInputs = [
[0x41],
[0x80,0xFF],
[0x80,0xFF,0x100],
[0xD83D,0xDE0D],
[0xDE0D,0x41]
];
testInputs.forEach(input => {
const javascriptURL = "javascript:[" + input + "].map(b => String.fromCharCode(b)).join('')",
output = input.map(b => String.fromCharCode(b)).join("");
async_test(t => {
const frame = document.createElement("iframe");
t.add_cleanup(() => frame.remove());
frame.src = javascriptURL;
t.step_timeout(() => {
assert_equals(frame.contentDocument.body.textContent, output);
assert_equals(frame.contentDocument.charset, document.charset);
t.done();
}, 200);
document.body.appendChild(frame);
});
async_test(t => {
const frame = document.createElement("iframe"),
href = document.createElement("a");
t.add_cleanup(() => { frame.remove(); href.remove(); });
frame.name = "hi" + input;
href.target = "hi" + input;
href.href = javascriptURL;
t.step_timeout(() => {
assert_equals(frame.contentDocument.body.textContent, output);
assert_equals(frame.contentDocument.charset, document.charset);
t.done();
}, 200)
document.body.appendChild(frame);
document.body.appendChild(href);
href.click();
});
});
</script>