Auto merge of #17112 - cbrewster:custom_element_registry, r=jdm

Implement custom element registry

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

---
<!-- 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 #16753 (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/17112)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-05 08:38:03 -07:00 committed by GitHub
commit b584944f17
13 changed files with 520 additions and 87 deletions

View file

@ -554144,7 +554144,7 @@
"testharness"
],
"custom-elements/custom-element-registry/define.html": [
"724060b276a1f3254fd226e329631005ec5a5e87",
"4f3d4da1aae8efab035a4b951147904d71e7de3b",
"testharness"
],
"custom-elements/disconnected-callbacks.html": [

View file

@ -1,50 +1,8 @@
[CustomElementRegistry.html]
type: testharness
[CustomElementRegistry interface must have define as a method]
expected: FAIL
[customElements.define must throw when the element interface is not a constructor]
expected: FAIL
[customElements.define must not throw the constructor is HTMLElement]
expected: FAIL
[customElements.define must throw with an invalid name]
expected: FAIL
[customElements.define must throw when there is already a custom element of the same name]
expected: FAIL
[customElements.define must throw a NotSupportedError when there is already a custom element with the same class]
expected: FAIL
[customElements.define must throw a NotSupportedError when element definition is running flag is set]
expected: FAIL
[customElements.define must check IsConstructor on the constructor before checking the element definition is running flag]
expected: FAIL
[customElements.define must validate the custom element name before checking the element definition is running flag]
expected: FAIL
[customElements.define unset the element definition is running flag before upgrading custom elements]
expected: FAIL
[customElements.define must not throw when defining another custom element in a different global object during Get(constructor, "prototype")]
expected: FAIL
[Custom Elements: CustomElementRegistry interface]
expected: FAIL
[customElements.define must get "prototype" property of the constructor]
expected: FAIL
[customElements.define must rethrow an exception thrown while getting "prototype" property of the constructor]
expected: FAIL
[customElements.define must throw when "prototype" property of the constructor is not an object]
expected: FAIL
[customElements.define must get callbacks of the constructor prototype]
expected: FAIL
@ -69,45 +27,9 @@
[customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on observedAttributes]
expected: FAIL
[customElements.define must not throw even if "observedAttributes" fails to convert if "attributeChangedCallback" is not defined]
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
[CustomElementRegistry interface must have get as a method]
expected: FAIL
[customElements.get must return undefined when the registry does not contain an entry with the given name]
expected: FAIL
[customElements.get must return undefined when the registry does not contain an entry with the given name even if the name was not a valid custom element name]
expected: FAIL
[customElements.get return the constructor of the entry with the given name when there is a matching entry.]
expected: FAIL
[customElements.whenDefined must return a promise for a valid custom element name]
expected: FAIL
[customElements.whenDefined must return the same promise each time invoked for a valid custom element name which has not been defined]
expected: FAIL
[customElements.whenDefined must return an unresolved promise when the registry does not contain the entry with the given name]
expected: FAIL
[customElements.whenDefined must return a rejected promise when the given name is not a valid custom element name]
expected: FAIL
[customElements.whenDefined must return a resolved promise when the registry contains the entry with the given name]
expected: FAIL
[customElements.whenDefined must return a new resolved promise each time invoked when the registry contains the entry with the given name]
expected: FAIL
[A promise returned by customElements.whenDefined must be resolved by "define"]
expected: FAIL

View file

@ -9,9 +9,3 @@
[HTMLElement constructor must allow subclassing an user-defined subclass of HTMLElement]
expected: FAIL
[HTMLElement constructor must throw a TypeError when NewTarget is equal to itself]
expected: FAIL
[HTMLElement constructor must throw a TypeError when NewTarget is equal to itself via a Proxy object]
expected: FAIL

View file

@ -0,0 +1 @@
prefs: [dom.customelements.enabled:true]

View file

@ -1,5 +1,53 @@
[define.html]
type: testharness
[Custom Elements: Element definition]
[If constructor is arrow function, should throw a TypeError]
expected: FAIL
[If constructor.prototype.connectedCallback throws, should rethrow]
expected: FAIL
[If constructor.prototype.connectedCallback is null, should throw a TypeError]
expected: FAIL
[If constructor.prototype.connectedCallback is object, should throw a TypeError]
expected: FAIL
[If constructor.prototype.connectedCallback is integer, should throw a TypeError]
expected: FAIL
[If constructor.prototype.disconnectedCallback throws, should rethrow]
expected: FAIL
[If constructor.prototype.disconnectedCallback is null, should throw a TypeError]
expected: FAIL
[If constructor.prototype.disconnectedCallback is object, should throw a TypeError]
expected: FAIL
[If constructor.prototype.disconnectedCallback is integer, should throw a TypeError]
expected: FAIL
[If constructor.prototype.adoptedCallback throws, should rethrow]
expected: FAIL
[If constructor.prototype.adoptedCallback is null, should throw a TypeError]
expected: FAIL
[If constructor.prototype.adoptedCallback is object, should throw a TypeError]
expected: FAIL
[If constructor.prototype.adoptedCallback is integer, should throw a TypeError]
expected: FAIL
[If constructor.prototype.attributeChangedCallback throws, should rethrow]
expected: FAIL
[If constructor.prototype.attributeChangedCallback is null, should throw a TypeError]
expected: FAIL
[If constructor.prototype.attributeChangedCallback is object, should throw a TypeError]
expected: FAIL
[If constructor.prototype.attributeChangedCallback is integer, should throw a TypeError]
expected: FAIL

View file

@ -1,6 +1,5 @@
[parser-constructs-custom-elements.html]
type: testharness
expected: ERROR
[HTML parser must create a defined custom element before executing inline scripts]
expected: FAIL

View file

@ -12,6 +12,7 @@
// https://html.spec.whatwg.org/multipage/scripting.html#element-definition
// Use window from iframe to isolate the test.
const iframe = document.getElementById("iframe");
const testWindow = iframe.contentDocument.defaultView;
const customElements = testWindow.customElements;