Skip to content

Commit

Permalink
Implement TrustedTypes.emptyHTML
Browse files Browse the repository at this point in the history
Bug: 936436
Change-Id: Iaedc27556016d037c4b66f05393131ec06ed9042
  • Loading branch information
Stefano Sanfilippo authored and chromium-wpt-export-bot committed May 15, 2019
1 parent 19fdbf6 commit 4a7b062
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions trusted-types/TrustedTypePolicyFactory-constants.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<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 *">
<body>
<script>
test(t => {
const empty = TrustedTypes.emptyHTML;
assert_true(TrustedTypes.isHTML(empty));
assert_equals(empty.toString(), "");
}, 'TrustedTypes.emptyHTML returns the intended value.');

test(t => {
try { TrustedTypes.emptyHTML = 'fake'; } catch { }
assert_true(TrustedTypes.isHTML(TrustedTypes.emptyHTML));
assert_equals(TrustedTypes.emptyHTML.toString(), "");
}, 'TrustedTypes.emptyHTML cannot be redefined.');

test(t => {
try { Object.defineProperty(TrustedTypes, 'emptyHTML', 'fake'); } catch { }
assert_true(TrustedTypes.isHTML(TrustedTypes.emptyHTML));
assert_equals(TrustedTypes.emptyHTML.toString(), "");
}, 'TrustedTypes.emptyHTML cannot be redefined via defineProperty.');
</script>

0 comments on commit 4a7b062

Please sign in to comment.