| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Custom Elements: Element definition</title> | 2 <title>Custom Elements: Element definition</title> |
| 3 <script src="/resources/testharness.js"></script> | 3 <script src="/resources/testharness.js"></script> |
| 4 <script src="/resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <body> | 5 <body> |
| 6 <div id="log"></div> | 6 <div id="log"></div> |
| 7 <iframe id="iframe"></iframe> | 7 <iframe id="iframe"></iframe> |
| 8 <script> | 8 <script> |
| 9 'use strict'; | 9 'use strict'; |
| 10 (() => { | 10 (() => { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 }, `Element names: defining an element named ${name} should succeed`); | 103 }, `Element names: defining an element named ${name} should succeed`); |
| 104 }); | 104 }); |
| 105 invalidCustomElementNames.forEach(name => { | 105 invalidCustomElementNames.forEach(name => { |
| 106 test(() => { | 106 test(() => { |
| 107 assert_throws(expectSyntaxError, () => { | 107 assert_throws(expectSyntaxError, () => { |
| 108 customElements.define(name, class {}); | 108 customElements.define(name, class {}); |
| 109 }); | 109 }); |
| 110 }, `Element names: defining an element named ${name} should throw a SyntaxEr
ror`); | 110 }, `Element names: defining an element named ${name} should throw a SyntaxEr
ror`); |
| 111 }); | 111 }); |
| 112 | 112 |
| 113 // 3. If this CustomElementsRegistry contains an entry with name name, | 113 // 3. If this CustomElementRegistry contains an entry with name name, |
| 114 // then throw a NotSupportedError and abort these steps. | 114 // then throw a NotSupportedError and abort these steps. |
| 115 test(() => { | 115 test(() => { |
| 116 customElements.define('test-define-dup-name', class {}); | 116 customElements.define('test-define-dup-name', class {}); |
| 117 assert_throws(expectNotSupportedError, () => { | 117 assert_throws(expectNotSupportedError, () => { |
| 118 customElements.define('test-define-dup-name', class {}); | 118 customElements.define('test-define-dup-name', class {}); |
| 119 }); | 119 }); |
| 120 }, 'If the name is already defined, should throw a NotSupportedError'); | 120 }, 'If the name is already defined, should throw a NotSupportedError'); |
| 121 | 121 |
| 122 // 5. If this CustomElementsRegistry contains an entry with constructor constr
uctor, | 122 // 5. If this CustomElementRegistry contains an entry with constructor constru
ctor, |
| 123 // then throw a NotSupportedError and abort these steps. | 123 // then throw a NotSupportedError and abort these steps. |
| 124 test(() => { | 124 test(() => { |
| 125 class TestDupConstructor {}; | 125 class TestDupConstructor {}; |
| 126 customElements.define('test-define-dup-constructor', TestDupConstructor); | 126 customElements.define('test-define-dup-constructor', TestDupConstructor); |
| 127 assert_throws(expectNotSupportedError, () => { | 127 assert_throws(expectNotSupportedError, () => { |
| 128 customElements.define('test-define-dup-ctor2', TestDupConstructor); | 128 customElements.define('test-define-dup-ctor2', TestDupConstructor); |
| 129 }); | 129 }); |
| 130 }, 'If the constructor is already defined, should throw a NotSupportedError'); | 130 }, 'If the constructor is already defined, should throw a NotSupportedError'); |
| 131 | 131 |
| 132 // 9.1. If extends is a valid custom element name, | 132 // 9.1. If extends is a valid custom element name, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 assert_throws(expectTypeError, () => { | 234 assert_throws(expectTypeError, () => { |
| 235 customElements.define(`test-define-${name.toLowerCase()}-${data.name
}`, C); | 235 customElements.define(`test-define-${name.toLowerCase()}-${data.name
}`, C); |
| 236 }); | 236 }); |
| 237 } | 237 } |
| 238 }, `If constructor.prototype.${name} is ${data.name}, should ${data.succes
s ? 'succeed' : 'throw a TypeError'}`); | 238 }, `If constructor.prototype.${name} is ${data.name}, should ${data.succes
s ? 'succeed' : 'throw a TypeError'}`); |
| 239 }); | 239 }); |
| 240 }); | 240 }); |
| 241 })(); | 241 })(); |
| 242 </script> | 242 </script> |
| 243 </body> | 243 </body> |
| OLD | NEW |