<!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="trusted-types *">
</head>
<body>
<script>
// TrustedURL assignments do not throw.
test(t => {
document.body.innerText = '';
let p = createHTML_policy(window, 1);
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 => {
const old = document.body.innerText;
assert_throws(new TypeError(), _ => {
document.write('A string');
});
assert_equals(document.body.innerText, old);
}, "`document.write(string)` throws");
// Null assignment throws.
test(t => {
const old = document.body.innerText;
assert_throws(new TypeError(), _ => {
document.write(null);
});
assert_equals(document.body.innerText, old);
}, "`document.write(null)` throws");
</script>