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

Side by Side Diff: third_party/WebKit/LayoutTests/custom-elements/spec/state-failed-upgrade.html

Issue 2456773002: Clear the custom element's reaction queue if upgrade fails. (Closed)
Patch Set: Created 4 years, 1 month 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 <title>Custom Elements: Custom Element State "Failed" in Upgrades</title> 2 <title>Custom Elements: Custom Element State "Failed" in Upgrades</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 // Custom Element State 10 // Custom Element State
11 // https://dom.spec.whatwg.org/#concept-element-custom-element-state 11 // https://dom.spec.whatwg.org/#concept-element-custom-element-state
12 12
13 test_with_window(w => { 13 test_with_window(w => {
14 let document = w.document; 14 let document = w.document;
15 let element = document.createElement('a-a'); 15 let element = document.createElement('a-a');
16 let error = new Error('expected');
16 17
17 let constructorCount = 0; 18 let constructorCount = 0;
18 w.customElements.define('a-a', class extends w.HTMLElement { 19 w.customElements.define('a-a', class extends w.HTMLElement {
19 constructor() { 20 constructor() {
20 constructorCount++; 21 constructorCount++;
21 throw new Error(); 22 throw error;
22 } 23 }
23 connectedCallback() { 24 connectedCallback() {
24 // TODO(davaajav): remove the failure expectation when this issue is close d
25 // https://github.com/w3c/webcomponents/issues/563
26 assert_unreached('connectedCallback should not be invoked if constructor t hrew'); 25 assert_unreached('connectedCallback should not be invoked if constructor t hrew');
27 } 26 }
28 }); 27 });
29 28
30 // Upgrade calls the constructor. 29 // Upgrade calls the constructor.
31 // 9. If constructResult is an abrupt completion, then 30 // 9. If constructResult is an abrupt completion, then
32 // Set element's custom element state to "failed". 31 // Set element's custom element state to "failed".
33 // https://html.spec.whatwg.org/multipage/scripting.html#upgrades 32 // https://html.spec.whatwg.org/multipage/scripting.html#upgrades
34 let container = document.body; 33 let container = document.body;
35 container.appendChild(element); 34 assert_reports(w, error, () => container.appendChild(element));
36 assert_equals(constructorCount, 1, 'constructor should be invoked once'); 35 assert_equals(constructorCount, 1, 'constructor should be invoked once');
37 36
38 // "failed" is not "defined" 37 // "failed" is not "defined"
39 // https://dom.spec.whatwg.org/#concept-element-defined 38 // https://dom.spec.whatwg.org/#concept-element-defined
40 assert_false(element.matches(':defined')); 39 assert_false(element.matches(':defined'));
41 40
42 // "failed" element should implement HTMLUnknownElement only in "creating an e lement for a token" 41 // "failed" element should implement HTMLUnknownElement only in "creating an e lement for a token"
43 // https://html.spec.whatwg.org/#create-an-element-for-the-token 42 // https://html.spec.whatwg.org/#create-an-element-for-the-token
44 assert_equals(Object.getPrototypeOf(element), w.HTMLElement.prototype); 43 assert_equals(Object.getPrototypeOf(element), w.HTMLElement.prototype);
45 44
46 // 2. If element's custom element state is "failed", then abort these steps. 45 // 2. If element's custom element state is "failed", then abort these steps.
47 // https://html.spec.whatwg.org/multipage/scripting.html#upgrades 46 // https://html.spec.whatwg.org/multipage/scripting.html#upgrades
48 container.appendChild(element); 47 container.appendChild(element);
49 assert_equals(constructorCount, 1, 'constructor should be invoked once'); 48 assert_equals(constructorCount, 1, 'constructor should be invoked once');
50 }); 49 });
51 </script> 50 </script>
52 </body> 51 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698