Skip to content

Commit

Permalink
[Trusted Types] Obey TT in createHTMLDocument-create documents.
Browse files Browse the repository at this point in the history
This will pass on the Trusted Type enforcement requirement set by the CSP
header, but will not actually instantiate a TrustedTypePolicyFactory. That
plugs the current hole; but might not be an acceptable long-term solution.

Bug: 951536
Change-Id: I56d541d57184396ce1dacdac9236d9259189f621
  • Loading branch information
otherdaniel authored and chromium-wpt-export-bot committed Oct 30, 2019
1 parent 82cecba commit 7262315
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions trusted-types/trusted-types-createHTMLDocument.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/content-security-policy/support/testharness-helper.js"></script>
<meta http-equiv="Content-Security-Policy" content="trusted-types *">
</head>
<body>
<script>

test(t => {
function try_assign(doc) {
doc.createElement("script").textContent = "2+2";
}
assert_throws(new TypeError(),
_ => try_assign(document),
"Trusted Type assignment throws in main document");
assert_throws(new TypeError(),
_ => try_assign(document.implementation.createHTMLDocument('')),
"Trusted Type assignment throws in created document");
}, "Trusted Types work in createHTMLDocument");

</script>
</body>

0 comments on commit 7262315

Please sign in to comment.