|
21 | 21 | createParserOptions(options, type, sink), |
22 | 22 | }); |
23 | 23 |
|
24 | | - for (const pos of ["Before", "After", "ReplaceWith", "Append", "Prepend"]) { |
| 24 | + for (const pos of ["", "Before", "After", "ReplaceWith", "Append", "Prepend"]) { |
25 | 25 | const method_name = `stream${pos}HTMLUnsafe`; |
26 | 26 | const expected_iface = |
27 | | - pos === "Append" || pos === "Prepend" ? "Element" : "Node"; |
| 27 | + pos === "" || pos === "Append" || pos === "Prepend" ? "Element" : "Node"; |
28 | 28 | test((t) => { |
29 | 29 | let recorded_type = null; |
30 | 30 | let recorded_sink = null; |
|
40 | 40 | // Append and Prepend only have a hierarchy check for the html element. |
41 | 41 | const element = document.createElement( |
42 | 42 | pos === "Append" || pos === "Prepend" ? "html" : "div"); |
| 43 | + if (pos === "") { |
| 44 | + element.appendChild(document.createElement("span")); |
| 45 | + } |
43 | 46 | try { |
44 | 47 | element[method_name](); |
45 | 48 | assert_unreached("Should have thrown"); |
46 | 49 | } catch (e) { |
47 | 50 | assert_equals(e.message, "createParserOptions called"); |
48 | 51 | assert_equals(recorded_type, "TrustedHTMLParserOptions"); |
49 | 52 | assert_equals(recorded_sink, `${expected_iface} ${method_name}`); |
| 53 | + if (pos === "") { |
| 54 | + assert_equals(element.childNodes.length, 1); |
| 55 | + } |
50 | 56 | } |
51 | | - }, `${method_name} checks createParserOptions before hierarchy checks`); |
| 57 | + }, `${method_name} checks createParserOptions before ${pos === "" ? "clearing children" : "hierarchy checks"}`); |
52 | 58 | } |
53 | 59 |
|
54 | 60 | for (const pos of ["Before", "After", "ReplaceWith"]) { |
|
0 commit comments