Update web-platform-tests to revision 4a5223502fa660ce03e470af6a61c8bc26c5a8ee

This commit is contained in:
WPT Sync Bot 2018-04-23 21:13:37 -04:00
parent c5f7c9ccf3
commit e891345f26
1328 changed files with 36632 additions and 20588 deletions

View file

@ -190,4 +190,19 @@ function test_getElementsByTagName(context, element) {
get_elements(context);
assert_array_equals(actual, expected);
}, "getElementsByTagName('*')")
test(function() {
var t1 = element.appendChild(document.createElement("abc"));
this.add_cleanup(function() {element.removeChild(t1)});
var l = context.getElementsByTagName("abc");
assert_true(l instanceof HTMLCollection);
assert_equals(l.length, 1);
var t2 = element.appendChild(document.createElement("abc"));
assert_equals(l.length, 2);
element.removeChild(t2);
assert_equals(l.length, 1);
}, "getElementsByTagName() should be a live collection");
}

View file

@ -125,4 +125,19 @@ function test_getElementsByTagNameNS(context, element) {
assert_array_equals(context.getElementsByTagNameNS(null, "0"), []);
assert_array_equals(context.getElementsByTagNameNS(null, "div"), []);
}, "Empty lists")
test(function() {
var t1 = element.appendChild(document.createElementNS("test", "abc"));
this.add_cleanup(function() {element.removeChild(t1)});
var l = context.getElementsByTagNameNS("test", "abc");
assert_true(l instanceof HTMLCollection);
assert_equals(l.length, 1);
var t2 = element.appendChild(document.createElementNS("test", "abc"));
assert_equals(l.length, 2);
element.removeChild(t2);
assert_equals(l.length, 1);
}, "getElementsByTagNameNS() should be a live collection");
}

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<title>Document.getElementsByClassName</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var a = document.createElement("a"),
b = document.createElement("b");
a.className = "foo";
this.add_cleanup(function() {document.body.removeChild(a);});
document.body.appendChild(a);
var l = document.getElementsByClassName("foo");
assert_true(l instanceof HTMLCollection);
assert_equals(l.length, 1);
b.className = "foo";
document.body.appendChild(b);
assert_equals(l.length, 2);
document.body.removeChild(b);
assert_equals(l.length, 1);
}, "getElementsByClassName() should be a live collection");
</script>

View file

@ -13,9 +13,31 @@ test(function() {
var secondList = a.getElementsByClassName("foo")
assert_true(list === secondList || list !== secondList, "Caching is allowed.")
}, "getElementsByClassName should work on disconnected subtrees.")
test(function() {
var list = document.getElementsByClassName("foo")
assert_false(list instanceof NodeList, "NodeList")
assert_true(list instanceof HTMLCollection, "HTMLCollection")
}, "Interface should be correct.")
test(function() {
var a = document.createElement("a");
var b = document.createElement("b");
var c = document.createElement("c");
b.className = "foo";
document.body.appendChild(a);
this.add_cleanup(function() {document.body.removeChild(a)});
a.appendChild(b);
var l = a.getElementsByClassName("foo");
assert_true(l instanceof HTMLCollection);
assert_equals(l.length, 1);
c.className = "foo";
a.appendChild(c);
assert_equals(l.length, 2);
a.removeChild(c);
assert_equals(l.length, 1);
}, "getElementsByClassName() should be a live collection");
</script>

View file

@ -7,6 +7,9 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div style="display: none">
<ul id='test'><li>1</li><li>2</li><li>3</li><li>4</li></ul>
</div>
<script>
test(function() {
var element = document.createElement("p");
@ -96,4 +99,19 @@ test(function() {
assert_equals(list.entries, Array.prototype.entries);
assert_equals(list.forEach, Array.prototype.forEach);
}, "Iterator behavior of Node.childNodes");
test(() => {
var node = document.getElementById("test");
var children = node.childNodes;
assert_true(children instanceof NodeList);
var li = document.createElement("li");
assert_equals(children.length, 4);
node.appendChild(li);
assert_equals(children.length, 5);
node.removeChild(li);
assert_equals(children.length, 4);
}, "Node.childNodes should be a live collection");
</script>

View file

@ -240,7 +240,6 @@ test(function() {
assert_equals(doc.contentType, copy.contentType, "contentType equality");
assert_equals(doc.URL, "about:blank", "URL value")
assert_equals(doc.URL, copy.URL, "URL equality");
assert_equals(doc.origin, "null", "origin value")
assert_equals(doc.origin, copy.origin, "origin equality");
assert_equals(doc.compatMode, "CSS1Compat", "compatMode value");
assert_equals(doc.compatMode, copy.compatMode, "compatMode equality");
@ -286,4 +285,17 @@ test(function() {
assert_equals(copy.childNodes.length, 0,
"copy.childNodes.length with non-deep copy");
}, "node with children");
test(() => {
const proto = Object.create(HTMLElement.prototype),
node = document.createElement("hi");
Object.setPrototypeOf(node, proto);
assert_true(proto.isPrototypeOf(node));
const clone = node.cloneNode();
assert_false(proto.isPrototypeOf(clone));
assert_true(HTMLUnknownElement.prototype.isPrototypeOf(clone));
const deepClone = node.cloneNode(true);
assert_false(proto.isPrototypeOf(deepClone));
assert_true(HTMLUnknownElement.prototype.isPrototypeOf(deepClone));
}, "Node with custom prototype")
</script>

View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>ParentNode.children</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-parentnode-children">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div style="display: none">
<ul><li id='test'>1</li><li>2</li><li>3</li><li>4</li></ul>
</div>
<script>
test(() => {
var node = document.getElementById("test");
var parentNode = node.parentNode;
var children = parentNode.children;
assert_true(children instanceof HTMLCollection);
var li = document.createElement("li");
assert_equals(children.length, 4);
parentNode.appendChild(li);
assert_equals(children.length, 5);
parentNode.removeChild(li);
assert_equals(children.length, 4);
}, "ParentNode.children should be a live collection");
</script>
</html>