| <!DOCTYPE html> |
| <title>Custom Elements: Custom Element State "Failed" in document parser</title> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="resources/custom-elements-helpers.js"></script> |
| <body> |
| <template id="test-content"> |
| <script> |
| 'use strict'; |
| window.logs = []; |
| customElements.define('a-a', class extends HTMLElement { |
| constructor() { |
| super(); |
| logs.push('constructor'); |
| throw new Error(); |
| } |
| connectedCallback() { |
| logs.push('connected'); |
| } |
| }); |
| </script> |
| <a-a></a-a> |
| </template> |
| <script> |
| 'use strict'; |
| |
| // Custom Element State |
| // https://dom.spec.whatwg.org/#concept-element-custom-element-state |
| // Set to "failed" in step 7 of "create an element for a token" |
| // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token |
| |
| // This test loads the template content into iframe.srcdoc because "create an |
| // element for a token" with synchronous custom elements flag set to true is |
| // used only in document parser. |
| |
| test_with_window(w => { |
| let logs = w.logs; |
| assert_equals(logs.length, 1, 'Only constructor should be invoked'); |
| assert_equals(logs[0], 'constructor', 'The 1st action should be constructor'); |
| }, undefined, document.getElementById('test-content').innerHTML); |
| </script> |
| </body> |