| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="heap-snapshot-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| var instanceCount = 10; |
| function createHeapSnapshot() |
| { |
| return InspectorTest.createHeapSnapshot(instanceCount); |
| } |
| |
| InspectorTest.runHeapSnapshotTestSuite([ |
| function testSorting(next) |
| { |
| InspectorTest.takeAndOpenSnapshot(createHeapSnapshot, step1); |
| |
| function step1() |
| { |
| InspectorTest.switchToView("Summary", step1a); |
| } |
| |
| var columns; |
| var currentColumn; |
| var currentColumnOrder; |
| var windowRow; |
| |
| function step1a() |
| { |
| var row = InspectorTest.findRow("object", "Window"); |
| InspectorTest.assertEquals(true, !!row, "\"Window\" class row"); |
| InspectorTest.expandRow(row, step1b); |
| } |
| |
| function step1b(row) |
| { |
| InspectorTest.assertEquals(1, row.children.length, "single Window object"); |
| windowRow = row.children[0]; |
| InspectorTest.assertEquals(true, !!windowRow, "\"Window\" instance row"); |
| InspectorTest.expandRow(windowRow, step2); |
| } |
| |
| function step2() |
| { |
| columns = InspectorTest.viewColumns(); |
| currentColumn = 0; |
| currentColumnOrder = false; |
| step3(); |
| } |
| |
| function step3() |
| { |
| if (currentColumn >= columns.length) { |
| setTimeout(next, 0); |
| return; |
| } |
| InspectorTest.clickColumn(columns[currentColumn], step4); |
| } |
| |
| function step4(newColumnState) |
| { |
| columns[currentColumn] = newColumnState; |
| var columnName = columns[currentColumn].identifier; |
| var contents = windowRow.children.map(function(obj) { return JSON.stringify(obj.data[columnName]); }); |
| InspectorTest.assertEquals(instanceCount, contents.length, "column contents"); |
| var sortTypes = { object: "text", distanceToWindow: "number", count: "number", shallowSize: "size", retainedSize: "size" }; |
| InspectorTest.assertEquals(true, !!sortTypes[columns[currentColumn].identifier], "sort by identifier"); |
| InspectorTest.checkArrayIsSorted(contents, sortTypes[columns[currentColumn].identifier], columns[currentColumn].sort); |
| |
| if (!currentColumnOrder) |
| currentColumnOrder = true; |
| else { |
| currentColumnOrder = false; |
| ++currentColumn; |
| } |
| step3(); |
| } |
| } |
| ]); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p> |
| Tests sorting in Summary view of detailed heap snapshots. |
| </p> |
| </body> |
| </html> |