mirror of
https://github.com/servo/servo.git
synced 2025-08-15 18:35:33 +01:00
Update web-platform-tests to revision 10168e9a5d44efbc6e7d416d1d454eb9c9f1396c
This commit is contained in:
parent
c88dc51d03
commit
0e1caebaf4
791 changed files with 23381 additions and 5501 deletions
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Custom Elements: Changes to the HTML parser</title>
|
||||
<meta name="author" title="John Dai" href="mailto:jdai@mozilla.com">
|
||||
<meta name="assert" content="HTML parser creates a custom element which contains is attribute">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#create-an-element-for-the-token">
|
||||
<link rel="help" href="https://dom.spec.whatwg.org/#concept-create-element">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<autonomous-custom-element id="instance1" is="is-custom-element"></autonomous-custom-element>
|
||||
<script>
|
||||
|
||||
class AutonomousCustomElement extends HTMLElement { };
|
||||
class IsCustomElement extends HTMLElement { };
|
||||
|
||||
customElements.define('autonomous-custom-element', AutonomousCustomElement);
|
||||
customElements.define('is-custom-element', IsCustomElement);
|
||||
|
||||
test(function () {
|
||||
var customElement = document.getElementById('instance1');
|
||||
|
||||
assert_true(customElement instanceof HTMLElement, 'A resolved custom element must be an instance of HTMLElement');
|
||||
assert_false(customElement instanceof HTMLUnknownElement, 'A resolved custom element must NOT be an instance of HTMLUnknownElement');
|
||||
assert_true(customElement instanceof AutonomousCustomElement, 'A resolved custom element must be an instance of that custom element');
|
||||
assert_equals(customElement.localName, 'autonomous-custom-element');
|
||||
assert_equals(customElement.namespaceURI, 'http://www.w3.org/1999/xhtml', 'A custom element HTML must use HTML namespace');
|
||||
|
||||
}, 'HTML parser must create a defined autonomous custom element when customElements.define comes after HTML parser creation');
|
||||
|
||||
</script>
|
||||
<autonomous-custom-element id="instance2" is="is-custom-element"></autonomous-custom-element>
|
||||
<script>
|
||||
|
||||
test(function () {
|
||||
var customElement = document.getElementById('instance2');
|
||||
|
||||
assert_true(customElement instanceof HTMLElement, 'A resolved custom element must be an instance of HTMLElement');
|
||||
assert_false(customElement instanceof HTMLUnknownElement, 'A resolved custom element must NOT be an instance of HTMLUnknownElement');
|
||||
assert_true(customElement instanceof AutonomousCustomElement, 'A resolved custom element must be an instance of that custom element');
|
||||
assert_equals(customElement.localName, 'autonomous-custom-element');
|
||||
assert_equals(customElement.namespaceURI, 'http://www.w3.org/1999/xhtml', 'A custom element HTML must use HTML namespace');
|
||||
|
||||
}, 'HTML parser must create a defined autonomous custom element when customElements.define comes before HTML parser creation');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -8,6 +8,7 @@
|
|||
<link rel="help" href="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-helpers.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
|
@ -15,6 +16,7 @@
|
|||
|
||||
var numberOfAttributesInConstructor;
|
||||
var numberOfChildNodesInConstructor;
|
||||
var attributesChangedCalls = [];
|
||||
|
||||
class MyCustomElement extends HTMLElement {
|
||||
constructor(...args) {
|
||||
|
@ -22,6 +24,14 @@ class MyCustomElement extends HTMLElement {
|
|||
numberOfAttributesInConstructor = this.attributes.length;
|
||||
numberOfChildNodesInConstructor = this.childNodes.length;
|
||||
}
|
||||
|
||||
attributeChangedCallback(...args) {
|
||||
attributesChangedCalls.push(create_attribute_changed_callback_log(this, ...args));
|
||||
}
|
||||
|
||||
static get observedAttributes() {
|
||||
return ['id', 'class'];
|
||||
}
|
||||
};
|
||||
customElements.define('my-custom-element', MyCustomElement);
|
||||
|
||||
|
@ -54,6 +64,12 @@ test(function () {
|
|||
assert_equals(numberOfChildNodesInConstructor, 0, 'HTML parser must not append child nodes to a custom element before invoking the constructor');
|
||||
}, 'HTML parser must set the attributes or append children before calling constructor');
|
||||
|
||||
test(function () {
|
||||
assert_equals(attributesChangedCalls.length, 2);
|
||||
assert_attribute_log_entry(attributesChangedCalls[0], {name: 'id', oldValue: null, newValue: 'custom-element-id', namespace: null});
|
||||
assert_attribute_log_entry(attributesChangedCalls[1], {name: 'class', oldValue: null, newValue: 'class1 class2', namespace: null});
|
||||
}, 'HTML parser must enqueue attributeChanged reactions');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue