| Hayato Ito | 99914e1 | 2018-03-22 09:56:30 | [diff] [blame] | 1 | <!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> |
| 8 | class MyAutonomousCustomElement extends HTMLElement { |
| 9 | } |
| 10 | |
| 11 | customElements.define('my-custom', MyAutonomousCustomElement); |
| 12 | |
| 13 | test(() => { |
| 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 | |
| 17 | class MyCustomizedBuiltinElement extends HTMLInputElement { |
| 18 | } |
| 19 | |
| 20 | customElements.define('my-input', MyCustomizedBuiltinElement, { extends: 'input' }); |
| 21 | |
| 22 | test(() => { |
| 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> |