| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../http/tests/inspector/resources/inspector-test.js"></script> |
| <script> |
| function test() |
| { |
| let suite = InspectorTest.createAsyncSuite("Heap.snapshot"); |
| |
| suite.addTestCase({ |
| name: "TriggerSnapshot", |
| description: "Calling Heap.snapshot should create a heap snapshot.", |
| test(resolve, reject) { |
| HeapAgent.snapshot((error, timestamp, snapshotStringData) => { |
| InspectorTest.expectThat(!error, "Should not have an error creating a snapshot."); |
| let workerProxy = WI.HeapSnapshotWorkerProxy.singleton(); |
| workerProxy.createSnapshot(snapshotStringData, ({objectId, snapshot: serializedSnapshot}) => { |
| let snapshot = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot); |
| InspectorTest.expectThat(snapshot.totalSize > 1024, "Snapshot size should be greater than 1kb."); |
| InspectorTest.expectThat(snapshot.totalObjectCount > 100, "Snapshot object count should be greater than 100."); |
| InspectorTest.expectThat(snapshot.categories.get("Window"), "Snapshot should include a class category for 'Window'."); |
| snapshot.instancesWithClassName("Window", (windows) => { |
| InspectorTest.expectThat(windows.length > 0, "Snapshot should include at least one 'Window' instance."); |
| resolve(); |
| }); |
| }); |
| }); |
| } |
| }); |
| |
| suite.runTestCasesAndFinish(); |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Test for the Heap.snapshot command.</p> |
| </body> |
| </html> |