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
  • Loading branch information
mbrodesser-Igalia committed Dec 30, 2024
1 parent a93dfdd commit 04cc105
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 04cc105

Please sign in to comment.