https://github.com/web-platform-tests/wpt
Raw File
Tip revision: dd6fbaac2a7deeea999adeecd4b30a3655f48c7e authored by Yoav Weiss on 19 April 2018, 20:02:31 UTC
[Resource Timing] Align TAO parsing to spec
Tip revision: dd6fbaa
Element-interface-attachShadow-custom-element.html
<!DOCTYPE html>
<title>Shadow DOM: Attaching a ShadowRoot for custom elements</title>
<meta name="author" title="Hayato Ito" href="mailto:hayato@chromium.org">
<link rel="help" href="https://dom.spec.whatwg.org/#dom-element-attachshadow">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
class MyAutonomousCustomElement extends HTMLElement {
}

customElements.define('my-custom', MyAutonomousCustomElement);

test(() => {
  assert_true(document.createElement('my-custom').attachShadow({mode: "open"}) instanceof ShadowRoot);
}, 'Element.attachShadow must create an instance of ShadowRoot for autonomous custom elements');

class MyCustomizedBuiltinElement extends HTMLInputElement {
}

customElements.define('my-input', MyCustomizedBuiltinElement, { extends: 'input' });

test(() => {
  assert_throws({'name': 'NotSupportedError'}, () => {
    document.createElement('input', {is: 'my-input'}).attachShadow({mode: "open"});
  });
}, 'Element.attachShadow must throw a NotSupportedError for customized built-in elements');
</script>
</body>
</html>
back to top