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: cb3e58c8b7ff8d78bfab512fae053cc7de5d787b
gecko-reviewers: smaug
  • Loading branch information
mbrodesser-Igalia authored and moz-wptsync-bot committed Dec 18, 2024
1 parent ea4394f commit 902982a
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 902982a

Please sign in to comment.