Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /sanitizer-api/sethtml-with-trustedtypes-createParserOptions-null.html - WPT Dashboard Interop Dashboard
<!doctype html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<meta
http-equiv="Content-Security-Policy"
content="require-trusted-types-for 'script';"
/>
</head>
<body>
<div id="container"></div>
<script>
const container = document.querySelector("#container");
for (const returnValue of [null, undefined]) {
const policy = trustedTypes.createPolicy(`returns-${returnValue}`, {
createHTML: (html) => html,
createParserOptions: () => returnValue,
});
test(() => {
assert_throws_js(TypeError, () => {
policy.createParserOptions({});
});
}, `Named policy createParserOptions returning ${returnValue} throws TypeError`);
}
</script>
</body>
</html>