OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <title>Custom Elements Constructor Tests</title> | |
3 <script src="../../resources/testharness.js"></script> | |
4 <script src="../../resources/testharness-helpers.js"></script> | |
5 <script src="../../resources/testharnessreport.js"></script> | |
6 <script src="resources/custom-elements-helpers.js"></script> | |
domenic
2016/05/05 19:15:27
In preparation for upstreaming might want to add <
| |
7 <body> | |
8 <script> | |
9 test_with_window((w) => { | |
10 assert_throws(TypeError.prototype, () => { | |
11 w.HTMLElement(); | |
12 }, 'calling the HTMLElement constructor should throw a TypeError'); | |
13 }, 'HTMLElement constructor, invoke'); | |
14 | |
15 test_with_window((w) => { | |
16 assert_throws(TypeError.prototype, () => { | |
17 new w.HTMLElement(); | |
18 }, 'invoking the HTMLElement constructor with a construct call should ' + | |
19 'throw a TypeError'); | |
20 }, 'HTMLElement constructor, construct'); | |
21 | |
22 test_with_window((w) => { | |
23 class X extends w.HTMLElement {} | |
24 w.customElements.define('a-a', X); | |
25 assert_throws(TypeError.prototype, () => { | |
26 X(); | |
27 }, 'calling a custom element constructor should throw a TypeError'); | |
28 }, 'Custom element constructor, invoke'); | |
29 | |
30 test_with_window((w) => { | |
31 class C extends w.HTMLElement {} | |
32 w.customElements.define('a-a', C); | |
33 let e = new C(); | |
34 assert_true(e instanceof w.HTMLElement, | |
justinfagnani
2016/05/05 17:04:48
might want to verify the localName
domenic
2016/05/05 19:15:27
Other ideas:
e.namespaceURI === "http://www.w3.or
| |
35 'the element should be an HTMLElement'); | |
36 }, 'Custom element constructor, construct'); | |
37 | |
38 test_with_window((w) => { | |
39 class C extends w.HTMLElement { } | |
40 class D extends C {} | |
41 w.customElements.define('a-a', C); // Note: Not D. | |
42 assert_throws(TypeError.prototype, () => { | |
43 new D(); | |
44 }, | |
45 'constructing a custom element with a new.target with no registry ' + | |
46 'entry should throw a TypeError'); | |
47 }, 'Custom element constructor, construct invalid new.target'); | |
48 | |
49 // TODO(dominicc): Use Reflect.construct to set weird and wonderful new.target | |
50 </script> | |
OLD | NEW |