chromium/third_party/blink/web_tests/custom-elements/spec/state-failed-create.html

<!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
// If this step throws an exception, then report the exception, and let element be
// instead a new element that implements HTMLUnknownElement, with no attributes,
// namespace set to given namespace, namespace prefix set to null, custom element state
// set to "failed", custom element definition set to null, and node document set to document.

// 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');
  let e = w.document.querySelector('a-a');
  assert_equals(Object.getPrototypeOf(e), w.HTMLUnknownElement.prototype);
}, undefined, document.getElementById('test-content').innerHTML);
</script>
</body>