From 9da4afa6c6b0eab00a9d993a863e7cd5daa916dc Mon Sep 17 00:00:00 2001 From: Blink WPT Bot Date: Mon, 23 Dec 2024 16:23:57 -0800 Subject: [PATCH] [Sanitizer] Add tests for safe + unsafe cases. (#49761) This tests for differences between setHTML and setHTMLUnsafe. Since the html5lib testcase format only supports one result per testcase, we use two testcase files with identical inputs, one each with the expectations for safe and unsafe variants. Also, a drive-by fix for an issue uncovered by the tests: The spec demands we block insertion in a xxx +#document +|
+| "Hello" +| "xxx" + +#data +
Helloxxx +#config +{ "elements": ["div", "script"] } +#document +|
+| "Hello" +| "xxx" + +#data +Helloxxx +#document +| +| "Hello" +| "xxx" + +#data + +#document +| +| src="https://bla.com/blubb" + +#data + +#config +{ "attributes": ["src", "onclick", "one"]} +#document +| +| one="two" +| src="https://bla.com/blubb" + diff --git a/sanitizer-api/sethtml-safety.tentative.html b/sanitizer-api/sethtml-safety.tentative.html new file mode 100644 index 00000000000000..d7a10c0477be80 --- /dev/null +++ b/sanitizer-api/sethtml-safety.tentative.html @@ -0,0 +1,49 @@ + + +Testcases from the previous Sanitizer API + + + + + + + + diff --git a/sanitizer-api/sethtml-unsafety.dat b/sanitizer-api/sethtml-unsafety.dat new file mode 100644 index 00000000000000..b83004dfcb8e9e --- /dev/null +++ b/sanitizer-api/sethtml-unsafety.dat @@ -0,0 +1,61 @@ +#data +test +#document-fragment +script +#document +| "test" + +#data +

Hello

+#document-fragment +script +#document +| "

Hello

" + +#data +
Helloxxx +#document +|
+| "Hello" +| xxx +#config +{ "elements": ["div", "script"] } +#document +|
+| "Hello" +| xxx +#document +| +| "Hello" +| +| "World" +| "xxx" + +#data + +#document +| +| onclick="2+2" +| one="two" +| src="https://bla.com/blubb" + +#data + +#config +{ "attributes": ["src", "onclick", "one"]} +#document +| +| onclick="2+2" +| one="two" +| src="https://bla.com/blubb" +