Skip to content

Commit

Permalink
also add custom elements tests
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Apr 15, 2019
1 parent 4bcb95b commit 5bf98d8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions custom-elements/adopted-callback.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 <template>\'s content 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');
Expand Down

0 comments on commit 5bf98d8

Please sign in to comment.