From f3ebc7700c503d8773c1e40d29aa6fb572bd230b Mon Sep 17 00:00:00 2001 From: Sam Sneddon Date: Thu, 13 Apr 2023 08:38:26 +0000 Subject: [PATCH] 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 https://github.com/html5lib/html5lib-tests/pull/165 -- wpt-commits: ff2fcb22027c36f71122179189800392ac906d12 wpt-pr: 39474 --- testing/web-platform/tests/html/syntax/parsing/test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testing/web-platform/tests/html/syntax/parsing/test.js b/testing/web-platform/tests/html/syntax/parsing/test.js index 6dc6e19f3ec0a..e725107b80d89 100644 --- a/testing/web-platform/tests/html/syntax/parsing/test.js +++ b/testing/web-platform/tests/html/syntax/parsing/test.js @@ -211,7 +211,12 @@ function test_fragment(iframe, t, test_id, uri_encoded_input, escaped_expected, container_elem = document.createElement(container); } container_elem.innerHTML = input_string; - var serialized_dom = test_serializer(container_elem); + var serialized_dom; + if (container_elem.namespaceURI === namespaces["html"] && container_elem.localName === "template") { + serialized_dom = test_serializer(container_elem.content); + } else { + serialized_dom = test_serializer(container_elem); + } current_tests[iframe.id].actual = serialized_dom; serialized_dom = convert_innerHTML(serialized_dom); assert_equals(serialized_dom, expected); @@ -220,6 +225,7 @@ function test_fragment(iframe, t, test_id, uri_encoded_input, escaped_expected, function convert_innerHTML(serialized_dom) { var lines = serialized_dom.split("\n"); + assert_not_equals(lines[0], "