OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Custom Built-in Elements: define algorithm paths that are reached by cust
omized built-in elements</title> | 2 <title>Custom Built-in Elements: define algorithm paths that are reached by cust
omized built-in elements</title> |
3 <link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#cus
tomelementsregistry"> | 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#cus
tomelementsregistry"> |
4 <script src="../../resources/testharness.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
5 <script src="../../resources/testharnessreport.js"></script> | 5 <script src="../../resources/testharnessreport.js"></script> |
6 <script src="resources/custom-elements-helpers.js"></script> | 6 <script src="resources/custom-elements-helpers.js"></script> |
7 <body> | 7 <body> |
8 <script> | 8 <script> |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
11 | 11 |
12 test_with_window((w) => { | 12 test_with_window((w) => { |
13 class A extends w.HTMLButtonElement {} | 13 class A extends w.HTMLButtonElement {} |
14 let valid_custom_element_names = [ | 14 let valid_custom_element_names = [ |
15 'a-a', | 15 'a-a', |
16 'z0-y0', | 16 'z0-y0', |
17 'emotion-\u1f60d', | 17 'emotion-\u1f60d', |
18 'math-\u03b1', | 18 'math-\u03b1', |
19 'a.b-c' | 19 'a.b-c' |
20 ]; | 20 ]; |
21 valid_custom_element_names.forEach((val) => { | 21 valid_custom_element_names.forEach((val) => { |
22 assert_throws_dom_exception(w, 'NotSupportedError', () => { | 22 assert_throws_dom_exception(w, 'NotSupportedError', () => { |
23 w.customElements.define('a-a', A, { extends: val }); | 23 w.customElements.define('a-a', A, { extends: val }); |
24 }, `having valid custon element name element interface (${val}) ` + | 24 }, `having valid custon element name element interface (${val}) ` + |
25 'for extends should throw a NotSupportedError') | 25 'for extends should throw a NotSupportedError') |
26 }); | 26 }); |
27 }, 'Element interface for extends is not valid custom element name'); | 27 }, 'Element interface for extends is not valid custom element name should throw
error'); |
28 | 28 |
29 test_with_window((w) => { | 29 test_with_window((w) => { |
30 class A extends w.HTMLButtonElement {} | 30 class A extends w.HTMLButtonElement {} |
31 let HTMLUnknownElement_names = [ | 31 let HTMLUnknownElement_names = [ |
32 'bgsound', | 32 'bgsound', |
33 'blink', | 33 'blink', |
34 'isindex', | 34 'isindex', |
35 'multicol', | 35 'multicol', |
36 'nextid', | 36 'nextid', |
37 'spacer', | 37 'spacer', |
38 42 | 38 42 |
39 ] | 39 ] |
40 HTMLUnknownElement_names.forEach((val) => { | 40 HTMLUnknownElement_names.forEach((val) => { |
41 assert_throws_dom_exception(w, 'NotSupportedError', () => { | 41 assert_throws_dom_exception(w, 'NotSupportedError', () => { |
42 w.customElements.define('a-a', A, { extends: val }); | 42 w.customElements.define('a-a', A, { extends: val }); |
43 }, `having element interface for extends (${val}) undefined in specs` + | 43 }, `having element interface for extends (${val}) undefined in specs` + |
44 ' should throw a NotSupportedError'); | 44 ' should throw a NotSupportedError'); |
45 }); | 45 }); |
46 }, 'Element interface for extends defined in specification'); | 46 }, 'Element interface for extends not defined in specification should throw erro
r'); |
47 | 47 |
48 test_with_window((w) => { | 48 test_with_window((w) => { |
49 class A extends w.HTMLButtonElement {} | 49 class A extends w.HTMLDivElement {} |
50 w.customElements.define('defined-name', A, { extends: 'button' }); | 50 w.customElements.define('defined-name', A, { extends: 'div' }); |
51 assert_equals(new A().localName, 'button', | 51 assert_equals(new A().localName, 'div', |
52 'localName should be element interface for extends'); | 52 'localName should be element interface for extends'); |
53 assert_not_equals(new A().localName, 'defined-name', | 53 assert_not_equals(new A().localName, 'defined-name', |
54 'localName should not be defined-name'); | 54 'localName should not be defined-name'); |
55 }, 'localName set to element interface for extends'); | 55 }, 'localName set to element interface for extends'); |
56 </script> | 56 </script> |
57 </body> | 57 </body> |
OLD | NEW |