Chromium Code Reviews| Index: LayoutTests/fast/dom/NodeList/nodelist-iterable.html |
| diff --git a/LayoutTests/fast/dom/NodeList/nodelist-iterable.html b/LayoutTests/fast/dom/NodeList/nodelist-iterable.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..68d29be3c1b00523b22fb5ce4669fa7924cad097 |
| --- /dev/null |
| +++ b/LayoutTests/fast/dom/NodeList/nodelist-iterable.html |
| @@ -0,0 +1,66 @@ |
| +<!DOCTYPE html> |
| +<meta charset="utf-8"> |
| +<script src="../../../resources/testharness.js"></script> |
|
jsbell
2015/07/01 19:41:19
Nit: Add a <title> explaining the purpose of the t
caitp (gmail)
2015/07/01 20:22:35
Done.
|
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<div id="container"> |
| + <div id='div1'></div> |
|
jsbell
2015/07/01 19:41:19
nit: Be consistent in quoting (i.e. use "" here if
caitp (gmail)
2015/07/01 20:22:35
Done.
|
| + <div id='div2'></div><br> |
| + <div id='div3'></div><br> |
| + <div id='div4'></div><br> |
| + <div id='div5'></div><br> |
| +</div> |
| +<script> |
| +"use strict"; |
| + |
| +test(function () { |
| + let nodeList = container.querySelectorAll('div'); |
| + let id = 0; |
| + for (let node of nodeList) { |
| + assert_true(node instanceof HTMLDivElement, "elements should be expected types"); |
|
jsbell
2015/07/01 19:41:19
Ditto (i.e. use ' if used above, etc).
|
| + assert_equals(node.id, "div" + ++id, "elements should be the expected values"); |
| + } |
| +}, "for (node of NodeList)"); |
| + |
| + |
| +test(function () { |
| + let nodeList = container.querySelectorAll('div'); |
| + for (let entry of nodeList.entries()) { |
| + let id = entry[0] + 1; |
| + let node = entry[1]; |
| + assert_true(node instanceof HTMLDivElement, "elements should be expected types"); |
| + assert_equals(node.id, "div" + id, "elements should be the expected values"); |
| + } |
| +}, "for ([index, node] of NodeList.entries())"); |
| + |
| + |
| +test(function () { |
| + let nodeList = container.querySelectorAll('div'); |
| + for (let id of nodeList.keys()) { |
| + let node = nodeList[id++]; |
| + assert_true(node instanceof HTMLDivElement, "elements should be expected types"); |
| + assert_equals(node.id, "div" + id, "elements should be the expected values"); |
| + } |
| +}, "for (index of NodeList.keys())"); |
| + |
| + |
| +test(function () { |
| + let nodeList = container.querySelectorAll('div'); |
| + let id = 0; |
| + for (let node of nodeList.values()) { |
| + assert_true(node instanceof HTMLDivElement, "elements should be expected types"); |
| + assert_equals(node.id, "div" + ++id, "elements should be the expected values"); |
| + } |
| +}, "for (node of NodeList.values())"); |
| + |
| + |
| +test(function () { |
| + let nodeList = container.querySelectorAll('div'); |
| + nodeList.forEach(function(node, id) { |
| + assert_true(node instanceof HTMLDivElement, "elements should be expected types"); |
| + assert_equals(node.id, "div" + ++id, "elements should be the expected values"); |
| + }); |
| +}, "iterable<Node>#forEach()"); |
| + |
| +if (window.testRunner) |
|
jsbell
2015/07/01 19:41:19
Is this necessary?
caitp (gmail)
2015/07/01 20:22:35
Without it, the DOM elements in the test get added
|
| + container.style.display = "none"; |
| +</script> |