blob: 28813d72e0e1833e25658e2210abb9b0a30b2137 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/helper.sub.js"></script>
<meta http-equiv="Content-Security-Policy" content="require-trusted-types">
</head>
<body>
<script>
// TrustedURL assignments do not throw.
async_test(t => {
createHTML_policy(window)
.then(t.step_func_done(p => {
let html = p.createHTML(INPUTS.HTML);
document.write(html);
assert_equals(document.body.innerText, RESULTS.HTML);
}));
}, "document.write with html assigned via policy (successful URL transformation).");
// String assignments throw.
test(t => {
assert_throws(new TypeError(), _ => {
document.write('A string');
});
}, "`document.write(string)` throws");
// Null assignment throws.
test(t => {
assert_throws(new TypeError(), _ => {
document.write(null);
});
}, "`document.write(null)` throws");
</script>