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

Side by Side Diff: LayoutTests/fast/dom/NodeList/nodelist-iterable.html

Issue 1220883007: [dom] support iterable<> NodeList (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add testharness.js tests for NodeList iterable remove HTMLCollection changes Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/domListEnumeration-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <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.
4 <script src="../../../resources/testharnessreport.js"></script>
5 <div id="container">
6 <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.
7 <div id='div2'></div><br>
8 <div id='div3'></div><br>
9 <div id='div4'></div><br>
10 <div id='div5'></div><br>
11 </div>
12 <script>
13 "use strict";
14
15 test(function () {
16 let nodeList = container.querySelectorAll('div');
17 let id = 0;
18 for (let node of nodeList) {
19 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).
20 assert_equals(node.id, "div" + ++id, "elements should be the expected va lues");
21 }
22 }, "for (node of NodeList)");
23
24
25 test(function () {
26 let nodeList = container.querySelectorAll('div');
27 for (let entry of nodeList.entries()) {
28 let id = entry[0] + 1;
29 let node = entry[1];
30 assert_true(node instanceof HTMLDivElement, "elements should be expected types");
31 assert_equals(node.id, "div" + id, "elements should be the expected valu es");
32 }
33 }, "for ([index, node] of NodeList.entries())");
34
35
36 test(function () {
37 let nodeList = container.querySelectorAll('div');
38 for (let id of nodeList.keys()) {
39 let node = nodeList[id++];
40 assert_true(node instanceof HTMLDivElement, "elements should be expected types");
41 assert_equals(node.id, "div" + id, "elements should be the expected valu es");
42 }
43 }, "for (index of NodeList.keys())");
44
45
46 test(function () {
47 let nodeList = container.querySelectorAll('div');
48 let id = 0;
49 for (let node of nodeList.values()) {
50 assert_true(node instanceof HTMLDivElement, "elements should be expected types");
51 assert_equals(node.id, "div" + ++id, "elements should be the expected va lues");
52 }
53 }, "for (node of NodeList.values())");
54
55
56 test(function () {
57 let nodeList = container.querySelectorAll('div');
58 nodeList.forEach(function(node, id) {
59 assert_true(node instanceof HTMLDivElement, "elements should be expected types");
60 assert_equals(node.id, "div" + ++id, "elements should be the expected va lues");
61 });
62 }, "iterable<Node>#forEach()");
63
64 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
65 container.style.display = "none";
66 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/domListEnumeration-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698