Auto merge of #17381 - cbrewster:custom_element_creation, r=jdm

Custom element creation

<!-- Please describe your changes on the following line: -->

This implements the CE-related steps when creating elements. `is` is now support by `document.createElement` and is stored on `Element`s. Only synchronously created autonomous elements are supported as async element creation and customized built-in elements both require custom element upgrade reactions.

Spec: https://dom.spec.whatwg.org/#concept-create-element

---
<!-- 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 #17191 (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/17381)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-23 21:08:40 -07:00 committed by GitHub
commit bc3ec0ce1b
34 changed files with 286 additions and 287 deletions

View file

@ -31,10 +31,10 @@ macro_rules! sizeof_checker (
// Update the sizes here
sizeof_checker!(size_event_target, EventTarget, 40);
sizeof_checker!(size_node, Node, 184);
sizeof_checker!(size_element, Element, 344);
sizeof_checker!(size_htmlelement, HTMLElement, 360);
sizeof_checker!(size_div, HTMLDivElement, 360);
sizeof_checker!(size_span, HTMLSpanElement, 360);
sizeof_checker!(size_element, Element, 376);
sizeof_checker!(size_htmlelement, HTMLElement, 392);
sizeof_checker!(size_div, HTMLDivElement, 392);
sizeof_checker!(size_span, HTMLSpanElement, 392);
sizeof_checker!(size_text, Text, 216);
sizeof_checker!(size_characterdata, CharacterData, 216);
sizeof_checker!(size_servothreadsafelayoutnode, ServoThreadSafeLayoutNode, 16);

View file

@ -554206,7 +554206,7 @@
"testharness"
],
"custom-elements/Document-createElement.html": [
"d9582ab3867b02e98da9b0da8e3398303d1833ab",
"074c9f703cc7feb1dfc3d07aedd08460bd591d42",
"testharness"
],
"custom-elements/HTMLElement-constructor.html": [

View file

@ -1,8 +1,5 @@
[CustomElementRegistry.html]
type: testharness
[customElements.define must not throw when defining another custom element in a different global object during Get(constructor, "prototype")]
expected: FAIL
[customElements.define must get callbacks of the constructor prototype]
expected: FAIL

View file

@ -1,38 +0,0 @@
[Document-createElement.html]
type: testharness
[document.createElement must create an instance of custom elements]
expected: FAIL
[document.createElement must report a TypeError when the result of Construct is not a DOM node]
expected: FAIL
[document.createElement must report a TypeError when the result of Construct is a TextNode]
expected: FAIL
[document.createElement must report a NotSupportedError when attribute is added by setAttribute during construction]
expected: FAIL
[document.createElement must report a NotSupportedError when attribute is added by attributes.setNamedItem during construction]
expected: FAIL
[document.createElement must not report a NotSupportedError when attribute is added and removed during construction]
expected: FAIL
[document.createElement must report a NotSupportedError when a Text child is added during construction]
expected: FAIL
[document.createElement must report a NotSupportedError when a Comment child is added during construction]
expected: FAIL
[document.createElement must report a NotSupportedError when an element child is added during construction]
expected: FAIL
[document.createElement must not report a NotSupportedError when an element child is added and removed during construction]
expected: FAIL
[document.createElement must report a NotSupportedError when the element gets inserted into another element during construction]
expected: FAIL
[document.createElement must not report a NotSupportedError when the element is inserted and removed from another element during construction]
expected: FAIL

View file

@ -1,8 +1,5 @@
[parser-constructs-custom-element-in-document-write.html]
type: testharness
[HTML parser must instantiate custom elements inside document.write]
expected: FAIL
[Custom Elements: Changes to the HTML parser]
expected: FAIL

View file

@ -1,8 +1,5 @@
[parser-constructs-custom-element-synchronously.html]
type: testharness
[HTML parser must only append nodes that appear before a custom element before instantiating the custom element]
expected: FAIL
[Custom Elements: Changes to the HTML parser]
expected: FAIL

View file

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

View file

@ -1,8 +1,5 @@
[parser-sets-attributes-and-children.html]
type: testharness
[HTML parser must set the attributes or append children before calling constructor]
expected: FAIL
[Custom Elements: Changes to the HTML parser]
expected: FAIL

View file

@ -1,11 +1,5 @@
[parser-uses-constructed-element.html]
type: testharness
[HTML parser must use the returned value of the custom element constructor instead of the one created before super() call]
expected: FAIL
[HTML parser must use the returned value of the custom element constructor instead using the one created in super() call]
expected: FAIL
[Custom Elements: HTML parser must construct a custom element instead of upgrading]
expected: FAIL

View file

@ -9,3 +9,6 @@
[Custom Elements: HTML parser must use the owner document's custom element registry]
expected: FAIL
[HTML parser must not instantiate custom elements inside template elements]
expected: FAIL

View file

@ -3,9 +3,9 @@
[setAttribute and removeAttribute must enqueue and invoke attributeChangedCallback]
expected: FAIL
[Calling Node.prototype.cloneNode(false) must push a new element queue to the processing stack]
expected: FAIL
[Custom Elements: Custom element reactions must be invoked before returning to author scripts]
expected: FAIL
[Calling Node.prototype.cloneNode(false) must push a new element queue to the processing stack]
expected: FAIL

View file

@ -3,6 +3,3 @@
[value on Attr must enqueue an attributeChanged reaction when replacing an existing attribute]
expected: FAIL
[value on Attr must not enqueue an attributeChanged reaction when replacing an existing unobserved attribute]
expected: FAIL

View file

@ -3,87 +3,45 @@
[cssText on CSSStyleDeclaration must enqueue an attributeChanged reaction when it adds the observed style attribute]
expected: FAIL
[cssText on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it adds the style attribute but the style attribute is not observed]
expected: FAIL
[cssText on CSSStyleDeclaration must enqueue an attributeChanged reaction when it mutates the observed style attribute]
expected: FAIL
[cssText on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it mutates the style attribute but the style attribute is not observed]
expected: FAIL
[setProperty on CSSStyleDeclaration must enqueue an attributeChanged reaction when it adds the observed style attribute]
expected: FAIL
[setProperty on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it adds the style attribute but the style attribute is not observed]
expected: FAIL
[setProperty on CSSStyleDeclaration must enqueue an attributeChanged reaction when it mutates the observed style attribute]
expected: FAIL
[setProperty on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it mutates the style attribute but the style attribute is not observed]
expected: FAIL
[setProperty on CSSStyleDeclaration must enqueue an attributeChanged reaction when it makes a property important and the style attribute is observed]
expected: FAIL
[setProperty on CSSStyleDeclaration must enqueue an attributeChanged reaction when it makes a property important but the style attribute is not observed]
expected: FAIL
[setPropertyValue on CSSStyleDeclaration must enqueue an attributeChanged reaction when it adds the observed style attribute]
expected: FAIL
[setPropertyValue on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it adds the style attribute but the style attribute is not observed]
expected: FAIL
[setPropertyValue on CSSStyleDeclaration must enqueue an attributeChanged reaction when it mutates the observed style attribute]
expected: FAIL
[setPropertyValue on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it mutates the style attribute but the style attribute is not observed]
expected: FAIL
[setPropertyPriority on CSSStyleDeclaration must enqueue an attributeChanged reaction when it makes a property important and the style attribute is observed]
expected: FAIL
[setPropertyPriority on CSSStyleDeclaration must enqueue an attributeChanged reaction when it makes a property important but the style attribute is not observed]
expected: FAIL
[removeProperty on CSSStyleDeclaration must enqueue an attributeChanged reaction when it removes a property from the observed style attribute]
expected: FAIL
[removeProperty on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it removes a property from the style attribute but the style attribute is not observed]
expected: FAIL
[cssFloat on CSSStyleDeclaration must enqueue an attributeChanged reaction when it adds the observed style attribute]
expected: FAIL
[cssFloat on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it adds the style attribute but the style attribute is not observed]
expected: FAIL
[A camel case attribute (borderWidth) on CSSStyleDeclaration must enqueue an attributeChanged reaction when it adds the observed style attribute]
expected: FAIL
[A camel case attribute (borderWidth) on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it adds the style attribute but the style attribute is not observed]
expected: FAIL
[A camel case attribute (borderWidth) on CSSStyleDeclaration must enqueue an attributeChanged reaction when it mutates the observed style attribute]
expected: FAIL
[A camel case attribute (borderWidth) on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it mutates the style attribute but the style attribute is not observed]
expected: FAIL
[A dashed property (border-width) on CSSStyleDeclaration must enqueue an attributeChanged reaction when it adds the observed style attribute]
expected: FAIL
[A dashed property (border-width) on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it adds the style attribute but the style attribute is not observed]
expected: FAIL
[A dashed property (border-width) on CSSStyleDeclaration must enqueue an attributeChanged reaction when it mutates the observed style attribute]
expected: FAIL
[A dashed property (border-width) on CSSStyleDeclaration must not enqueue an attributeChanged reaction when it mutates the style attribute but the style attribute is not observed]
expected: FAIL
[A webkit prefixed camel case attribute (webkitFilter) on CSSStyleDeclaration must enqueue an attributeChanged reaction when it adds the observed style attribute]
expected: FAIL

View file

@ -3,24 +3,12 @@
[setter on DOMStringMap must enqueue an attributeChanged reaction when adding an observed data attribute]
expected: FAIL
[setter on DOMStringMap must not enqueue an attributeChanged reaction when adding an unobserved data attribute]
expected: FAIL
[setter on DOMStringMap must enqueue an attributeChanged reaction when mutating the value of an observed data attribute]
expected: FAIL
[setter on DOMStringMap must enqueue an attributeChanged reaction when mutating the value of an observed data attribute to the same value]
expected: FAIL
[setter on DOMStringMap must not enqueue an attributeChanged reaction when mutating the value of an unobserved data attribute]
expected: FAIL
[deleter on DOMStringMap must enqueue an attributeChanged reaction when removing an observed data attribute]
expected: FAIL
[deleter on DOMStringMap must not enqueue an attributeChanged reaction when removing an unobserved data attribute]
expected: FAIL
[deleter on DOMStringMap must not enqueue an attributeChanged reaction when it does not remove a data attribute]
expected: FAIL

View file

@ -3,15 +3,9 @@
[add on DOMTokenList must enqueue an attributeChanged reaction when adding an attribute]
expected: FAIL
[add on DOMTokenList must not enqueue an attributeChanged reaction when adding an unobserved attribute]
expected: FAIL
[add on DOMTokenList must enqueue an attributeChanged reaction when adding a value to an existing attribute]
expected: FAIL
[add on DOMTokenList must not enqueue an attributeChanged reaction when adding a value to an unobserved attribute]
expected: FAIL
[add on DOMTokenList must enqueue exactly one attributeChanged reaction when adding multiple values to an attribute]
expected: FAIL
@ -24,9 +18,6 @@
[remove on DOMTokenList must enqueue an attributeChanged reaction even when removing a non-existent value from an attribute]
expected: FAIL
[remove on DOMTokenList must not enqueue an attributeChanged reaction when removing a value from an unobserved attribute]
expected: FAIL
[toggle on DOMTokenList must enqueue an attributeChanged reaction when adding a value to an attribute]
expected: FAIL
@ -39,21 +30,12 @@
[replace on DOMTokenList must not enqueue an attributeChanged reaction when the token to replace does not exist in the attribute]
expected: FAIL
[replace on DOMTokenList must not enqueue an attributeChanged reaction when replacing a value in an unobserved attribute]
expected: FAIL
[the stringifier of DOMTokenList must enqueue an attributeChanged reaction when adding an observed attribute]
expected: FAIL
[the stringifier of DOMTokenList must not enqueue an attributeChanged reaction when adding an unobserved attribute]
expected: FAIL
[the stringifier of DOMTokenList must enqueue an attributeChanged reaction when mutating the value of an observed attribute]
expected: FAIL
[the stringifier of DOMTokenList must not enqueue an attributeChanged reaction when mutating the value of an unobserved attribute]
expected: FAIL
[the stringifier of DOMTokenList must enqueue an attributeChanged reaction when the setter is called with the original value of the attribute]
expected: FAIL

View file

@ -1,11 +1,5 @@
[Document.html]
type: testharness
[importNode on Document must not construct a new custom element when importing a custom element into a window-less document]
expected: FAIL
[importNode on Document must construct a new custom element when importing a custom element from a template]
expected: FAIL
[adoptNode on Document must enqueue an adopted reaction when importing a custom element]
expected: FAIL
@ -36,3 +30,6 @@
[writeln on Document must enqueue connectedCallback after constructing a custom element]
expected: FAIL
[importNode on Document must construct a new custom element when importing a custom element from a template]
expected: FAIL

View file

@ -21,78 +21,36 @@
[setAttribute on Element must enqueue an attributeChanged reaction when adding an attribute]
expected: FAIL
[setAttribute on Element must not enqueue an attributeChanged reaction when adding an unobserved attribute]
expected: FAIL
[setAttribute on Element must enqueue an attributeChanged reaction when replacing an existing attribute]
expected: FAIL
[setAttribute on Element must enqueue an attributeChanged reaction when replacing an existing unobserved attribute]
expected: FAIL
[setAttributeNS on Element must enqueue an attributeChanged reaction when adding an attribute]
expected: FAIL
[setAttributeNS on Element must not enqueue an attributeChanged reaction when adding an unobserved attribute]
expected: FAIL
[setAttributeNS on Element must enqueue an attributeChanged reaction when replacing an existing attribute]
expected: FAIL
[setAttributeNS on Element must enqueue an attributeChanged reaction when replacing an existing unobserved attribute]
expected: FAIL
[removeAttribute on Element must not enqueue an attributeChanged reaction when removing an unobserved attribute]
expected: FAIL
[removeAttribute on Element must enqueue an attributeChanged reaction when removing an existing attribute]
expected: FAIL
[removeAttribute on Element must not enqueue an attributeChanged reaction when removing an existing unobserved attribute]
expected: FAIL
[removeAttributeNS on Element must not enqueue an attributeChanged reaction when removing an unobserved attribute]
expected: FAIL
[removeAttributeNS on Element must enqueue an attributeChanged reaction when removing an existing attribute]
expected: FAIL
[removeAttributeNS on Element must not enqueue an attributeChanged reaction when removing an existing unobserved attribute]
expected: FAIL
[setAttributeNode on Element must enqueue an attributeChanged reaction when adding an attribute]
expected: FAIL
[setAttributeNode on Element must not enqueue an attributeChanged reaction when adding an unobserved attribute]
expected: FAIL
[setAttributeNode on Element must enqueue an attributeChanged reaction when replacing an existing attribute]
expected: FAIL
[setAttributeNode on Element must enqueue an attributeChanged reaction when replacing an existing unobserved attribute]
expected: FAIL
[setAttributeNodeNS on Element must enqueue an attributeChanged reaction when adding an attribute]
expected: FAIL
[setAttributeNodeNS on Element must not enqueue an attributeChanged reaction when adding an unobserved attribute]
expected: FAIL
[setAttributeNodeNS on Element must enqueue an attributeChanged reaction when replacing an existing attribute]
expected: FAIL
[setAttributeNodeNS on Element must enqueue an attributeChanged reaction when replacing an existing unobserved attribute]
expected: FAIL
[removeAttributeNode on Element must not enqueue an attributeChanged reaction when removing an unobserved attribute]
expected: FAIL
[removeAttributeNode on Element must enqueue an attributeChanged reaction when removing an existing attribute]
expected: FAIL
[removeAttributeNode on Element must not enqueue an attributeChanged reaction when removing an existing unobserved attribute]
expected: FAIL
[insertAdjacentElement on Element must enqueue a connected reaction]
expected: FAIL

View file

@ -3,42 +3,18 @@
[setNamedItem on NamedNodeMap must enqueue an attributeChanged reaction when adding an attribute]
expected: FAIL
[setNamedItem on NamedNodeMap must not enqueue an attributeChanged reaction when adding an unobserved attribute]
expected: FAIL
[setNamedItem on NamedNodeMap must enqueue an attributeChanged reaction when replacing an existing attribute]
expected: FAIL
[setNamedItem on NamedNodeMap must enqueue an attributeChanged reaction when replacing an existing unobserved attribute]
expected: FAIL
[setNamedItemNS on NamedNodeMap must enqueue an attributeChanged reaction when adding an attribute]
expected: FAIL
[setNamedItemNS on NamedNodeMap must not enqueue an attributeChanged reaction when adding an unobserved attribute]
expected: FAIL
[setNamedItemNS on NamedNodeMap must enqueue an attributeChanged reaction when replacing an existing attribute]
expected: FAIL
[setNamedItemNS on NamedNodeMap must enqueue an attributeChanged reaction when replacing an existing unobserved attribute]
expected: FAIL
[removeNamedItem on NamedNodeMap must not enqueue an attributeChanged reaction when removing an unobserved attribute]
expected: FAIL
[removeNamedItem on NamedNodeMap must enqueue an attributeChanged reaction when removing an existing attribute]
expected: FAIL
[removeNamedItem on NamedNodeMap must not enqueue an attributeChanged reaction when removing an existing unobserved attribute]
expected: FAIL
[removeNamedItemNS on NamedNodeMap must not enqueue an attributeChanged reaction when removing an unobserved attribute]
expected: FAIL
[removeNamedItemNS on NamedNodeMap must enqueue an attributeChanged reaction when removing an existing attribute]
expected: FAIL
[removeNamedItemNS on NamedNodeMap must not enqueue an attributeChanged reaction when removing an existing unobserved attribute]
expected: FAIL

View file

@ -3,15 +3,9 @@
[nodeValue on Node must enqueue an attributeChanged reaction when replacing an existing attribute]
expected: FAIL
[nodeValue on Node must not enqueue an attributeChanged reaction when replacing an existing unobserved attribute]
expected: FAIL
[textContent on Node must enqueue an attributeChanged reaction when replacing an existing attribute]
expected: FAIL
[textContent on Node must not enqueue an attributeChanged reaction when replacing an existing unobserved attribute]
expected: FAIL
[cloneNode on Node must enqueue an attributeChanged reaction when cloning an element with an observed attribute]
expected: FAIL

View file

@ -36,9 +36,6 @@
[Creating an element in an HTML document fetched by XHR and adopting back to a document with browsing context must enqueue a custom element upgrade reaction]
expected: FAIL
[Creating an element in the document of an iframe must enqueue a custom element upgrade reaction if there is a matching definition]
expected: FAIL
["define" in the document of an iframe must not enqueue a custom element upgrade reaction on a disconnected unresolved custom element]
expected: FAIL

View file

@ -1,14 +1,5 @@
[Node-cloneNode.html]
type: testharness
[Node.prototype.cloneNode(false) must be able to clone a custom element]
expected: FAIL
[Node.prototype.cloneNode(false) must be able to clone a custom element inside an iframe]
expected: FAIL
[Node.prototype.cloneNode(true) must be able to clone a descendent custom element]
expected: FAIL
[Node.prototype.cloneNode(true) must set parentNode, previousSibling, and nextSibling before upgrading custom elements]
expected: FAIL
@ -24,3 +15,12 @@
[Inserting an element must not try to upgrade a custom element when it had already failed to upgrade once]
expected: FAIL
[Node.prototype.cloneNode(false) must be able to clone a custom element]
expected: FAIL
[Node.prototype.cloneNode(false) must be able to clone a custom element inside an iframe]
expected: FAIL
[Node.prototype.cloneNode(true) must be able to clone a descendent custom element]
expected: FAIL

View file

@ -1,4 +1,5 @@
[003.html]
type: testharness
[Fragment Navigation: Updating scroll position]
expected: FAIL
expected: FAIL

View file

@ -3,3 +3,4 @@
[Append iframe element to its own child document]
bug: https://github.com/servo/servo/issues/17479
expected: FAIL

View file

@ -8,7 +8,7 @@
<link rel="help" content="https://dom.spec.whatwg.org/#concept-create-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/custom-elements-helper.js"></script>
<script src="resources/custom-elements-helpers.js"></script>
</head>
<body>
<div id="log"></div>