Skip to content

Commit f3ebc77

Browse files
gsneddersmoz-wptsync-bot
authored andcommitted
Bug 1827435 [wpt PR 39474] - Fix html5lib test serialization with #document-fragment: template, a=testonly
Automatic update from web-platform-tests Fix html5lib test serialization with #document-fragment: template When innerHTML is applied to a template, it uses the template's template contents as its context object, which means we need to serialize that and not the element itself. See also html5lib/html5lib-tests#165 -- wpt-commits: ff2fcb22027c36f71122179189800392ac906d12 wpt-pr: 39474
1 parent 91476b1 commit f3ebc77

File tree

1 file changed

+7
-1
lines changed
  • testing/web-platform/tests/html/syntax/parsing

1 file changed

+7
-1
lines changed

testing/web-platform/tests/html/syntax/parsing/test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ function test_fragment(iframe, t, test_id, uri_encoded_input, escaped_expected,
211211
container_elem = document.createElement(container);
212212
}
213213
container_elem.innerHTML = input_string;
214-
var serialized_dom = test_serializer(container_elem);
214+
var serialized_dom;
215+
if (container_elem.namespaceURI === namespaces["html"] && container_elem.localName === "template") {
216+
serialized_dom = test_serializer(container_elem.content);
217+
} else {
218+
serialized_dom = test_serializer(container_elem);
219+
}
215220
current_tests[iframe.id].actual = serialized_dom;
216221
serialized_dom = convert_innerHTML(serialized_dom);
217222
assert_equals(serialized_dom, expected);
@@ -220,6 +225,7 @@ function test_fragment(iframe, t, test_id, uri_encoded_input, escaped_expected,
220225

221226
function convert_innerHTML(serialized_dom) {
222227
var lines = serialized_dom.split("\n");
228+
assert_not_equals(lines[0], "<template>", "template is never the innerHTML context object");
223229
lines[0] = "#document";
224230
return lines.join("\n");
225231
}

0 commit comments

Comments
 (0)