OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Custom Elements: Custom Element State "Failed" in Upgrades</title> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script src="resources/custom-elements-helpers.js"></script> |
| 6 <body> |
| 7 <script> |
| 8 'use strict'; |
| 9 |
| 10 // Custom Element State |
| 11 // https://dom.spec.whatwg.org/#concept-element-custom-element-state |
| 12 |
| 13 test_with_window(w => { |
| 14 let document = w.document; |
| 15 let element = document.createElement('a-a'); |
| 16 |
| 17 let constructorCount = 0; |
| 18 w.customElements.define('a-a', class extends w.HTMLElement { |
| 19 constructor() { |
| 20 constructorCount++; |
| 21 throw new Error(); |
| 22 } |
| 23 connectedCallback() { |
| 24 assert_unreached('connectedCallback should not be invoked if constructor t
hrew'); |
| 25 } |
| 26 }); |
| 27 |
| 28 // Upgrade calls the constructor. |
| 29 // 9. If constructResult is an abrupt completion, then |
| 30 // Set element's custom element state to "failed". |
| 31 // https://html.spec.whatwg.org/multipage/scripting.html#upgrades |
| 32 let container = document.body; |
| 33 container.appendChild(element); |
| 34 assert_equals(constructorCount, 1, 'constructor should be invoked once'); |
| 35 |
| 36 // "failed" is not "defined" |
| 37 // https://dom.spec.whatwg.org/#concept-element-defined |
| 38 assert_false(element.matches(':defined')); |
| 39 }); |
| 40 </script> |
| 41 </body> |
OLD | NEW |