Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/custom-elements/adopted-callback.html

Issue 2408493002: Import wpt@357b83b809e3cbc7a1805e7c3ca108a7980d782f (Closed)
Patch Set: Added one more win7-specific baseline Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Custom Elements: adoptedCallback</title> 4 <title>Custom Elements: adoptedCallback</title>
5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> 5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
6 <meta name="assert" content="adoptedCallback must be enqueued whenever custom el ement is adopted into a new document"> 6 <meta name="assert" content="adoptedCallback must be enqueued whenever custom el ement is adopted into a new document">
7 <link rel="help" href="https://w3c.github.io/webcomponents/spec/custom/#dfn-conn ected-callback"> 7 <link rel="help" href="https://w3c.github.io/webcomponents/spec/custom/#dfn-conn ected-callback">
8 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharness.js"></script>
9 <script src="/resources/testharnessreport.js"></script> 9 <script src="/resources/testharnessreport.js"></script>
10 <script src="./resources/document-types.js"></script> 10 <script src="./resources/custom-elements-helpers.js"></script>
11 </head> 11 </head>
12 <body> 12 <body>
13 <div id="log"></div> 13 <div id="log"></div>
14 <script> 14 <script>
15 15
16 var calls = []; 16 var calls = [];
17 class MyCustomElement extends HTMLElement { 17 class MyCustomElement extends HTMLElement {
18 connectedCallback() { calls.push('connected'); } 18 connectedCallback() { calls.push('connected'); }
19 adoptedCallback(oldDocument, newDocument) { calls.push('adopted'); calls.pus h(oldDocument); calls.push(newDocument); } 19 adoptedCallback(oldDocument, newDocument) { calls.push('adopted'); calls.pus h(oldDocument); calls.push(newDocument); }
20 disconnectedCallback() { calls.push('disconnected'); } 20 disconnectedCallback() { calls.push('disconnected'); }
21 } 21 }
22 customElements.define('my-custom-element', MyCustomElement); 22 customElements.define('my-custom-element', MyCustomElement);
23 23
24 test(function () { 24 test(function () {
25 var instance = document.createElement('my-custom-element'); 25 var instance = document.createElement('my-custom-element');
26 calls = []; 26 calls = [];
27 document.body.appendChild(instance); 27 document.body.appendChild(instance);
28 assert_array_equals(calls, ['connected']); 28 assert_array_equals(calls, ['connected']);
29 }, 'Inserting a custom element into the owner document must not enqueue and invo ke adoptedCallback'); 29 }, 'Inserting a custom element into the owner document must not enqueue and invo ke adoptedCallback');
30 30
31 DocumentTypes.forEach(function (entry) { 31 document_types().forEach(function (entry) {
32 if (entry.isOwner) 32 if (entry.isOwner)
33 return; 33 return;
34 34
35 var documentName = entry.name; 35 var documentName = entry.name;
36 var getDocument = entry.create; 36 var getDocument = entry.create;
37 37
38 promise_test(function () { 38 promise_test(function () {
39 return getDocument().then(function (doc) { 39 return getDocument().then(function (doc) {
40 var instance = document.createElement('my-custom-element'); 40 var instance = document.createElement('my-custom-element');
41 calls = []; 41 calls = [];
42 doc.documentElement.appendChild(instance); 42 doc.documentElement.appendChild(instance);
43 assert_array_equals(calls, ['adopted', document, doc, 'connected']); 43 assert_array_equals(calls, ['adopted', document, doc, 'connected']);
44 }); 44 });
45 }, 'Inserting a custom element into a ' + documentName + ' must enqueue and invoke adoptedCallback'); 45 }, 'Inserting a custom element into ' + documentName + ' must enqueue and in voke adoptedCallback');
46 46
47 promise_test(function () { 47 promise_test(function () {
48 return getDocument().then(function (doc) { 48 return getDocument().then(function (doc) {
49 var instance = document.createElement('my-custom-element'); 49 var instance = document.createElement('my-custom-element');
50 document.body.appendChild(instance); 50 document.body.appendChild(instance);
51 calls = []; 51 calls = [];
52 doc.documentElement.appendChild(instance); 52 doc.documentElement.appendChild(instance);
53 assert_array_equals(calls, ['disconnected', 'adopted', document, doc , 'connected']); 53 assert_array_equals(calls, ['disconnected', 'adopted', document, doc , 'connected']);
54 }); 54 });
55 }, 'Moving a custom element from the owner document into a ' + documentName + ' must enqueue and invoke adoptedCallback'); 55 }, 'Moving a custom element from the owner document into ' + documentName + ' must enqueue and invoke adoptedCallback');
56 56
57 promise_test(function () { 57 promise_test(function () {
58 return getDocument().then(function (doc) { 58 return getDocument().then(function (doc) {
59 var instance = document.createElement('my-custom-element'); 59 var instance = document.createElement('my-custom-element');
60 var parent = document.createElement('div'); 60 var parent = document.createElement('div');
61 parent.appendChild(instance); 61 parent.appendChild(instance);
62 calls = []; 62 calls = [];
63 doc.documentElement.appendChild(parent); 63 doc.documentElement.appendChild(parent);
64 assert_array_equals(calls, ['adopted', document, doc, 'connected']); 64 assert_array_equals(calls, ['adopted', document, doc, 'connected']);
65 }); 65 });
66 }, 'Inserting an ancestor of custom element into a ' + documentName + ' must enqueue and invoke adoptedCallback'); 66 }, 'Inserting an ancestor of custom element into ' + documentName + ' must e nqueue and invoke adoptedCallback');
67 67
68 promise_test(function () { 68 promise_test(function () {
69 return getDocument().then(function (doc) { 69 return getDocument().then(function (doc) {
70 var instance = document.createElement('my-custom-element'); 70 var instance = document.createElement('my-custom-element');
71 var parent = document.createElement('div'); 71 var parent = document.createElement('div');
72 parent.appendChild(instance); 72 parent.appendChild(instance);
73 document.body.appendChild(parent); 73 document.body.appendChild(parent);
74 calls = []; 74 calls = [];
75 doc.documentElement.appendChild(parent); 75 doc.documentElement.appendChild(parent);
76 assert_array_equals(calls, ['disconnected', 'adopted', document, doc , 'connected']); 76 assert_array_equals(calls, ['disconnected', 'adopted', document, doc , 'connected']);
77 }); 77 });
78 }, 'Moving an ancestor of custom element from the owner document into a ' + documentName + ' must enqueue and invoke adoptedCallback'); 78 }, 'Moving an ancestor of custom element from the owner document into ' + do cumentName + ' must enqueue and invoke adoptedCallback');
79 79
80 promise_test(function () { 80 promise_test(function () {
81 return getDocument().then(function (doc) { 81 return getDocument().then(function (doc) {
82 var instance = document.createElement('my-custom-element'); 82 var instance = document.createElement('my-custom-element');
83 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div' ); 83 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div' );
84 var shadowRoot = host.attachShadow({mode: 'closed'}); 84 var shadowRoot = host.attachShadow({mode: 'closed'});
85 doc.documentElement.appendChild(host); 85 doc.documentElement.appendChild(host);
86 86
87 calls = []; 87 calls = [];
88 shadowRoot.appendChild(instance); 88 shadowRoot.appendChild(instance);
89 assert_array_equals(calls, ['adopted', document, doc, 'connected']); 89 assert_array_equals(calls, ['adopted', document, doc, 'connected']);
90 }); 90 });
91 }, 'Inserting a custom element into a shadow tree in a ' + documentName + ' must enqueue and invoke adoptedCallback'); 91 }, 'Inserting a custom element into a shadow tree in ' + documentName + ' mu st enqueue and invoke adoptedCallback');
92 92
93 promise_test(function () { 93 promise_test(function () {
94 return getDocument().then(function (doc) { 94 return getDocument().then(function (doc) {
95 var instance = document.createElement('my-custom-element'); 95 var instance = document.createElement('my-custom-element');
96 var host = document.createElement('div'); 96 var host = document.createElement('div');
97 var shadowRoot = host.attachShadow({mode: 'closed'}); 97 var shadowRoot = host.attachShadow({mode: 'closed'});
98 shadowRoot.appendChild(instance); 98 shadowRoot.appendChild(instance);
99 99
100 calls = []; 100 calls = [];
101 doc.documentElement.appendChild(host); 101 doc.documentElement.appendChild(host);
102 assert_array_equals(calls, ['adopted', document, doc, 'connected']); 102 assert_array_equals(calls, ['adopted', document, doc, 'connected']);
103 }); 103 });
104 }, 'Inserting the shadow host of a custom element into a ' + documentName + ' must enqueue and invoke adoptedCallback'); 104 }, 'Inserting the shadow host of a custom element into ' + documentName + ' must enqueue and invoke adoptedCallback');
105 105
106 promise_test(function () { 106 promise_test(function () {
107 return getDocument().then(function (doc) { 107 return getDocument().then(function (doc) {
108 var instance = document.createElement('my-custom-element'); 108 var instance = document.createElement('my-custom-element');
109 var host = document.createElement('div'); 109 var host = document.createElement('div');
110 var shadowRoot = host.attachShadow({mode: 'closed'}); 110 var shadowRoot = host.attachShadow({mode: 'closed'});
111 shadowRoot.appendChild(instance); 111 shadowRoot.appendChild(instance);
112 document.body.appendChild(host); 112 document.body.appendChild(host);
113 113
114 calls = []; 114 calls = [];
115 doc.documentElement.appendChild(host); 115 doc.documentElement.appendChild(host);
116 assert_array_equals(calls, ['disconnected', 'adopted', document, doc , 'connected']); 116 assert_array_equals(calls, ['disconnected', 'adopted', document, doc , 'connected']);
117 }); 117 });
118 }, 'Moving the shadow host of a custom element from the owner document into a ' + documentName + ' must enqueue and invoke adoptedCallback'); 118 }, 'Moving the shadow host of a custom element from the owner document into ' + documentName + ' must enqueue and invoke adoptedCallback');
119 119
120 promise_test(function () { 120 promise_test(function () {
121 return getDocument().then(function (doc) { 121 return getDocument().then(function (doc) {
122 var instance = document.createElement('my-custom-element'); 122 var instance = document.createElement('my-custom-element');
123 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div' ); 123 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div' );
124 var shadowRoot = host.attachShadow({mode: 'closed'}); 124 var shadowRoot = host.attachShadow({mode: 'closed'});
125 125
126 calls = []; 126 calls = [];
127 shadowRoot.appendChild(instance); 127 shadowRoot.appendChild(instance);
128 assert_array_equals(calls, ['adopted', document, doc]); 128 assert_array_equals(calls, ['adopted', document, doc]);
129 }); 129 });
130 }, 'Inserting a custom element into a detached shadow tree that belongs to a ' + documentName + ' must enqueue and invoke adoptedCallback'); 130 }, 'Inserting a custom element into a detached shadow tree that belongs to ' + documentName + ' must enqueue and invoke adoptedCallback');
131 }); 131 });
132 132
133 </script> 133 </script>
134 </body> 134 </body>
135 </html> 135 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698