blob: b59460e17b97353154ddfb083f9abe118100ad11 [file] [log] [blame]
Hayato Ito99914e12018-03-22 09:56:301<!DOCTYPE html>
2<title>Shadow DOM: Attaching a ShadowRoot for custom elements</title>
3<meta name="author" title="Hayato Ito" href="mailto:hayato@chromium.org">
4<link rel="help" href="https://dom.spec.whatwg.org/#dom-element-attachshadow">
5<script src="/resources/testharness.js"></script>
6<script src="/resources/testharnessreport.js"></script>
7<script>
8class MyAutonomousCustomElement extends HTMLElement {
9}
10
11customElements.define('my-custom', MyAutonomousCustomElement);
12
13test(() => {
14 assert_true(document.createElement('my-custom').attachShadow({mode: "open"}) instanceof ShadowRoot);
15}, 'Element.attachShadow must create an instance of ShadowRoot for autonomous custom elements');
16
17class MyCustomizedBuiltinElement extends HTMLInputElement {
18}
19
20customElements.define('my-input', MyCustomizedBuiltinElement, { extends: 'input' });
21
22test(() => {
23 assert_throws({'name': 'NotSupportedError'}, () => {
24 document.createElement('input', {is: 'my-input'}).attachShadow({mode: "open"});
25 });
26}, 'Element.attachShadow must throw a NotSupportedError for customized built-in elements');
27</script>
28</body>
29</html>