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

Unified Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-basic.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-basic.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/TreeWalker-basic.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-basic.html
similarity index 67%
copy from third_party/WebKit/LayoutTests/fast/dom/TreeWalker/TreeWalker-basic.html
copy to third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-basic.html
index 4921af392590da500dde30f131670aeea41f5ea6..501c2e7f78c3d00454cb68a2c6bd56bf7a75032a 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/TreeWalker-basic.html
+++ b/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-basic.html
@@ -1,10 +1,15 @@
<!DOCTYPE html>
<html>
+<!--
+Test adapted from https://mxr.mozilla.org/chromium/source/src/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/TreeWalker-basic.html
+ -->
<head>
<title>TreeWalker: Basic test</title>
-<script src="../../../resources/testharness.js"></script>
-<script src="../../../resources/testharnessreport.js"></script>
-<link rel="stylesheet" href="../../../resources/testharness.css">
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<script src="traversal-support.js"></script>
+<link rel="stylesheet" href="../../../../resources/testharness.css">
+<div id=log></div>
</head>
<body>
<p>This test checks the basic functionality of TreeWalker.</p>
@@ -31,27 +36,52 @@ function createSampleDOM()
// "g" <!--h-->
var div = document.createElement('div');
div.id = 'a';
- div.innerHTML = 'b<div id="c"><div id="d">e<span id="f">g<!--h--></span>i</div><!--j--></div>';
+ // div.innerHTML = 'b<div id="c"><div id="d">e<span id="f">g<!--h--></span>i</div><!--j--></div>';
+
+ div.appendChild(document.createTextNode("b"));
+
+ var c = document.createElement("div");
+ c.id = 'c';
+ div.appendChild(c);
+
+ var d = document.createElement("div");
+ d.id = 'd';
+ c.appendChild(d);
+
+ var e = document.createTextNode("e");
+ d.appendChild(e);
+
+ var f = document.createElement("span");
+ f.id = 'f';
+ d.appendChild(f);
+
+ var g = document.createTextNode("g");
+ f.appendChild(g);
+
+ var h = document.createComment("h");
+ f.appendChild(h);
+
+ var i = document.createTextNode("i");
+ d.appendChild(i);
+
+ var j = document.createComment("j");
+ c.appendChild(j);
+
return div;
}
-function check_walker(walker, root)
+function check_walker(walker, root, whatToShowValue)
{
- assert_equals(walker.toString(), '[object TreeWalker]');
- assert_equals(walker.root, root);
- assert_equals(walker.whatToShow, 0xFFFFFFFF);
- assert_equals(walker.filter, null);
- assert_equals(walker.currentNode, root);
+ whatToShowValue = whatToShowValue === undefined ? 0xFFFFFFFF : whatToShowValue;
+
+ assert_equals(walker.toString(), '[object TreeWalker]', 'toString');
+ assert_equals(walker.root, root, 'root');
+ assert_equals(walker.whatToShow, whatToShowValue, 'whatToShow');
+ assert_equals(walker.filter, null, 'filter');
+ assert_equals(walker.currentNode, root, 'currentNode');
assert_readonly(walker, 'root');
assert_readonly(walker, 'whatToShow');
assert_readonly(walker, 'filter');
- assert_idl_attribute(walker, 'parentNode');
- assert_idl_attribute(walker, 'firstChild');
- assert_idl_attribute(walker, 'lastChild');
- assert_idl_attribute(walker, 'previousSibling');
- assert_idl_attribute(walker, 'nextSibling');
- assert_idl_attribute(walker, 'previousNode');
- assert_idl_attribute(walker, 'nextNode');
}
test(function ()
@@ -64,6 +94,13 @@ test(function ()
test(function ()
{
var root = createSampleDOM();
+ var walker = document.createTreeWalker(root, null, null);
+ check_walker(walker, root, 0);
+}, 'Construct a TreeWalker by document.createTreeWalker(root, null, null).');
+
+test(function ()
+{
+ var root = createSampleDOM();
var walker = document.createTreeWalker(root, undefined, undefined);
check_walker(walker, root);
}, 'Construct a TreeWalker by document.createTreeWalker(root, undefined, undefined).');
@@ -77,23 +114,11 @@ test(function ()
assert_throws(new TypeError(), function () { document.createTreeWalker(1); });
}, 'Give an invalid root node to document.createTreeWalker().');
-// |expected| should be an object indicating the expected type of node.
-function assert_node(actual, expected)
-{
- assert_true(actual instanceof expected.type,
- 'Node type mismatch: actual = ' + actual.nodeType + ', expected = ' + expected.nodeType);
- if (typeof(expected.id) !== 'undefined')
- assert_equals(actual.id, expected.id);
- if (typeof(expected.nodeValue) !== 'undefined')
- assert_equals(actual.nodeValue, expected.nodeValue);
-}
-
test(function ()
{
var root = createSampleDOM();
var walker = document.createTreeWalker(root);
var f = root.lastChild.firstChild.childNodes[1]; // An element node: div#f.
- var body = document.body; // An element outside |root|.
assert_node(walker.currentNode, { type: Element, id: 'a' });
assert_equals(walker.parentNode(), null);
@@ -118,8 +143,6 @@ test(function ()
assert_equals(walker.currentNode, f);
}, 'Walk over nodes.');
-// FIXME: Add tests that use |whatToShow| argument and/or |filter| argument.
-
test(function() {
var treeWalker = document.createTreeWalker(document.body, 42, null);
assert_equals(treeWalker.root, document.body);

Powered by Google App Engine
This is Rietveld 408576698