Skip to content

Commit

Permalink
Bug 1907849: part 9) Extend WPT to check sink value of "Document pars…
Browse files Browse the repository at this point in the history
…eHTMLUnsafe". r=smaug

One step towards fixing w3c/trusted-types#494.

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

UltraBlame original commit: c006cb26e155686ac4c27d2a0797ff2ce03e39a8
  • Loading branch information
marco-c committed Jan 1, 2025
1 parent ffdb670 commit 186a430
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 186a430

Please sign in to comment.