Skip to content

Commit

Permalink
Test steps 4 and 5 of the HTMLConstructor
Browse files Browse the repository at this point in the history
Upstreamed from servo/servo#17224 [ci skip]
  • Loading branch information
cbrewster authored and jdm committed Jun 19, 2017
1 parent 6b076b1 commit 8ee4de2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions custom-elements/HTMLElement-constructor.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
assert_throws({'name': 'TypeError'}, function () { new SomeCustomElement; });
}, 'HTMLElement constructor must throw TypeError when it has not been defined by customElements.define');

test(function () {
class SomeCustomElement extends HTMLParagraphElement {};
customElements.define('some-custom-element', SomeCustomElement);
assert_throws({'name': 'TypeError'}, function () { new SomeCustomElement(); });
}, 'Custom element constructor must throw TypeError when it does not extend HTMLElement');

test(function () {
class SomeCustomButtonElement extends HTMLButtonElement {};
customElements.define('some-custom-button-element', SomeCustomButtonElement, { extends: "p" });
assert_throws({'name': 'TypeError'}, function () { new SomeCustomButtonElement(); });
}, 'Custom element constructor must throw TypeError when it does not extend the proper element interface');

test(function () {
class CustomElementWithInferredTagName extends HTMLElement {};
customElements.define('inferred-name', CustomElementWithInferredTagName);
Expand Down

0 comments on commit 8ee4de2

Please sign in to comment.