Update web-platform-tests to revision 1e4fe87a7f01c0b5c614c8f601ffa68b4a00662a

This commit is contained in:
WPT Sync Bot 2018-02-13 20:15:58 -05:00
parent 4c3f1756da
commit 432648745e
164 changed files with 8354 additions and 595 deletions

View file

@ -36,12 +36,18 @@ test(function () {
customElements.define('autonomous-custom-element', AutonomousCustomElement);
customElements.define('is-custom-element', IsCustomElement);
var instance = document.createElement('autonomous-custom-element', { is: "is-custom-element"});
var instance = document.createElement('autonomous-custom-element', { is: 'is-custom-element'});
assert_true(instance instanceof AutonomousCustomElement);
assert_equals(instance.localName, 'autonomous-custom-element');
assert_equals(instance.namespaceURI, 'http://www.w3.org/1999/xhtml', 'A custom element HTML must use HTML namespace');
var instance2 = document.createElement('undefined-element', { is: 'is-custom-element'});
assert_false(instance2.matches(':defined'));
class DefinedLater extends HTMLElement {}
customElements.define('undefined-element', DefinedLater);
document.body.appendChild(instance2);
assert_true(instance2 instanceof DefinedLater);
}, 'document.createElement must create an instance of autonomous custom elements when it has is attribute');
function assert_reports(expected, testFunction, message) {
@ -349,6 +355,7 @@ test(() => {
// https://github.com/w3c/webcomponents/issues/608
let div = document.createElement('div', { is: 'my-div' });
assert_false(div instanceof MyElement);
assert_false(div.hasAttribute('is'));
customElements.define('my-div', MyElement, { extends: 'div' });
document.body.appendChild(div);

View file

@ -38,6 +38,7 @@ test(() => {
let element = document.createElementNS('http://www.w3.org/1999/xhtml', 'p:address', { is: 'my-builtin'});
assert_true(element instanceof MyBuiltinElement);
assert_equals(element.prefix, 'p');
assert_false(element.hasAttribute('is'));
}, 'builtin: document.createElementNS should create custom elements with prefixes.');
test(() => {
@ -46,6 +47,7 @@ test(() => {
customElements.define('my-builtin2', MyBuiltinElement2, { extends: 'address'});
let element = document.createElementNS('urn:example', 'address', { is: 'my-builtin2' });
assert_false(element instanceof MyBuiltinElement2);
assert_false(element.hasAttribute('is'));
}, 'builtin: document.createElementNS should check namespaces.');
</script>
</body>

View file

@ -800,17 +800,24 @@ for (const t of testData) {
test(() => {
let customized = new t.klass();
assert_equals(customized.constructor, t.klass);
assert_equals(customized.cloneNode().constructor, t.klass,
'Cloning a customized built-in element should succeed.');
}, `${t.tag}: Operator 'new' should instantiate a customized built-in element`);
test(() => {
let customized = document.createElement(t.tag, { is: name });
assert_equals(customized.constructor, t.klass);
assert_equals(customized.cloneNode().constructor, t.klass,
'Cloning a customized built-in element should succeed.');
}, `${t.tag}: document.createElement() should instantiate a customized built-in element`);
if (t.parsing == 'document') {
let test = async_test(`${t.tag}: document parser should instantiate a customized built-in element`);
window.addEventListener('load', test.step_func_done(() => {
assert_equals(document.querySelector(t.tag).constructor, t.klass);
let customized = document.querySelector(t.tag);
assert_equals(customized.constructor, t.klass);
assert_equals(customized.cloneNode().constructor, t.klass,
'Cloning a customized built-in element should succeed.');
}));
return;
}
@ -823,6 +830,8 @@ for (const t of testData) {
}
let customized = document.getElementById(name);
assert_equals(customized.constructor, t.klass);
assert_equals(customized.cloneNode().constructor, t.klass,
'Cloning a customized built-in element should succeed.');
}, `${t.tag}: innerHTML should instantiate a customized built-in element`);
}, `${t.tag}: Define a customized built-in element`);

View file

@ -0,0 +1,56 @@
<!DOCTYPE html>
<link rel="help" href="https://dom.spec.whatwg.org/#dom-document-importnode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/custom-elements-helpers.js"></script>
<body>
<script>
test_with_window((w, doc) => {
class MyElement extends HTMLElement {}
class MyElement2 extends w.HTMLElement {}
customElements.define('my-element', MyElement);
w.customElements.define('my-element', MyElement2);
let original = document.createElement('my-element');
assert_true(original instanceof MyElement);
let imported = doc.importNode(original);
assert_true(imported instanceof MyElement2);
}, 'autonomous: document.importNode() should import custom elements successfully');
test_with_window((w, doc) => {
class MyElement3 extends w.HTMLElement {}
w.customElements.define('my-element3', MyElement3);
let original = document.createElement('my-element3');
assert_equals(original.constructor, HTMLElement);
let imported = doc.importNode(original);
assert_true(imported instanceof MyElement3);
}, 'autonomous: document.importNode() should import "undefined" custom elements successfully');
test_with_window((w, doc) => {
class MyDiv extends HTMLDivElement {}
class MyDiv2 extends w.HTMLDivElement {}
customElements.define('my-div', MyDiv, { extends: 'div' });
w.customElements.define('my-div', MyDiv2, { extends: 'div' });
let original = document.createElement('div', { is: 'my-div' });
assert_true(original instanceof MyDiv);
let imported = doc.importNode(original);
assert_true(imported instanceof MyDiv2);
}, 'built-in: document.importNode() should import custom elements successfully');
test_with_window((w, doc) => {
class MyDiv2 extends w.HTMLDivElement {}
w.customElements.define('my-div2', MyDiv2, { extends: 'div' });
let original = document.createElement('div', { is: 'my-div2' });
assert_equals(original.constructor, HTMLDivElement);
let imported = doc.importNode(original);
assert_true(imported instanceof MyDiv2);
}, 'built-in: document.importNode() should import "undefined" custom elements successfully');
</script>
</body>

View file

@ -49,6 +49,35 @@ test(function () {
'A cloned custom element must be an instance of the custom element');
}, 'Node.prototype.cloneNode(false) must be able to clone as a autonomous custom element when it contains is attribute');
test(function () {
class MyDiv1 extends HTMLDivElement {};
class MyDiv2 extends HTMLDivElement {};
class MyDiv3 extends HTMLDivElement {};
customElements.define('my-div1', MyDiv1, { extends: 'div' });
customElements.define('my-div2', MyDiv2, { extends: 'div' });
let instance = document.createElement('div', { is: 'my-div1'});
assert_true(instance instanceof MyDiv1);
instance.setAttribute('is', 'my-div2');
let clone = instance.cloneNode(false);
assert_not_equals(instance, clone);
assert_true(clone instanceof MyDiv1,
'A cloned custom element must be an instance of the custom element even with an inconsistent "is" attribute');
let instance3 = document.createElement('div', { is: 'my-div3'});
assert_false(instance3 instanceof MyDiv3);
instance3.setAttribute('is', 'my-div2');
let clone3 = instance3.cloneNode(false);
assert_not_equals(instance3, clone);
customElements.define('my-div3', MyDiv3, { extends: 'div' });
document.body.appendChild(instance3);
document.body.appendChild(clone3);
assert_true(instance3 instanceof MyDiv3,
'An undefined element must be upgraded even with an inconsistent "is" attribute');
assert_true(clone3 instanceof MyDiv3,
'A cloned undefined element must be upgraded even with an inconsistent "is" attribute');
}, 'Node.prototype.cloneNode(false) must be able to clone as a customized built-in element when it has an inconsistent "is" attribute');
test_with_window(function (contentWindow) {
var contentDocument = contentWindow.document;
class MyCustomElement extends contentWindow.HTMLElement {}