Skip to content

Commit

Permalink
part 14) Add WPTs for checking parseFromString's trusted types' sin…
Browse files Browse the repository at this point in the history
…k string of the default policy.

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

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1907849
gecko-commit: 4b9f0161c5ae020946dbc2063b8263682cfab762
gecko-reviewers: smaug
  • Loading branch information
mbrodesser-Igalia authored and moz-wptsync-bot committed Dec 31, 2024
1 parent 91408f6 commit 0669ef6
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@

// 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, type, sink) => {
assert_equals(sink, "DOMParser parseFromString");
return createHTMLJS(value);
}
});

let parser = new DOMParser();
let doc = parser.parseFromString(INPUTS.HTML, "text/html");
assert_equals(doc.body.innerText, RESULTS.HTML);
Expand Down

0 comments on commit 0669ef6

Please sign in to comment.