Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/custom-elements/spec/construct.html |
| diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/construct.html b/third_party/WebKit/LayoutTests/custom-elements/spec/construct.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f328fa130699acefa2440e71df865a7570429ad7 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/custom-elements/spec/construct.html |
| @@ -0,0 +1,50 @@ |
| +<!DOCTYPE html> |
| +<title>Custom Elements Constructor Tests</title> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharness-helpers.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script src="resources/custom-elements-helpers.js"></script> |
|
domenic
2016/05/05 19:15:27
In preparation for upstreaming might want to add <
|
| +<body> |
| +<script> |
| +test_with_window((w) => { |
| + assert_throws(TypeError.prototype, () => { |
| + w.HTMLElement(); |
| + }, 'calling the HTMLElement constructor should throw a TypeError'); |
| +}, 'HTMLElement constructor, invoke'); |
| + |
| +test_with_window((w) => { |
| + assert_throws(TypeError.prototype, () => { |
| + new w.HTMLElement(); |
| + }, 'invoking the HTMLElement constructor with a construct call should ' + |
| + 'throw a TypeError'); |
| +}, 'HTMLElement constructor, construct'); |
| + |
| +test_with_window((w) => { |
| + class X extends w.HTMLElement {} |
| + w.customElements.define('a-a', X); |
| + assert_throws(TypeError.prototype, () => { |
| + X(); |
| + }, 'calling a custom element constructor should throw a TypeError'); |
| +}, 'Custom element constructor, invoke'); |
| + |
| +test_with_window((w) => { |
| + class C extends w.HTMLElement {} |
| + w.customElements.define('a-a', C); |
| + let e = new C(); |
| + 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
|
| + 'the element should be an HTMLElement'); |
| +}, 'Custom element constructor, construct'); |
| + |
| +test_with_window((w) => { |
| + class C extends w.HTMLElement { } |
| + class D extends C {} |
| + w.customElements.define('a-a', C); // Note: Not D. |
| + assert_throws(TypeError.prototype, () => { |
| + new D(); |
| + }, |
| + 'constructing a custom element with a new.target with no registry ' + |
| + 'entry should throw a TypeError'); |
| +}, 'Custom element constructor, construct invalid new.target'); |
| + |
| +// TODO(dominicc): Use Reflect.construct to set weird and wonderful new.target |
| +</script> |