tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit f681ad30b28da43c66d360c7bc400629e231c995
parent ce262f8577c500eb441d9e9d6ccf9198791e19a3
Author: Anne van Kesteren <annevk@annevk.nl>
Date:   Wed, 26 Nov 2025 09:00:39 +0000

Bug 2001299 [wpt PR 56134] - More shadowrootcustomelementregistry attribute serialization tests, a=testonly

Automatic update from web-platform-tests
More shadowrootcustomelementregistry attribute serialization tests

And another declarative shadow root test.

For https://github.com/whatwg/html/issues/11892 and https://github.com/whatwg/html/issues/11947.
--

wpt-commits: 6bfc9216ddc2919a2e57c0e217f7cea03d23567e
wpt-pr: 56134

Diffstat:
Mtesting/web-platform/tests/custom-elements/registries/template.window.js | 46+++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/testing/web-platform/tests/custom-elements/registries/template.window.js b/testing/web-platform/tests/custom-elements/registries/template.window.js @@ -17,9 +17,53 @@ test(() => { test(() => { const div = document.createElement("div"); + div.setHTMLUnsafe(`<div><template shadowrootmode=open shadowrootserializable></template></div>`); + assert_equals(div.firstChild.firstChild, null); + assert_equals(div.firstChild.shadowRoot.customElementRegistry, customElements); + assert_equals(div.getHTML({ serializableShadowRoots: true }), "<div><template shadowrootmode=\"open\" shadowrootserializable=\"\"></template></div>"); +}, "Serializing a ShadowRoot with a global 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 document"); + +test(() => { + const div = document.implementation.createHTMLDocument().createElement("div"); + assert_equals(div.customElementRegistry, null); + div.setHTMLUnsafe(`<div><template shadowrootmode=open shadowrootcustomelementregistry shadowrootserializable></template></div>`); + assert_equals(div.firstChild.shadowRoot.customElementRegistry, null); + assert_equals(div.getHTML({ serializableShadowRoots: true }), "<div><template shadowrootmode=\"open\" shadowrootserializable=\"\"></template></div>"); +}, "Serializing a ShadowRoot with a null registry with a null registry host document"); + +test(() => { + const div = document.implementation.createHTMLDocument().createElement("div"); + assert_equals(div.customElementRegistry, null); 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"); +}, "Serializing a ShadowRoot with a registry with a null registry host document"); + +test(() => { + const registry = new CustomElementRegistry(); + const hostDocument = document.implementation.createHTMLDocument(); + registry.initialize(hostDocument); + assert_equals(hostDocument.customElementRegistry, registry); + const host = hostDocument.createElement('div'); + const shadow = host.attachShadow({ mode: "closed", serializable: true, customElementRegistry: null }); + assert_equals(host.getHTML({ serializableShadowRoots: true }), `<template shadowrootmode="closed" shadowrootserializable="" shadowrootcustomelementregistry=""></template>`); +}, "Serializing a ShadowRoot with a null registry with a scoped registry host document"); + +test(() => { + const registry = new CustomElementRegistry(); + const element = document.createElement('a-b', { customElementRegistry: registry }); + element.setHTMLUnsafe(`<a-b><template shadowrootmode="open"></template></a-b>`); + assert_equals(element.firstChild.customElementRegistry, registry); + assert_equals(element.firstChild.shadowRoot.customElementRegistry, customElements); +}, "A declarative shadow root gets its default registry from its node document");