Bug 1652760 [wpt PR 24589] - Dynamically test javascript URL string return values in frames, a=testonly

Automatic update from web-platform-tests
Dynamically test javascript URL string return values in frames (#24589)

Test javascript URL string return values in direct and indirect (target) frame contexts.
--

wpt-commits: 75e2f5ed99d4da9ead4eda71b78bfe1ec17bad9f
wpt-pr: 24589
This commit is contained in:
Rob Buis 2020-07-22 20:00:55 +00:00 коммит произвёл moz-wptsync-bot
Родитель 71d938690b
Коммит 2bad51638b
1 изменённых файлов: 51 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,51 @@
<!doctype html>
<meta charset=UTF-8>
<title>Test javascript URL string return values in direct and indirect (target) frame contexts.</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);
});
});
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"),
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>