OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
4 <script src="heap-snapshot-test.js"></script> | 4 <script src="heap-snapshot-test.js"></script> |
5 <script> | 5 <script> |
6 | 6 |
7 function test() | 7 function test() |
8 { | 8 { |
9 var instanceCount = 25; | 9 var instanceCount = 25; |
10 function createHeapSnapshot() | 10 function createHeapSnapshot() |
11 { | 11 { |
12 return InspectorTest.createHeapSnapshot(instanceCount); | 12 return InspectorTest.createHeapSnapshot(instanceCount); |
13 } | 13 } |
14 | 14 |
15 InspectorTest.runHeapSnapshotTestSuite([ | 15 InspectorTest.runHeapSnapshotTestSuite([ |
16 function testSearch(next) | 16 function testSearch(next) |
17 { | 17 { |
18 InspectorTest.takeAndOpenSnapshot(createHeapSnapshot, step1a); | 18 InspectorTest.takeAndOpenSnapshot(createHeapSnapshot, step1a); |
| 19 function addSearchResultSniffer(step) |
| 20 { |
| 21 function jumpToSearchResult() |
| 22 { |
| 23 step(InspectorTest.currentProfileView()._searchResults.lengt
h); |
| 24 } |
| 25 InspectorTest.addSniffer(InspectorTest.currentProfileView(), "_j
umpToSearchResult", jumpToSearchResult); |
| 26 } |
| 27 |
| 28 function addNodeHighlightSniffer(callback) |
| 29 { |
| 30 InspectorTest.addSniffer(InspectorTest.currentProfileView(), "_d
idHighlightById", callback); |
| 31 } |
19 | 32 |
20 function step1a() | 33 function step1a() |
21 { | 34 { |
22 InspectorTest.switchToView("Summary", step1b); | 35 InspectorTest.switchToView("Summary", step1b); |
23 } | 36 } |
24 | 37 |
25 function step1b() | 38 function step1b() |
26 { | 39 { |
27 var row = InspectorTest.findRow("Window"); | 40 var row = InspectorTest.findRow("Window"); |
28 InspectorTest.assertEquals(true, !!row, "\"Window\" class row"); | 41 InspectorTest.assertEquals(true, !!row, "\"Window\" class row"); |
29 InspectorTest.expandRow(row, step1c); | 42 InspectorTest.expandRow(row, step1c); |
30 } | 43 } |
31 | 44 |
32 function step1c(row) | 45 function step1c(row) |
33 { | 46 { |
34 InspectorTest.assertEquals(1, row.children.length, "single Windo
w object"); | 47 InspectorTest.assertEquals(1, row.children.length, "single Windo
w object"); |
35 var windowRow = row.children[0]; | 48 var windowRow = row.children[0]; |
36 InspectorTest.assertEquals(true, !!windowRow, "\"Window\" instan
ce row"); | 49 InspectorTest.assertEquals(true, !!windowRow, "\"Window\" instan
ce row"); |
37 InspectorTest.expandRow(windowRow, step2); | 50 InspectorTest.expandRow(windowRow, step2); |
38 } | 51 } |
39 | 52 |
40 function step2() | 53 function step2() |
41 { | 54 { |
42 InspectorTest.currentProfileView().performSearch("A", step3); | 55 addSearchResultSniffer(step3); |
| 56 InspectorTest.currentProfileView().performSearch({query: "A", ca
seSensitive: false}); |
43 } | 57 } |
44 | 58 |
45 function step3(view, resultCount) | 59 function step3(resultCount) |
46 { | 60 { |
47 InspectorTest.assertEquals(1, resultCount, "Search for existing
node"); | 61 InspectorTest.assertEquals(1, resultCount, "Search for existing
node"); |
48 view.searchCanceled(); | 62 addSearchResultSniffer(step4); |
49 view.performSearch("foo", step4); | 63 InspectorTest.currentProfileView().performSearch({query: "foo",
caseSensitive:false}); |
50 } | 64 } |
51 | 65 |
52 function step4(view, resultCount) | 66 function step4(resultCount) |
53 { | 67 { |
54 InspectorTest.assertEquals(0, resultCount, "Search for not-exist
ing node"); | 68 InspectorTest.assertEquals(0, resultCount, "Search for not-exist
ing node"); |
55 view.searchCanceled(); | 69 addNodeHighlightSniffer(step5); |
56 view.performSearch("@999", step5); | 70 InspectorTest.currentProfileView().performSearch({query: "@999",
caseSensitive: false}); |
57 } | 71 } |
58 | 72 |
59 function step5(view, resultCount) | 73 function step5(found) |
60 { | 74 { |
61 InspectorTest.assertEquals(0, resultCount, "Search for not-exist
ing node by id"); | 75 InspectorTest.assertEquals(false, found, "Search for not-existin
g node by id"); |
62 view.searchCanceled(); | 76 addNodeHighlightSniffer(step6); |
63 view.performSearch("@83", step6); | 77 InspectorTest.currentProfileView().performSearch({query: "@83",
caseSensitive:false}); |
64 } | 78 } |
65 | 79 |
66 function step6(view, resultCount) | 80 function step6(found) |
67 { | 81 { |
68 InspectorTest.assertEquals(1, resultCount, "Search for existing
node by id"); | 82 InspectorTest.assertEquals(true, found, "Search for existing nod
e by id"); |
69 next(); | 83 next(); |
70 } | 84 } |
71 } | 85 } |
72 ]); | 86 ]); |
73 } | 87 } |
74 | 88 |
75 </script> | 89 </script> |
76 </head> | 90 </head> |
77 <body onload="runTest()"> | 91 <body onload="runTest()"> |
78 <p> | 92 <p> |
79 Tests search in Summary view of detailed heap snapshots. | 93 Tests search in Summary view of detailed heap snapshots. |
80 </p> | 94 </p> |
81 </body> | 95 </body> |
82 </html> | 96 </html> |
OLD | NEW |