3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="heap-snapshot-test.js"></script>
9 var instanceCount = 200;
10 function createHeapSnapshot()
12 return InspectorTest.createHeapSnapshot(instanceCount, 100);
15 InspectorTest.runHeapSnapshotTestSuite([
16 function testSearch(next)
18 InspectorTest.takeAndOpenSnapshot(createHeapSnapshot, step1);
22 InspectorTest.switchToView("Summary", step2);
28 view = InspectorTest.currentProfileView();
29 view.performSearch("@101", checkNodeIsHighlighted.bind(this, "A", "101", step3));
34 view.searchCanceled();
35 view.performSearch("@a", step4);
38 function step4(view, resultCount)
40 if (resultCount !== 0) {
41 InspectorTest.addResult("FAIL: node @a found");
44 view.searchCanceled();
45 view.performSearch("@999", step5);
48 function step5(view, resultCount)
50 if (resultCount !== 0) {
51 InspectorTest.addResult("FAIL: found node @999");
54 view.searchCanceled();
55 view.performSearch("@100", checkNodeIsHighlighted.bind(this, "B", "100", step6));
60 view.searchCanceled();
61 view.performSearch("@400", checkNodeIsHighlighted.bind(this, "B", "400", step7));
66 view.searchCanceled();
67 view.performSearch("@401", checkNodeIsHighlighted.bind(this, "A", "401", next));
70 function checkNodeIsHighlighted(constructorName, nodeId, onSuccess, view, resultCount)
72 if (resultCount !== 1) {
73 InspectorTest.addResult("FAIL: node @" + nodeId + " not found");
77 var constructorsGrid = InspectorTest.currentProfileView()._dataGrid;
78 var constructorNodes = constructorsGrid.rootNode().children;
80 for (var i = 0; i < constructorNodes.length; i++) {
81 if (constructorNodes[i].data.object === constructorName) {
82 constructorNode = constructorNodes[i];
86 if (!constructorNode) {
87 InspectorTest.addResult("FAIL: constructor " + constructorName + " not found in viewport");
90 var instanceNodes = constructorNode.children;
91 for (var i = 0; i < instanceNodes.length; i++) {
92 if (instanceNodes[i].snapshotNodeId == nodeId) {
93 if (!instanceNodes[i].element().classList.contains("highlighted-row")) {
94 if (constructorsGrid._nodeToHighlightAfterScroll === instanceNodes[i]) {
95 function afterScroll(nodeToHighlight)
99 InspectorTest.addSniffer(WebInspector.HeapSnapshotSortableDataGrid.prototype, "highlightNode", afterScroll);
102 InspectorTest.addResult("FAIL: node is not highlighted");
110 InspectorTest.addResult("EXCEPTION: " + e);
120 <body onload="runTest()">
122 Tests search in Summary view of detailed heap snapshots.