From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../tests/sanitizer-api/support/testcases.sub.js | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 testing/web-platform/tests/sanitizer-api/support/testcases.sub.js (limited to 'testing/web-platform/tests/sanitizer-api/support') diff --git a/testing/web-platform/tests/sanitizer-api/support/testcases.sub.js b/testing/web-platform/tests/sanitizer-api/support/testcases.sub.js new file mode 100644 index 0000000000..1a5989fb73 --- /dev/null +++ b/testing/web-platform/tests/sanitizer-api/support/testcases.sub.js @@ -0,0 +1,88 @@ +const testcases = [ + {config_input: {}, value: "test", result: "test", message: "string"}, + {config_input: {}, value: "bla", result: "bla", message: "html fragment"}, + {config_input: {}, value: "test", result: "test", message: "document"}, + {config_input: {}, value: "
test", result: "
test
", message: "html without close tag"}, + {config_input: {}, value: "", result: "

Click.

", message: "dropAttributes list {\"data-attribute-with-dashes\": [\"*\"]} with dom dataset js access"}, + {config_input: {allowAttributes: {"id": ["div"]}}, value: "

P

DIV
", result: "

P

DIV
", message: "allowAttributes list {\"id\": [\"div\"]} with id attribute"}, + {config_input: {allowAttributes: {"id": ["*"]}}, value: "

Click.

", result: "

Click.

", message: "allowAttributes list {\"id\": [\"*\"]} with id attribute and onclick scripts"}, + {config_input: {allowAttributes: {"*": ["a"]}}, value: "Click.
div
", result: "Click.
div
", message: "allowAttributes list {\"*\": [\"a\"]} with style attribute"}, + {config_input: {dropAttributes: {"style": ["*"]}, allowAttributes: {"style": ["*"]}}, value: "

Click.

", result: "

Click.

", message: "allowAttributes list has no influence to dropAttributes"}, + {config_input: {allowElements: ["template", "div"]}, value: "", result: "", message: "Template element"}, + {config_input: {}, value: "Click.", result: "Click.", message: "HTMLAnchorElement with javascript protocal"}, + {config_input: {}, value: "Click.", result: "Click.", message: "HTMLAnchorElement with javascript protocal start with space"}, + {config_input: {}, value: "Click.", result: "Click.", message: "HTMLAnchorElement"}, + {config_input: {}, value: "Click.", result: "Click.", message: "HTMLAreaElement with javascript protocal"}, + {config_input: {}, value: "Click.", result: "Click.", message: "HTMLAreaElement with javascript protocal start with space"}, + {config_input: {}, value: "Click.", result: "Click.", message: "HTMLAreaElement"}, + {config_input: {}, value: "
Click.
", result: "
Click.
", message: "HTMLFormElement with javascript action"}, + {config_input: {}, value: "
Click.
", result: "
Click.
", message: "HTMLFormElement with javascript action start with space"}, + {config_input: {}, value: "
Click.
", result: "
Click.
", message: "HTMLFormElement"}, + {config_input: {}, value: "Click.", result: "Click.", message: "HTMLInputElement with javascript formaction"}, + {config_input: {}, value: "Click.", result: "Click.", message: "HTMLInputElement with javascript formaction start with space"}, + {config_input: {}, value: "Click.", result: "Click.", message: "HTMLInputElement"}, + {config_input: {}, value: "", result: "", message: "HTMLButtonElement with javascript formaction"}, + {config_input: {}, value: "", result: "", message: "HTMLButtonElement with javascript formaction start with space"}, + {config_input: {}, value: "", result: "", message: "HTMLButtonElement"}, + {config_input: {}, value: "

Some text

Some more text

", result: "

Some text

Some more text

", message: "malformed HTML"}, + {config_input: {}, value: "

Some text

Some more text

", result: "

Some text

Some more text

", message: "HTML with comments; comments not allowed"}, + {config_input: {allowComments: true}, value: "

Some text

Some more text

", result: "

Some text

Some more text

", message: "HTML with comments; allowComments"}, + {config_input: {allowComments: false}, value: "

Some text

Some more text

", result: "

Some text

Some more text

", message: "HTML with comments; !allowComments"}, + {config_input: {}, value: "

commentintext

", result: "

commentintext

", message: "HTML with comments deeper in the tree"}, + {config_input: {allowComments: true}, value: "

commentintext

", result: "

commentintext

", message: "HTML with comments deeper in the tree, allowComments"}, + {config_input: {allowComments: false}, value: "

commentintext

", result: "

commentintext

", message: "HTML with comments deeper in the tree, !allowComments"}, + {config_input: {allowElements: ["svg"]}, value: "", result: "", message: "Unknown HTML names (HTMLUnknownElement instances) should not match elements parsed as non-HTML namespaces."}, + {config_input: {allowElements: ["div", "svg"]}, value: "
", result: "
", message: "Unknown HTML names (HTMLUnknownElement instances) should not match elements parsed as non-HTML namespaces when nested."}, + + // Case normalization (actually: lack of) + {config_input: {dropElements: ["I", "DL"]}, value: "
balabala
test
", result: "
balabala
test
", message: "dropElements list [\"I\", \"DL\"]}"}, + {config_input: {dropElements: ["i", "dl"]}, value: "
balabala
test
", result: "
balabala
", message: "dropElements list [\"i\", \"dl\"]}"}, + {config_input: {dropElements: ["i", "dl"]}, value: "
balabala
test
", result: "
balabala
", message: "dropElements list [\"i\", \"dl\"]} with uppercase HTML"}, + {config_input: {dropAttributes: {"ID": ["*"]}}, value: "

Click.

", result: "

Click.

", message: "dropAttributes list {\"ID\": [\"*\"]} with id attribute"}, + {config_input: {dropAttributes: {"ID": ["*"]}}, value: "

Click.

", result: "

Click.

", message: "dropAttributes list {\"ID\": [\"*\"]} with ID attribute"}, + {config_input: {dropAttributes: {"id": ["*"]}}, value: "

Click.

", result: "

Click.

", message: "dropAttributes list {\"id\": [\"*\"]} with ID attribute"}, + + // allowUnknownMarkup for elements (with and without) + {config_input: {dropElements: [123, [], "test", "i", "custom-element"]}, value: "
balabalatest
tcustom-element", result: "
balabala
", message: "dropElements with unknown elements and without allowUnknownMarkup"}, + {config_input: {blockElements: [123, [], "test", "i", "custom-element"]}, value: "
balabalatest
tcustom-element", result: "
balabalatest
", message: "blockElements with unknown elements and without allowUnknownMarkup"}, + {config_input: {allowElements: ["p", "test"]}, value: "
test
p
tt

div

test", result: "testptt

div

", message: "allowElements with unknown elements and without allowUnknownMarkup"}, + {config_input: {dropElements: [123, [], "test", "i", "custom-element"], allowUnknownMarkup: true}, value: "
balabalatest
tcustom-element", result: "
balabala
", message: "dropElements with unknown elements and with allowUnknownMarkup"}, + {config_input: {blockElements: [123, [], "test", "i", "custom-element"], allowUnknownMarkup: true}, value: "
balabalatest
tcustom-element", result: "
balabalatest
t", message: "blockElements with unknown elements and with allowUnknownMarkup"}, + {config_input: {allowElements: ["p", "test"], allowUnknownMarkup: true}, value: "
test
p
tt

div

test
", result: "testptt

div

test", message: "allowElements with unknown elements and with allowUnknownMarkup"}, + + // allowUnknownMarkup for attributes (with and without) + {config_input: {allowAttributes: {"hello": ["*"], "world": ["b"]}}, value: "
", result: "
", message: "allowAttributes unknown attributes and without allowUnknownMarkup"}, + {config_input: {allowAttributes: {"hello": ["*"], "world": ["b"]}, allowUnknownMarkup: true}, value: "
", result: "
", message: "allowAttributes unknown attributes and with allowUnknownMarkup"}, + {config_input: {dropAttributes: {"hello": ["*"], "world": ["b"]}}, value: "
", result: "
", message: "dropAttributes unknown attributes and without allowUnknownMarkup"}, + {config_input: {dropAttributes: {"hello": ["*"], "world": ["b"]}, allowUnknownMarkup: true}, value: "
", result: "
", message: "dropAttributes unknown attributes and with allowUnknownMarkup"}, +]; -- cgit v1.2.3