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

Side by Side Diff: third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html

Issue 2954843002: Fix upgrading built-in custom elements
Patch Set: Created 3 years, 6 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 <script src="../../resources/testharness.js"></script> 2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script> 3 <script src="../../resources/testharnessreport.js"></script>
4 <script src="resources/custom-elements-helpers.js"></script> 4 <script src="resources/custom-elements-helpers.js"></script>
5 <body> 5 <body>
6 <script> 6 <script>
7 'use strict'; 7 'use strict';
8 8
9 // Looks up the preceeding element (which should be a template 9 // Looks up the preceeding element (which should be a template
10 // element) and creates a Promise test. The test name is taken from 10 // element) and creates a Promise test. The test name is taken from
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 </a-a> 60 </a-a>
61 </template> 61 </template>
62 <script> 62 <script>
63 'use strict'; 63 'use strict';
64 64
65 test_with_content((w) => { 65 test_with_content((w) => {
66 assert_array_equals(w.invocations, 66 assert_array_equals(w.invocations,
67 ['constructor', 'x="y"', 'connected', 'script']); 67 ['constructor', 'x="y"', 'connected', 'script']);
68 }); 68 });
69 </script> 69 </script>
70 <!-- TODO: the test pass now due to the elements upgrade.
71 Creating synchronously built-in elements still needs to be implemente d."
72 -->
73 <template data-test="the parser synchronously creates built-in elements">
74 <script>
75 'use strict';
70 76
77 window.invocations = [];
78 customElements.define('d-d', class extends HTMLDivElement {
79 constructor() {
80 super();
81 invocations.push('constructor');
82 }
83 static get observedAttributes() { return ['is']; }
84 attributeChangedCallback(name, oldValue, newValue, nsuri) {
85 invocations.push(`${name}="${newValue}"`);
86 }
87 connectedCallback() {
88 invocations.push('connected');
89 }
90 }, {extends: 'div'});
91 </script>
92 <div is="d-d">
93 <script>
94 'use strict';
95
96 invocations.push('script');
97 </script>
98 </div>
99 </template>
100 <script>
101 'use strict';
102
103 test_with_content((w) => {
104 assert_array_equals(w.invocations,
105 ['constructor', 'is="d-d"', 'connected', 'script']);
106 });
107 </script>
71 <template data-test="foreign content insertion executes connected"> 108 <template data-test="foreign content insertion executes connected">
72 <script> 109 <script>
73 'use strict'; 110 'use strict';
74 111
75 customElements.define('a-a', class extends HTMLElement { 112 customElements.define('a-a', class extends HTMLElement {
76 constructor() { 113 constructor() {
77 super(); 114 super();
78 } 115 }
79 connectedCallback() { 116 connectedCallback() {
80 window.connectedChildNodeCount = this.childNodes.length; 117 window.connectedChildNodeCount = this.childNodes.length;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 'the element should have been created successfully'); 360 'the element should have been created successfully');
324 361
325 let elements = f.detached.querySelectorAll('a-a'); 362 let elements = f.detached.querySelectorAll('a-a');
326 console.log(f.invocations[0].parentNode); 363 console.log(f.invocations[0].parentNode);
327 assert_equals(elements.length, 2, 364 assert_equals(elements.length, 2,
328 'two elements should have been created'); 365 'two elements should have been created');
329 assert_equals(Object.getPrototypeOf(elements[1]), w.HTMLElement.prototype, 366 assert_equals(Object.getPrototypeOf(elements[1]), w.HTMLElement.prototype,
330 'the second element should be un-upgraded, not failed'); 367 'the second element should be un-upgraded, not failed');
331 }); 368 });
332 </script> 369 </script>
370
371 <template data-test="parsing upgrades the built-in element">
372 <div is="d-d"></div>
373 <script>
374 'use strict';
375
376 window.invocations = [];
377 customElements.define('d-d', class extends HTMLDivElement {
378 constructor() {
379 super();
380 invocations.push('constructor');
381 }
382 static get observedAttributes() { return ['is']; }
383 attributeChangedCallback(name, oldValue, newValue, nsuri) {
384 invocations.push(`${name}="${newValue}"`);
385 }
386 connectedCallback() {
387 invocations.push('connected');
388 }
389 }, {extends: 'div'});
390 </script>
391 </template>
392 <script>
393 'use strict';
394
395 test_with_content((w) => {
396 assert_array_equals(
397 w.invocations,
398 ['constructor', 'is="d-d"', 'connected'],
399 'the built-in element should be upgraded');
400 });
401 </script>
402
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Element.cpp » ('j') | third_party/WebKit/Source/core/dom/Element.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698