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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/custom-elements/connected-callbacks.html

Issue 2408083002: Revert of Import wpt@357b83b809e3cbc7a1805e7c3ca108a7980d782f (Closed)
Patch Set: 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: connectedCallback</title> 4 <title>Custom Elements: connectedCallback</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="connectedCallback must be enqueued whenever custom element is inserted into a document"> 6 <meta name="assert" content="connectedCallback must be enqueued whenever custom element is inserted into a 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/custom-elements-helpers.js"></script> 10 <script src="resources/document-types.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', this); } 18 connectedCallback() { calls.push('connected', this); }
19 disconnectedCallback() { calls.push('disconnected', this); } 19 disconnectedCallback() { calls.push('disconnected', this); }
20 } 20 }
21 customElements.define('my-custom-element', MyCustomElement); 21 customElements.define('my-custom-element', MyCustomElement);
22 22
23 document_types().forEach(function (entry) { 23 DocumentTypes.forEach(function (entry) {
24 var documentName = entry.name; 24 var documentName = entry.name;
25 var getDocument = entry.create; 25 var getDocument = entry.create;
26 26
27 promise_test(function () { 27 promise_test(function () {
28 return getDocument().then(function (doc) { 28 return getDocument().then(function (doc) {
29 var instance = document.createElement('my-custom-element'); 29 var instance = document.createElement('my-custom-element');
30 calls = []; 30 calls = [];
31 doc.documentElement.appendChild(instance); 31 doc.documentElement.appendChild(instance);
32 assert_array_equals(calls, ['connected', instance]); 32 assert_array_equals(calls, ['connected', instance]);
33 }); 33 });
34 }, 'Inserting a custom element into ' + documentName + ' must enqueue and in voke connectedCallback'); 34 }, 'Inserting a custom element into a ' + documentName + ' must enqueue and invoke connectedCallback');
35 35
36 promise_test(function () { 36 promise_test(function () {
37 return getDocument().then(function (doc) { 37 return getDocument().then(function (doc) {
38 var instance = document.createElement('my-custom-element'); 38 var instance = document.createElement('my-custom-element');
39 var parent = document.createElement('div'); 39 var parent = document.createElement('div');
40 parent.appendChild(instance); 40 parent.appendChild(instance);
41 calls = []; 41 calls = [];
42 doc.documentElement.appendChild(parent); 42 doc.documentElement.appendChild(parent);
43 assert_array_equals(calls, ['connected', instance]); 43 assert_array_equals(calls, ['connected', instance]);
44 }); 44 });
45 }, 'Inserting an ancestor of custom element into ' + documentName + ' must e nqueue and invoke connectedCallback'); 45 }, 'Inserting an ancestor of custom element into a ' + documentName + ' must enqueue and invoke connectedCallback');
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 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div' ); 50 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div' );
51 var shadowRoot = host.attachShadow({mode: 'closed'}); 51 var shadowRoot = host.attachShadow({mode: 'closed'});
52 doc.documentElement.appendChild(host); 52 doc.documentElement.appendChild(host);
53 53
54 calls = []; 54 calls = [];
55 shadowRoot.appendChild(instance); 55 shadowRoot.appendChild(instance);
56 assert_array_equals(calls, ['connected', instance]); 56 assert_array_equals(calls, ['connected', instance]);
57 }); 57 });
58 }, 'Inserting a custom element into a shadow tree in ' + documentName + ' mu st enqueue and invoke connectedCallback'); 58 }, 'Inserting a custom element into a shadow tree in a ' + documentName + ' must enqueue and invoke connectedCallback');
59 59
60 promise_test(function () { 60 promise_test(function () {
61 return getDocument().then(function (doc) { 61 return getDocument().then(function (doc) {
62 var instance = document.createElement('my-custom-element'); 62 var instance = document.createElement('my-custom-element');
63 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div' ); 63 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div' );
64 var shadowRoot = host.attachShadow({mode: 'closed'}); 64 var shadowRoot = host.attachShadow({mode: 'closed'});
65 shadowRoot.appendChild(instance); 65 shadowRoot.appendChild(instance);
66 66
67 calls = []; 67 calls = [];
68 doc.documentElement.appendChild(host); 68 doc.documentElement.appendChild(host);
69 assert_array_equals(calls, ['connected', instance]); 69 assert_array_equals(calls, ['connected', instance]);
70 }); 70 });
71 }, 'Inserting the shadow host of a custom element into ' + documentName + ' must enqueue and invoke connectedCallback'); 71 }, 'Inserting the shadow host of a custom element into a ' + documentName + ' must enqueue and invoke connectedCallback');
72 72
73 promise_test(function () { 73 promise_test(function () {
74 return getDocument().then(function (doc) { 74 return getDocument().then(function (doc) {
75 var instance = document.createElement('my-custom-element'); 75 var instance = document.createElement('my-custom-element');
76 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div' ); 76 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div' );
77 var shadowRoot = host.attachShadow({mode: 'closed'}); 77 var shadowRoot = host.attachShadow({mode: 'closed'});
78 78
79 calls = []; 79 calls = [];
80 shadowRoot.appendChild(instance); 80 shadowRoot.appendChild(instance);
81 assert_array_equals(calls, []); 81 assert_array_equals(calls, []);
82 }); 82 });
83 }, 'Inserting a custom element into a detached shadow tree that belongs to ' + documentName + ' must not enqueue and invoke connectedCallback'); 83 }, 'Inserting a custom element into a detached shadow tree that belongs to a ' + documentName + ' must not enqueue and invoke connectedCallback');
84 }); 84 });
85 85
86 </script> 86 </script>
87 </body> 87 </body>
88 </html> 88 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698