Source code

Revision control

Other Tools

Test Info:

  • This test was skipped 110 times in the preceding 7 days.
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/helper.sub.js"></script>
</head>
<body>
<div id="container"></div>
<script>
const container = document.querySelector("#container");
const policy = window.trustedTypes.createPolicy("policy", {
createScript: t => t,
});
function stringify(arg) {
return "textContent" in arg.__proto__ ? arg.textContent : arg.toString()
}
// This test case mirrors the block-Node-multiple-arguments case except
// that, because Trusted Types is not enabled, no exceptions should be
// thrown anyhwere.
const targets = ["div", "script"];
const all_args = [
[ policy.createScript("'createScript';") ],
[ policy.createScript("'cresteScript #1';"), policy.createScript("'#2;'") ],
[ "'plain text';" ],
[ "'plain text #1';", "'plain text #2';" ],
[ document.createTextNode("'node';") ],
[ document.createTextNode("'node #1';"),
document.createTextNode("'node #2';") ],
[ "'mixed';", document.createTextNode("'node';") ],
[ "'mixed';", policy.createScript("'script';") ],
[ document.createTextNode("'node';"),
policy.createScript("'script';") ],
];
for (target of targets) {
for (args of all_args) {
for (setter of [container.replaceWith, container.after, container.before]) {
test(t => {
var outer = document.createElement(target);
container.appendChild(outer);
var inner = document.createElement("p");
outer.appendChild(inner);
setter.apply(inner, args);
assert_equals(outer.textContent, args.map(stringify).join(""));
}, `${setter.name}(${args.toString()}) on <${target}> should pass`);
}
for (setter of [container.append, container.prepend]) {
test(t => {
let outer = document.createElement(target);
container.appendChild(outer);
setter.apply(outer, args);
assert_equals(outer.textContent, args.map(stringify).join(""));
}, `${setter.name}(${args.toString()}) on <${target}> should pass`);
}
}
}
</script>
</body>
</html>