chromium/third_party/blink/web_tests/custom-elements/cereactions-with-exception.html

<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<body>
<div id=log></div>
<div id=container></div>
<script>
test(() => {
  var upgraded = false;
  class MyCustomElement extends HTMLElement {
    constructor() { super(); upgraded = true; }
  }
  customElements.define('my-custom-element', MyCustomElement);
  log.addEventListener('DOMNodeRemoved', function (e) {
    if (document.querySelector('#log'))
      document.adoptNode(log);
  });
  assert_throws_dom('NotFoundError', () => { log.outerHTML = '<my-custom-element></my-custom-element>'; });
  assert_true(upgraded, 'MyCustomElement constructor should be called');
}, 'CEReactions should rethrow an exception by the originally-specified steps; 1');

test(() => {
  var disconnected = false;
  class MyCustomElement2 extends HTMLElement {
    disconnectedCallback() { this.style.display = 'none'; disconnected = true; }
  }
  customElements.define('my-custom-element-2', MyCustomElement2);
  var container = document.querySelector('#container');
  var myElement = document.createElement('my-custom-element-2');
  container.innerHTML = "a";
  container.appendChild(myElement);
  assert_throws_dom("HierarchyRequestError", () => container.firstChild.before("b", container));
  assert_true(disconnected, 'diconnectedCallback() should be called');
}, 'CEReactions should rethrow an exception by the originally-specified steps; 2');
</script>
</body>