Skip to content

Commit 19a30ae

Browse files
committed
Cover Element streamHTMLUnsafe sink name in createParserOptions order tests
1 parent 63ab5f3 commit 19a30ae

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎domparsing/stream-html-with-trusted-types-createParserOptions-order.html‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
createParserOptions(options, type, sink),
2222
});
2323

24-
for (const pos of ["Before", "After", "ReplaceWith", "Append", "Prepend"]) {
24+
for (const pos of ["", "Before", "After", "ReplaceWith", "Append", "Prepend"]) {
2525
const method_name = `stream${pos}HTMLUnsafe`;
2626
const expected_iface =
27-
pos === "Append" || pos === "Prepend" ? "Element" : "Node";
27+
pos === "" || pos === "Append" || pos === "Prepend" ? "Element" : "Node";
2828
test((t) => {
2929
let recorded_type = null;
3030
let recorded_sink = null;
@@ -40,15 +40,21 @@
4040
// Append and Prepend only have a hierarchy check for the html element.
4141
const element = document.createElement(
4242
pos === "Append" || pos === "Prepend" ? "html" : "div");
43+
if (pos === "") {
44+
element.appendChild(document.createElement("span"));
45+
}
4346
try {
4447
element[method_name]();
4548
assert_unreached("Should have thrown");
4649
} catch (e) {
4750
assert_equals(e.message, "createParserOptions called");
4851
assert_equals(recorded_type, "TrustedHTMLParserOptions");
4952
assert_equals(recorded_sink, `${expected_iface} ${method_name}`);
53+
if (pos === "") {
54+
assert_equals(element.childNodes.length, 1);
55+
}
5056
}
51-
}, `${method_name} checks createParserOptions before hierarchy checks`);
57+
}, `${method_name} checks createParserOptions before ${pos === "" ? "clearing children" : "hierarchy checks"}`);
5258
}
5359

5460
for (const pos of ["Before", "After", "ReplaceWith"]) {

0 commit comments

Comments
 (0)