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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-previousNodeLastChildReject.html

Issue 1529523002: Import dom/ from web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak W3CImportExpectations Created 5 years 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <!--
4 Test adapted from https://mxr.mozilla.org/chromium/source/src/third_party/WebKit /LayoutTests/fast/dom/TreeWalker/script-tests/previousNodeLastChildReject.js
5 -->
6 <head>
7 <title>TreeWalker: previousNodeLastChildReject</title>
8 <script src="../../../../resources/testharness.js"></script>
9 <script src="../../../../resources/testharnessreport.js"></script>
10 <script src="traversal-support.js"></script>
11 <link rel="stylesheet" href="../../../../resources/testharness.css">
12 <div id=log></div>
13 </head>
14 <body>
15 <p>Test that previousNode properly respects the filter.</p>
16 <script>
17 var testElement;
18 setup(function() {
19 testElement = document.createElement("div");
20 testElement.id = 'root';
21 // testElement.innerHTML='<div id="A1"><div id="B1"><div id="C1"></div><div id="C2"><div id="D1"></div><div id="D2"></div></div></div><div id="B2"><div id=" C3"></div><div id="C4"></div></div></div>';
22 // testElement.innerHTML='
23 // <div id="A1">
24 // <div id="B1">
25 // <div id="C1">
26 // </div>
27 // <div id="C2">
28 // <div id="D1">
29 // </div>
30 // <div id="D2">
31 // </div>
32 // </div>
33 // </div>
34 // <div id="B2">
35 // <div id="C3">
36 // </div>
37 // <div id="C4">
38 // </div>
39 // </div>
40 // </div>';
41
42 // XXX for Servo, build the tree without using innerHTML
43 var a1 = document.createElement("div"); a1.id = "A1";
44 var b1 = document.createElement("div"); b1.id = "B1";
45 var b2 = document.createElement("div"); b2.id = "B2";
46 var c1 = document.createElement("div"); c1.id = "C1";
47 var c2 = document.createElement("div"); c2.id = "C2";
48 var c3 = document.createElement("div"); c3.id = "C3";
49 var c4 = document.createElement("div"); c4.id = "C4";
50 var d1 = document.createElement("div"); d1.id = "D1";
51 var d2 = document.createElement("div"); d2.id = "D2";
52
53 testElement.appendChild(a1);
54 a1.appendChild(b1);
55 a1.appendChild(b2);
56 b1.appendChild(c1);
57 b1.appendChild(c2);
58 b2.appendChild(c3);
59 b2.appendChild(c4);
60 c2.appendChild(d1);
61 c2.appendChild(d2);
62 });
63
64 test(function()
65 {
66 function filter(node)
67 {
68 if (node.id == "C2")
69 return NodeFilter.FILTER_REJECT;
70 return NodeFilter.FILTER_ACCEPT;
71 }
72
73 var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter);
74 assert_node(walker.currentNode, { type: Element, id: 'root' });
75 assert_node(walker.firstChild(), { type: Element, id: 'A1' });
76 assert_node(walker.currentNode, { type: Element, id: 'A1' });
77 assert_node(walker.nextNode(), { type: Element, id: 'B1' });
78 assert_node(walker.currentNode, { type: Element, id: 'B1' });
79 assert_node(walker.nextNode(), { type: Element, id: 'C1' });
80 assert_node(walker.currentNode, { type: Element, id: 'C1' });
81 assert_node(walker.nextNode(), { type: Element, id: 'B2' });
82 assert_node(walker.currentNode, { type: Element, id: 'B2' });
83 assert_node(walker.previousNode(), { type: Element, id: 'C1' });
84 assert_node(walker.currentNode, { type: Element, id: 'C1' });
85 }, 'Test that previousNode properly respects the filter.');
86 </script>
87 </body>
88 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698