1
0
Fork 0
firefox/testing/web-platform/tests/custom-elements/registries/template.window.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

25 lines
1.5 KiB
JavaScript

test(() => {
const template = document.createElement("template");
assert_false(template.hasAttribute("shadowrootcustomelementregistry"));
assert_equals(template.shadowRootCustomElementRegistry, "");
template.shadowRootCustomElementRegistry = "blah";
assert_equals(template.getAttribute("shadowrootcustomelementregistry"), "blah");
assert_equals(template.shadowRootCustomElementRegistry, "blah");
}, "shadowRootCustomElementRegistry reflects as string");
test(() => {
const div = document.createElement("div");
div.setHTMLUnsafe(`<div><template shadowrootmode=open shadowrootcustomelementregistry shadowrootserializable></template></div>`);
assert_equals(div.firstChild.firstChild, null);
assert_equals(div.getHTML({ serializableShadowRoots: true }), "<div><template shadowrootmode=\"open\" shadowrootserializable=\"\" shadowrootcustomelementregistry=\"\"></template></div>");
}, "Serializing a ShadowRoot with a null registry");
test(() => {
const div = document.createElement("div");
div.setHTMLUnsafe(`<div><template shadowrootmode=open shadowrootcustomelementregistry shadowrootserializable></template></div>`);
const registry = new CustomElementRegistry();
registry.initialize(div.firstChild.shadowRoot);
assert_equals(div.firstChild.shadowRoot.customElementRegistry, registry);
assert_equals(div.getHTML({ serializableShadowRoots: true }), "<div><template shadowrootmode=\"open\" shadowrootserializable=\"\" shadowrootcustomelementregistry=\"\"></template></div>");
}, "Serializing a ShadowRoot with a registry that differs from its host");