diff --git a/custom-elements/adopted-callback.html b/custom-elements/adopted-callback.html index 5c08a04a4210d7..0134ba55e40c91 100644 --- a/custom-elements/adopted-callback.html +++ b/custom-elements/adopted-callback.html @@ -117,6 +117,38 @@ }); }, 'Moving the shadow host of a custom element from the owner document into ' + documentName + ' must enqueue and invoke adoptedCallback'); + promise_test(function () { + return getDocument().then(function (doc) { + var instance = document.createElement('my-custom-element'); + var host = document.createElement('div'); + var shadowRoot = host.attachShadow({mode: 'closed'}); + shadowRoot.appendChild(instance); + document.body.appendChild(host); + + calls = []; + doc.documentElement.appendChild(shadowRoot); + assert_array_equals(calls, ['disconnected', 'adopted', document, doc, 'connected']); + }); + }, 'Moving the shadow host\'s shadow of a custom element from the owner document into ' + documentName + ' must enqueue and invoke adoptedCallback'); + + promise_test(function () { + return getDocument().then(function (doc) { + var instance = document.createElement('my-custom-element'); + var host = document.createElement('template'); + var shadowRoot = host.content; + shadowRoot.appendChild(instance); + document.body.appendChild(host); + + calls = []; + doc.documentElement.appendChild(shadowRoot); + if (documentName === "the document of the template elements") { + assert_array_equals(calls, ['connected']); + } else { + assert_array_equals(calls, ['adopted', shadowRoot.ownerDocument, doc, 'connected']); + } + }); + }, 'Moving the