Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/LayoutTests/custom-elements/spec/construct.html

Issue 1952893003: Implement custom element construction and some 'define' checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698