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

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/dom/dom-request-child-nodes-depth.js

Issue 2955943002: DevTools: migrate inspector-protocol/dom tests to a new test runner (Closed)
Patch Set: rebaseline Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector-protocol/dom/dom-request-child-nodes-depth.js
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/dom/dom-request-child-nodes-depth.js b/third_party/WebKit/LayoutTests/inspector-protocol/dom/dom-request-child-nodes-depth.js
new file mode 100644
index 0000000000000000000000000000000000000000..4d43543d321c3e7f2691be098484859176925f64
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/dom/dom-request-child-nodes-depth.js
@@ -0,0 +1,78 @@
+(async function(testRunner) {
+ var {page, session, dp} = await testRunner.startHTML(`
+ <div id="depth-1">
+ <div id="depth-2">
+ <div id="depth-3">
+ <div id="depth-4">
+ <div id="depth-5">
+ <div id="depth-6">
+ <div id="depth-7">
+ <div id="depth-8">
+ <div id="depth-9">
+ <div id="depth-10">
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ `, '');
+ testRunner.log("\n=== Get the Document ===\n");
+ var response = await dp.DOM.getDocument();
+ var bodyId = response.result.root.children[0].children[1].nodeId;
+
+ testRunner.log("\n=== Get immediate children of the body ===\n");
+ dp.DOM.requestChildNodes({nodeId: bodyId});
+ var message = await dp.DOM.onceSetChildNodes();
+ var firstDiv = message.params.nodes[0];
+ assert("First child is a div", firstDiv.localName, "div");
+ assert("First child is div#depth-1", firstDiv.attributes[1], "depth-1");
+ assert("First child has one child", firstDiv.childNodeCount, 1);
+ assert("First child has no .children property", firstDiv.children, undefined);
+
+ testRunner.log("\n=== Get children of div#depth-1 three levels deep ===\n");
+ dp.DOM.requestChildNodes({nodeId: firstDiv.nodeId, depth: 3});
+ var message = await dp.DOM.onceSetChildNodes();
+ var depth = 1;
+ var firstChild = message.params.nodes[0];
+ var node = firstChild;
+ while (node && node.children) {
+ depth++;
+ node = node.children[0];
+ }
+ assert("div#depth-1 has nodes 3 levels deep", depth, 3);
+
+ testRunner.log("\n=== Get all children of body ===\n");
+ dp.DOM.requestChildNodes({nodeId: firstDiv.nodeId, depth: -1});
+ var message = await dp.DOM.onceSetChildNodes();
+ var depth = 0;
+ var firstChild = message.params.nodes[0];
+ var node = firstChild;
+ while (node && node.children) {
+ depth++;
+ node = node.children[0];
+ }
+ // We have requested nodes 3-level deep so far, so
+ // we should have gotten an additional 6 levels of depth.
+ assert("div#depth-1 has nodes 9 levels deep", depth, 6);
+
+ testRunner.log("\n=== Pass an invalid depth ===\n");
+ var response = await dp.DOM.requestChildNodes({nodeId: firstDiv.nodeId, depth: 0});
+ if (response.error)
+ testRunner.log("Backend error: " + response.error.message + " (" + response.error.code + ")\n");
+ testRunner.completeTest();
+
+ function assert(message, actual, expected) {
+ if (actual === expected) {
+ testRunner.log("PASS: " + message);
+ } else {
+ testRunner.log("FAIL: " + message + ", expected \"" + expected + "\" but got \"" + actual + "\"");
+ testRunner.completeTest();
+ }
+ };
+});
+

Powered by Google App Engine
This is Rietveld 408576698