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

Side by Side Diff: third_party/WebKit/LayoutTests/custom-elements/imports/connected-callback.html

Issue 2333673002: Add a test for {connected,disconnected}Callback in HTML Imports (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/custom-elements/imports/resources/connected-parsercreate.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <link id="import1" rel="import" href="resources/connected-upgrade.html">
5 <script>
6 'use strict';
7
8 let reactions = [];
9
10 customElements.define('a-a', class extends HTMLElement {
11 connectedCallback() {
12 reactions.push(this);
13 }
14 disconnectedCallback() {
15 reactions.push(this);
16 }
17 });
18 </script>
19 <link id="import2" rel="import" href="resources/connected-parsercreate.html">
20 <script>
21 'use strict';
22
23 test(() => {
24 let importDoc1 = import1.import;
25 let importDoc2 = import2.import;
26
27 let a = importDoc1.querySelector('#a');
28 let b = importDoc1.querySelector('#b');
29 let c = importDoc2.querySelector('#c');
30 let d = importDoc2.querySelector('#d');
31
32 assert_array_equals(reactions, [a, b, c, d],
33 'connectedCallback should be called for both upgrade and c reate.');
34
35 reactions = [];
36
37 d.remove();
38 c.remove();
39 b.remove();
40 a.remove();
41
42 assert_array_equals(reactions, [d, c, b, a],
43 'disconnectedCallback should be called in imports.');
44
45 reactions = [];
46
47 let div1 = document.createElement('div');
48 let div2 = document.createElement('div');
49 let div3 = document.createElement('div');
50
51 div1.appendChild(div2);
52 div1.appendChild(a);
53 div1.appendChild(div3);
54
55 div2.appendChild(d);
56 div2.appendChild(c);
57 div3.appendChild(b);
58
59 importDoc1.body.appendChild(div1);
60
61 assert_array_equals(reactions, [d, c, a, b],
62 'connectedCallback should be called in document order.');
63
64 reactions = [];
65
66 div1.remove();
67 assert_array_equals(reactions, [d, c, a, b],
68 'disconnectedCallback should be called in document order.' );
69 }, 'connectedCallback and disconnectedCallback should be invoked for elements in import');
70 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/custom-elements/imports/resources/connected-parsercreate.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698