Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / profiler / heap-snapshot-summary-search-by-id.html
1 <html>
2 <head>
3   <script src="../../http/tests/inspector/inspector-test.js"></script>
4   <script src="heap-snapshot-test.js"></script>
5 <script>
6
7 function test()
8 {
9     var instanceCount = 200;
10     function createHeapSnapshot()
11     {
12         return InspectorTest.createHeapSnapshot(instanceCount, 100);
13     }
14
15     InspectorTest.runHeapSnapshotTestSuite([
16         function testSearch(next)
17         {
18             InspectorTest.takeAndOpenSnapshot(createHeapSnapshot, step1);
19
20             function step1()
21             {
22                 InspectorTest.switchToView("Summary", step2);
23             }
24
25             var view;
26             function step2()
27             {
28                 view = InspectorTest.currentProfileView();
29                 view.performSearch("@101", checkNodeIsHighlighted.bind(this, "A", "101", step3));
30             }
31
32             function step3()
33             {
34                 view.searchCanceled();
35                 view.performSearch("@a", step4);
36             }
37
38             function step4(view, resultCount)
39             {
40                 if (resultCount !== 0) {
41                     InspectorTest.addResult("FAIL: node @a found");
42                     return next();
43                 }
44                 view.searchCanceled();
45                 view.performSearch("@999", step5);
46             }
47
48             function step5(view, resultCount)
49             {
50                 if (resultCount !== 0) {
51                     InspectorTest.addResult("FAIL: found node @999");
52                     return next();
53                 }
54                 view.searchCanceled();
55                 view.performSearch("@100", checkNodeIsHighlighted.bind(this, "B", "100", step6));
56             }
57
58             function step6()
59             {
60                 view.searchCanceled();
61                 view.performSearch("@400", checkNodeIsHighlighted.bind(this, "B", "400", step7));
62             }
63
64             function step7()
65             {
66                 view.searchCanceled();
67                 view.performSearch("@401", checkNodeIsHighlighted.bind(this, "A", "401", next));
68             }
69
70             function checkNodeIsHighlighted(constructorName, nodeId, onSuccess, view, resultCount)
71             {
72                 if (resultCount !== 1) {
73                     InspectorTest.addResult("FAIL: node @" + nodeId + " not found");
74                     return next();
75                 }
76                 try {
77                     var constructorsGrid = InspectorTest.currentProfileView()._dataGrid;
78                     var constructorNodes = constructorsGrid.rootNode().children;
79                     var constructorNode;
80                     for (var i = 0; i < constructorNodes.length; i++) {
81                         if (constructorNodes[i].data.object === constructorName) {
82                             constructorNode = constructorNodes[i];
83                             break;
84                         }
85                     }
86                     if (!constructorNode) {
87                         InspectorTest.addResult("FAIL: constructor " + constructorName + " not found in viewport");
88                         return next();
89                     }
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)
96                                     {
97                                         onSuccess();
98                                     }
99                                     InspectorTest.addSniffer(WebInspector.HeapSnapshotSortableDataGrid.prototype, "highlightNode", afterScroll);
100                                     return;
101                                 } else {
102                                     InspectorTest.addResult("FAIL: node is not highlighted");
103                                     return next();
104                                 }
105                             }
106                             return onSuccess();
107                         }
108                     }
109                 } catch (e) {
110                     InspectorTest.addResult("EXCEPTION: " + e);
111                 }
112                 return next();
113             }
114         }
115     ]);
116 }
117
118 </script>
119 </head>
120 <body onload="runTest()">
121 <p>
122 Tests search in Summary view of detailed heap snapshots.
123 </p>
124 </body>
125 </html>