Skip to content

Commit

Permalink
part 9) Extend WPT to check sink value of "Document parseHTMLUnsafe".
Browse files Browse the repository at this point in the history
One step towards fixing w3c/trusted-types#494.

Differential Revision: https://phabricator.services.mozilla.com/D232363

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1907849
gecko-commit: c006cb26e155686ac4c27d2a0797ff2ce03e39a8
gecko-reviewers: smaug
  • Loading branch information
mbrodesser-Igalia authored and moz-wptsync-bot committed Dec 31, 2024
1 parent c8dde25 commit 0ecc6b7
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<script src="support/helper.sub.js"></script>

<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';">

<link rel="help" href="https://html.spec.whatwg.org/#dom-parsehtmlunsafe">
</head>
<body>
<script>
Expand All @@ -33,7 +35,12 @@

// After default policy creation string assignment implicitly calls createHTML.
test(t => {
let p = window.trustedTypes.createPolicy("default", { createHTML: createHTMLJS }, true);
let p = window.trustedTypes.createPolicy("default", { createHTML:
(value, _, sink) => {
assert_equals(sink, "Document parseHTMLUnsafe");
return createHTMLJS(value);
}
});
let doc = Document.parseHTMLUnsafe(INPUTS.HTML);
assert_equals(doc.body.innerText, RESULTS.HTML);
}, "'Document.parseHTMLUnsafe(string)' assigned via default policy (successful HTML transformation).");
Expand Down

0 comments on commit 0ecc6b7

Please sign in to comment.