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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector-unit/viewport-datagrid-items-expandable-attached-to-dom.js

Issue 2781593003: [Devtools] DataGrid & ViewportDataGrid now should resetNode for children (Closed)
Patch Set: [Devtools] DataGrid & ViewportDataGrid now should resetNode for children Created 3 years, 9 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/http/tests/inspector-unit/viewport-datagrid-items-expandable-attached-to-dom.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-unit/viewport-datagrid-items-expandable-attached-to-dom.js b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/viewport-datagrid-items-expandable-attached-to-dom.js
new file mode 100644
index 0000000000000000000000000000000000000000..78dee70b967bbbf6c92db87240972e7b67da7e23
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/viewport-datagrid-items-expandable-attached-to-dom.js
@@ -0,0 +1,107 @@
+TestRunner.loadLazyModules(['data_grid']).then(test);
+function test() {
+ TestRunner.addResult("This tests viewport datagrid.");
+
+ var div = document.createElement("div");
+ UI.inspectorView.element.appendChild(div);
+
+ var columns = [{id: "id", title: "ID column", width: "250px"}];
+ var dataGrid = new DataGrid.ViewportDataGrid(columns);
+ div.appendChild(dataGrid.element);
+ dataGrid.element.style.height = '150px';
+
+ var rootNode = dataGrid.rootNode();
+ var nodes = [];
+
+ for (var i = 0; i <= 25; i++) {
+ var node = new DataGrid.ViewportDataGridNode({id: "a" + i});
+ rootNode.appendChild(node);
+ nodes.push(node);
+ }
+
+ TestRunner.addResult("Nodes 3 and 24 have children but should be collapsed initially");
+
+ node = new DataGrid.ViewportDataGridNode({id: "a" + 3 + "." + 0});
+ nodes.push(node);
+ nodes[3].appendChild(node);
+ node = new DataGrid.ViewportDataGridNode({id: "a" + 3 + "." + 1});
+ nodes.push(node);
+ nodes[3].appendChild(node);
+ node = new DataGrid.ViewportDataGridNode({id: "a" + 3 + "." + 2});
+ nodes.push(node);
+ nodes[3].appendChild(node);
+
+ node = new DataGrid.ViewportDataGridNode({id: "a" + 24 + "." + 0});
+ nodes.push(node);
+ nodes[24].appendChild(node);
+ node = new DataGrid.ViewportDataGridNode({id: "a" + 24 + "." + 1});
+ nodes.push(node);
+ nodes[24].appendChild(node);
+
+ dataGrid._update();
+ dumpVisibleNodes();
+
+ TestRunner.addResult("Expanding Node 3 and Node 24");
+ nodes[3].expand();
+ nodes[24].expand();
+ dataGrid._update();
+ dumpVisibleNodes();
+
+ TestRunner.addResult("Collapsing Node 3");
+ nodes[3].collapse();
+ dataGrid._update();
+ dumpVisibleNodes();
+
+ TestRunner.addResult("Scrolled down to 220px");
+ setScrollPosition(220);
+ dataGrid._update();
+ TestRunner.addResult("Expanding Node 3 while not in dom");
+ nodes[3].expand();
+ dataGrid._update();
+ TestRunner.addResult("Scrolled back up to 0px");
+ setScrollPosition(0);
+ dataGrid._update();
+ dumpVisibleNodes();
+
+ TestRunner.addResult("Moving node 0 to be a child of node 3 to make sure attributes adjust (name does not change)");
+ nodes[3].insertChild(nodes[0], 0);
+ dataGrid._update();
+ dumpVisibleNodes();
+
+ TestRunner.addResult("Moving node that is attached to dom (node 0) to child of offscreen parent (node 24)");
+ nodes[24].insertChild(nodes[0], 0);
+ dataGrid._update();
+ dumpVisibleNodes();
+
+ TestRunner.addResult("Scrolling down to 1000px - should be at bottom to make sure node 0 is attached properly to node 24");
+ setScrollPosition(1000);
+ dataGrid._update();
+ dumpVisibleNodes();
+
+ TestRunner.completeTest();
+
+ function setScrollPosition(yPosition) {
+ dataGrid._scrollContainer.scrollTop = yPosition;
+ dataGrid._onScroll();
+ }
+
+ function dumpVisibleNodes() {
+ TestRunner.addResult("Nodes attached to dom:");
+ for (var node of rootNode.flatChildren()) {
+ var element = node.existingElement();
+ if (!element)
+ continue;
+ if (div.contains(element)) {
+ var attributes = [];
+ if (node.hasChildren())
+ attributes.push("has children");
+ if (node.depth)
+ attributes.push("depth: " + node.depth);
+ if (node.expanded)
+ attributes.push("expanded");
+ TestRunner.addResult(node.data.id + " " + attributes.join(', '));
+ }
+ }
+ TestRunner.addResult("");
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698