Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 4 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /custom-elements/revamped-scoped-registry/ShadowRoot-init-customElements.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(() => {
const shadowRoot = document.createElement('div').attachShadow({mode: 'closed'});
assert_equals(shadowRoot.customElements, window.customElements);
}, 'A newly attached disconnected ShadowRoot should use the global registry by default');
test(() => {
const host = document.body.appendChild(document.createElement('div'));
const shadowRoot = host.attachShadow({mode: 'closed'});
assert_equals(shadowRoot.customElements, window.customElements);
}, 'A newly attached connected ShadowRoot should use the global registry by default');
test(() => {
const registry = new CustomElementRegistry;
const shadowRoot = document.createElement('div').attachShadow({mode: 'closed', customElements: registry});
assert_equals(shadowRoot.customElements, registry);
}, 'A newly attached disconnected ShadowRoot should use the scoped registry if explicitly specified in attachShadow');
test(() => {
const registry = new CustomElementRegistry;
const host = document.body.appendChild(document.createElement('div'));
const shadowRoot = host.attachShadow({mode: 'closed', customElements: registry});
assert_equals(shadowRoot.customElements, registry);
}, 'A newly attached connected ShadowRoot should use the scoped registry if explicitly specified in attachShadow');
test(() => {
const host = document.body.appendChild(document.createElement('div'));
host.attachShadow({mode: 'closed', customElements: null});
}, 'attachShadow() should not throw for a null customElements value');
</script>
</body>
</html>