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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-currentNode.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/resources/TreeWalker-currentNode.js
5 -->
6 <head>
7 <title>TreeWalker: currentNode</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 <div id='parent'>
16 <div id='subTree'><p>Lorem ipsum <span>dolor <b>sit</b> amet</span>, consectetur <i>adipisicing</i> elit, sed do eiusmod <tt>tempor <b><i>incididunt ut</i> labo re</b> et dolore magna</tt> aliqua.</p></div>
17 </div>
18 <p>Test TreeWalker currentNode functionality</p>
19 <script>
20 // var subTree = document.createElement('div');
21 // subTree.innerHTML = "<p>Lorem ipsum <span>dolor <b>sit</b> amet</span>, conse ctetur <i>adipisicing</i> elit, sed do eiusmod <tt>tempor <b><i>incididunt ut</i > labore</b> et dolore magna</tt> aliqua.</p>"
22 // document.body.appendChild(subTree);
23 var subTree = document.getElementById("subTree");
24
25 var all = function(node) { return true; }
26
27 test(function()
28 {
29 var w = document.createTreeWalker(subTree, NodeFilter.SHOW_ELEMENT, all);
30 assert_node(w.currentNode, { type: Element, id: 'subTree' });
31 assert_equals(w.parentNode(), null);
32 assert_node(w.currentNode, { type: Element, id: 'subTree' });
33 }, "Test that TreeWalker.parent() doesn't set the currentNode to a node not unde r the root.");
34
35 test(function()
36 {
37 var w = document.createTreeWalker(subTree,
38 NodeFilter.SHOW_ELEMENT
39 | NodeFilter.SHOW_COMMENT,
40 all);
41 w.currentNode = document.documentElement;
42 assert_equals(w.parentNode(), null);
43 assert_equals(w.currentNode, document.documentElement);
44 w.currentNode = document.documentElement;
45 assert_equals(w.nextNode(), document.documentElement.firstChild);
46 assert_equals(w.currentNode, document.documentElement.firstChild);
47 w.currentNode = document.documentElement;
48 assert_equals(w.previousNode(), null);
49 assert_equals(w.currentNode, document.documentElement);
50 w.currentNode = document.documentElement;
51 assert_equals(w.firstChild(), document.documentElement.firstChild);
52 assert_equals(w.currentNode, document.documentElement.firstChild);
53 w.currentNode = document.documentElement;
54 assert_equals(w.lastChild(), document.documentElement.lastChild);
55 assert_equals(w.currentNode, document.documentElement.lastChild);
56 w.currentNode = document.documentElement;
57 assert_equals(w.nextSibling(), null);
58 assert_equals(w.currentNode, document.documentElement);
59 w.currentNode = document.documentElement;
60 assert_equals(w.previousSibling(), null);
61 assert_equals(w.currentNode, document.documentElement);
62 }, "Test that we handle setting the currentNode to arbitrary nodes not under the root element.");
63
64 test(function()
65 {
66 var w = document.createTreeWalker(subTree, NodeFilter.SHOW_ELEMENT, all);
67 w.currentNode = subTree.previousSibling;
68 assert_equals(w.nextNode(), subTree);
69 w.currentNode = document.getElementById("parent");
70 assert_equals(w.firstChild(), subTree);
71 }, "Test how we handle the case when the traversed to node is within the root, b ut the currentElement is not.");
72 </script>
73 </body>
74 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698