| <!DOCTYPE html> |
| <title>Custom Built-in Elements: define algorithm paths that are reached by customized built-in elements</title> |
| <link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#customelementsregistry"> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="resources/custom-elements-helpers.js"></script> |
| <body> |
| <script> |
| |
| 'use strict'; |
| |
| test_with_window((w) => { |
| class A extends w.HTMLButtonElement {} |
| let valid_custom_element_names = [ |
| 'a-a', |
| 'z0-y0', |
| 'emotion-\u1f60d', |
| 'math-\u03b1', |
| 'a.b-c' |
| ]; |
| valid_custom_element_names.forEach((val) => { |
| assert_throws_dom_exception(w, 'NotSupportedError', () => { |
| w.customElements.define('a-a', A, { extends: val }); |
| }, `having valid custon element name element interface (${val}) ` + |
| 'for extends should throw a NotSupportedError') |
| }); |
| }, 'Element interface for extends is not valid custom element name should throw error'); |
| |
| test_with_window((w) => { |
| class A extends w.HTMLButtonElement {} |
| let HTMLUnknownElement_names = [ |
| 'bgsound', |
| 'blink', |
| 'isindex', |
| 'multicol', |
| 'nextid', |
| 'spacer', |
| 42 |
| ] |
| HTMLUnknownElement_names.forEach((val) => { |
| assert_throws_dom_exception(w, 'NotSupportedError', () => { |
| w.customElements.define('a-a', A, { extends: val }); |
| }, `having element interface for extends (${val}) undefined in specs` + |
| ' should throw a NotSupportedError'); |
| }); |
| }, 'Element interface for extends not defined in specification should throw error'); |
| |
| test_with_window((w) => { |
| class A extends w.HTMLDivElement {} |
| w.customElements.define('defined-name', A, { extends: 'div' }); |
| assert_equals(new A().localName, 'div', |
| 'localName should be element interface for extends'); |
| assert_not_equals(new A().localName, 'defined-name', |
| 'localName should not be defined-name'); |
| }, 'localName set to element interface for extends'); |
| </script> |
| </body> |