Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-childNodes.html

Issue 2212873003: W3C auto test importer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-childNodes.html
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-childNodes.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-childNodes.html
index d08dd2e1fa551acd895e88c82d50652cd448f0ad..8bd1f250e472c0d27cffbb92e3d69688e7df939f 100644
--- a/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-childNodes.html
+++ b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-childNodes.html
@@ -45,4 +45,53 @@ test(function() {
test(function() {
check_parent_node(new Document());
}, "Node.childNodes on a Document.");
+
+test(function() {
+ var node = document.createElement("div");
+ var kid1 = document.createElement("p");
+ var kid2 = document.createTextNode("hey");
+ var kid3 = document.createElement("span");
+ node.appendChild(kid1);
+ node.appendChild(kid2);
+ node.appendChild(kid3);
+
+ var list = node.childNodes;
+ assert_array_equals([...list], [kid1, kid2, kid3]);
+
+ var keys = list.keys();
+ assert_false(keys instanceof Array);
+ keys = [...keys];
+ assert_array_equals(keys, [0, 1, 2]);
+
+ var values = list.values();
+ assert_false(values instanceof Array);
+ values = [...values];
+ assert_array_equals(values, [kid1, kid2, kid3]);
+
+ var entries = list.entries();
+ assert_false(entries instanceof Array);
+ entries = [...entries];
+ assert_equals(entries.length, keys.length);
+ assert_equals(entries.length, values.length);
+ for (var i = 0; i < entries.length; ++i) {
+ assert_array_equals(entries[i], [keys[i], values[i]]);
+ }
+
+ var cur = 0;
+ var thisObj = {};
+ list.forEach(function(value, key, listObj) {
+ assert_equals(listObj, list);
+ assert_equals(this, thisObj);
+ assert_equals(value, values[cur]);
+ assert_equals(key, keys[cur]);
+ cur++;
+ }, thisObj);
+ assert_equals(cur, entries.length);
+
+ assert_equals(list[Symbol.iterator], Array.prototype[Symbol.iterator]);
+ assert_equals(list.keys, Array.prototype.keys);
+ assert_equals(list.values, Array.prototype.values);
+ assert_equals(list.entries, Array.prototype.entries);
+ assert_equals(list.forEach, Array.prototype.forEach);
+}, "Iterator behavior of Node.childNodes");
</script>

Powered by Google App Engine
This is Rietveld 408576698