diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/tests/mochitest/webcomponents/test_template_xhtml.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/tests/mochitest/webcomponents/test_template_xhtml.html')
-rw-r--r-- | dom/tests/mochitest/webcomponents/test_template_xhtml.html | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/dom/tests/mochitest/webcomponents/test_template_xhtml.html b/dom/tests/mochitest/webcomponents/test_template_xhtml.html new file mode 100644 index 0000000000..b14e5c365a --- /dev/null +++ b/dom/tests/mochitest/webcomponents/test_template_xhtml.html @@ -0,0 +1,46 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1011831 +--> +<head> + <title>Test for template element</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011831">Bug 1011831</a> +<script> +var docSrc = + '<!DOCTYPE html>' + + '<html xmlns="http://www.w3.org/1999/xhtml">' + + '<body>' + + '<template id="t">Content<span>Content</span></template>' + + '<div id="container"><template>One</template><div>Two</div></div>' + + '<template id="t2"></template>' + + '</body>' + + '</html>'; + +var doc = (new DOMParser()).parseFromString(docSrc, 'application/xhtml+xml'); + +var t = doc.getElementById("t"); +is(t.childNodes.length, 0, "Template should have no children."); +is(t.content.childNodes.length, 2, "Template content should have two children, text node and a span."); + +// Test serialization of template element. +is(t.innerHTML, 'Content<span xmlns="http://www.w3.org/1999/xhtml">Content</span>', "Template contents should be serialized."); +is(t.outerHTML, '<template xmlns="http://www.w3.org/1999/xhtml" id="t">Content<span>Content</span></template>', "Template contents should be serialized."); + +var c = doc.getElementById("container"); +is(c.innerHTML, '<template xmlns="http://www.w3.org/1999/xhtml">One</template><div xmlns="http://www.w3.org/1999/xhtml">Two</div>', "Template contents should be serialized."); +is(c.outerHTML, '<div xmlns="http://www.w3.org/1999/xhtml" id="container"><template>One</template><div>Two</div></div>', "Template contents should be serialized."); + +// Test setting innerHTML on template element. +var t2 = doc.getElementById("t2"); +t2.innerHTML = 'Three<span>Four</span>'; +is(t2.childNodes.length, 0, "Setting innerHTML should append children into template content."); +is(t2.content.childNodes.length, 2, "Setting innerHTML should append children into template content."); + +</script> +</body> +</html> |