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

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: 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 // Insert a node 10 // Insert a node
11 // https://dom.spec.whatwg.org/#concept-node-insert 11 // https://dom.spec.whatwg.org/#concept-node-insert
12 // 6.5.2.1 If inclusiveDescendant is custom, then enqueue a custom element callb ack reaction
13 // with inclusiveDescendant, callback name "connectedCallback", and an empty arg ument list.
14 test_with_window(w => {
15 let element = w.document.createElement('a-a');
16 let invocations = [];
17 let connectedCallback_args;
18 w.customElements.define('a-a', class extends w.HTMLElement {
19 constructor() { super(); }
dominicc (has gone to gerrit) 2016/07/13 06:19:06 You can omit this line; I think an ES6 class gets
20 connectedCallback() {
21 invocations.push(['connected', this]);
22 connectedCallback_args = arguments;
23 }
24 });
25 w.document.body.appendChild(element);
26 assert_true(element.matches(':defined'));
27 w.document.body.appendChild(element);
28 assert_equals(invocations.length, 1, 'connectedCallback should be invoked only once');
dominicc (has gone to gerrit) 2016/07/13 06:19:05 Could you also assert the length is 1 before line
29 assert_array_equals(invocations[0], ['connected', element], 'insierting "custo m" element should enqueue a connectedCallback reaction');
dominicc (has gone to gerrit) 2016/07/13 06:19:05 Spelling--inserting
30 assert_array_equals(connectedCallback_args, [], 'connectedCallback should be i nvoked with empty argument list');
31 }, 'Insert a node that is "custom" should enqueue connectedCallback');
32
12 // 6.5.2.2. try to upgrade inclusiveDescendant. 33 // 6.5.2.2. try to upgrade inclusiveDescendant.
13 // Try to upgrade an element 34 // Try to upgrade an element
14 // https://html.spec.whatwg.org/multipage/scripting.html#concept-try-upgrade 35 // https://html.spec.whatwg.org/multipage/scripting.html#concept-try-upgrade
15 test_with_window(w => { 36 test_with_window(w => {
16 let element = w.document.createElement('a-a'); 37 let element = w.document.createElement('a-a');
17 38
18 w.customElements.define('a-a', class extends w.HTMLElement { 39 w.customElements.define('a-a', class extends w.HTMLElement {
19 constructor() { 40 constructor() {
20 super(); 41 super();
21 this.is_upgraded = true; 42 this.is_upgraded = true;
22 } 43 }
23 }); 44 });
24 assert_false('is_upgraded' in element); 45 assert_false('is_upgraded' in element);
25 assert_false(element.matches(':defined')); 46 assert_false(element.matches(':defined'));
26 47
27 w.document.body.appendChild(element); 48 w.document.body.appendChild(element);
28 assert_true(element.is_upgraded); 49 assert_true(element.is_upgraded);
29 assert_true(element.matches(':defined')); 50 assert_true(element.matches(':defined'));
30 }, 'Insert a node should try to upgrade'); 51 }, 'Insert a node should try to upgrade');
31 </script> 52 </script>
32 </body> 53 </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