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

Side by Side Diff: third_party/WebKit/LayoutTests/custom-elements/spec/insert-a-node-try-to-upgrade.html

Issue 2144993002: CustomElements: insert a node (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor linebreak change Created 4 years, 5 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Custom Elements: Insert a node should try to upgrade</title> 2 <title>Custom Elements: Insert a node should try to upgrade</title>
3 <script src="../../resources/testharness.js"></script> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="resources/custom-elements-helpers.js"></script> 5 <script src="resources/custom-elements-helpers.js"></script>
6 <body> 6 <body>
7 <script> 7 <script>
8 'use strict'; 8 'use strict';
9 9
10 function assert_invocations(invocations, element, length, i) {
11 assert_equals(invocations.length, length, length == 2 ? 'inserting into differ ent node should enqueue connectedCallback again' : 'inserting an element should enqueue connectedCallback reaction');
12 assert_array_equals(invocations[i].slice(0, 2), ['connected', element], 'inser ting "custom" element should enqueue a connectedCallback reaction');
13 assert_array_equals(invocations[i][2], [], 'connectedCallback should be invoke d with empty argument list');
14 }
15
10 // Insert a node 16 // Insert a node
11 // https://dom.spec.whatwg.org/#concept-node-insert 17 // https://dom.spec.whatwg.org/#concept-node-insert
18 // 6.5.2.1 If inclusiveDescendant is custom, then enqueue a custom element callb ack reaction
19 // with inclusiveDescendant, callback name "connectedCallback", and an empty arg ument list.
20 test_with_window(w => {
21 let element = w.document.createElement('a-a');
22 let invocations = [];
23 w.customElements.define('a-a', class extends w.HTMLElement {
24 connectedCallback() { invocations.push(['connected', this, arguments]); }
25 });
26 w.document.body.appendChild(element);
27 assert_invocations(invocations, element, 1, 0);
28 w.document.head.appendChild(element);
29 assert_invocations(invocations, element, 2, 1);
30 }, 'Insert a node that is "custom" should enqueue connectedCallback');
31
12 // 6.5.2.2. try to upgrade inclusiveDescendant. 32 // 6.5.2.2. try to upgrade inclusiveDescendant.
13 // Try to upgrade an element 33 // Try to upgrade an element
14 // https://html.spec.whatwg.org/multipage/scripting.html#concept-try-upgrade 34 // https://html.spec.whatwg.org/multipage/scripting.html#concept-try-upgrade
15 test_with_window(w => { 35 test_with_window(w => {
16 let element = w.document.createElement('a-a'); 36 let element = w.document.createElement('a-a');
17 37
18 w.customElements.define('a-a', class extends w.HTMLElement { 38 w.customElements.define('a-a', class extends w.HTMLElement {
19 constructor() { 39 constructor() {
20 super(); 40 super();
21 this.is_upgraded = true; 41 this.is_upgraded = true;
22 } 42 }
23 }); 43 });
24 assert_false('is_upgraded' in element); 44 assert_false('is_upgraded' in element);
25 assert_false(element.matches(':defined')); 45 assert_false(element.matches(':defined'));
26 46
27 w.document.body.appendChild(element); 47 w.document.body.appendChild(element);
28 assert_true(element.is_upgraded); 48 assert_true(element.is_upgraded);
29 assert_true(element.matches(':defined')); 49 assert_true(element.matches(':defined'));
30 }, 'Insert a node should try to upgrade'); 50 }, 'Insert a node should try to upgrade');
31 </script> 51 </script>
32 </body> 52 </body>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698