From 0669ef6dc697a069926084ea2031213e9864a39a Mon Sep 17 00:00:00 2001 From: Mirko Brodesser Date: Mon, 30 Dec 2024 09:46:13 +0000 Subject: [PATCH] part 14) Add WPTs for checking `parseFromString`'s trusted types' sink 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 --- ...ck-string-assignment-to-DOMParser-parseFromString.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/trusted-types/block-string-assignment-to-DOMParser-parseFromString.html b/trusted-types/block-string-assignment-to-DOMParser-parseFromString.html index dd912e6b8dea59..6dbebd29a43486 100644 --- a/trusted-types/block-string-assignment-to-DOMParser-parseFromString.html +++ b/trusted-types/block-string-assignment-to-DOMParser-parseFromString.html @@ -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);