diff --git a/testing/web-platform/tests/shadow-dom/declarative/element-internals-shadowroot.tentative.html b/testing/web-platform/tests/shadow-dom/declarative/element-internals-shadowroot.tentative.html index 8469a6c1f1ff..aeaa322a31c2 100644 --- a/testing/web-platform/tests/shadow-dom/declarative/element-internals-shadowroot.tentative.html +++ b/testing/web-platform/tests/shadow-dom/declarative/element-internals-shadowroot.tentative.html @@ -108,6 +108,23 @@ assert_throws_dom('NotSupportedError', () => element.attachInternals(), 'attachInternals forbidden by disabledFeatures, post-upgrade'); }, 'ElementInternals disabled by disabledFeatures'); - - +test(() => { + let constructed = false; + const element = document.createElement('x-6'); + const sr = element.attachShadow({mode: 'closed'}); + assert_true(sr instanceof ShadowRoot); + customElements.define('x-6', class extends HTMLElement { + constructor() { + super(); + assert_throws_dom('NotSupportedError', () => this.attachShadow({mode:'open'}), 'attachShadow already called'); + const elementInternals = this.attachInternals(); + assert_equals(elementInternals.shadowRoot, null, 'ElementInternals.shadowRoot should not be available for pre-attached shadow'); + constructed = true; + } + }); + assert_false(constructed); + customElements.upgrade(element); + assert_true(constructed,'Failed to construct - test failed'); + assert_equals(element.shadowRoot, null, 'shadow root is closed'); +}, 'ElementInternals.shadowRoot doesn\'t reveal pre-attached closed shadowRoot');