Auto merge of #17224 - cbrewster:html_constructor, r=jdm

WebIDL HTMLConstructor support

<!-- Please describe your changes on the following line: -->
spec: https://html.spec.whatwg.org/multipage/#htmlconstructor

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #17194 (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17224)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-15 21:47:16 -07:00 committed by GitHub
commit c58bcc23ea
79 changed files with 510 additions and 97 deletions

View file

@ -554120,7 +554120,7 @@
"testharness"
],
"custom-elements/HTMLElement-constructor.html": [
"7fefdaa4cbdf30c505858730a5a3858e9db5dbc2",
"64522527ef425b90c704b20b000c8feef0d1ca25",
"testharness"
],
"custom-elements/OWNERS": [

View file

@ -27,9 +27,6 @@
[customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on observedAttributes]
expected: FAIL
[customElements.define must define an instantiatable custom element]
expected: FAIL
[customElements.define must upgrade elements in the shadow-including tree order]
expected: FAIL

View file

@ -1,11 +0,0 @@
[HTMLElement-constructor.html]
type: testharness
[HTMLElement constructor must infer the tag name from the element interface]
expected: FAIL
[HTMLElement constructor must allow subclassing a custom element]
expected: FAIL
[HTMLElement constructor must allow subclassing an user-defined subclass of HTMLElement]
expected: FAIL

View file

@ -1,32 +0,0 @@
[newtarget.html]
type: testharness
[Use NewTarget's prototype, not the one stored at definition time]
expected: FAIL
[Rethrow any exceptions thrown while getting the prototype]
expected: FAIL
[If prototype is not object (null), derives the fallback from NewTarget's realm (autonomous custom elements)]
expected: FAIL
[If prototype is not object (undefined), derives the fallback from NewTarget's realm (autonomous custom elements)]
expected: FAIL
[If prototype is not object (5), derives the fallback from NewTarget's realm (autonomous custom elements)]
expected: FAIL
[If prototype is not object (string), derives the fallback from NewTarget's realm (autonomous custom elements)]
expected: FAIL
[If prototype is not object (null), derives the fallback from NewTarget's realm (customized built-in elements)]
expected: FAIL
[If prototype is not object (undefined), derives the fallback from NewTarget's realm (customized built-in elements)]
expected: FAIL
[If prototype is not object (5), derives the fallback from NewTarget's realm (customized built-in elements)]
expected: FAIL
[If prototype is not object (string), derives the fallback from NewTarget's realm (customized built-in elements)]
expected: FAIL

View file

@ -27,6 +27,18 @@ test(function () {
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);