3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
6 if (window.testRunner) {
7 testRunner.dumpAsText();
8 testRunner.waitUntilDone();
11 function junkGenerator()
13 var junkArray = new Array(1000);
14 for (var i = 0; i < junkArray.length; ++i)
15 junkArray[i] = "42 " + i;
16 window.junkArray = junkArray;
19 function setupIntervalAndRunTest()
21 setInterval(junkGenerator, 0);
27 InspectorTest.importScript("../../../../inspector-protocol/heap-profiler/resources/heap-snapshot-common.js");
29 var gotLastSeenObjectIdEvent = false;
30 var gotHeapStatsUpdateEvent = false;
31 var gotHeapProfilerHeader = false;
32 function trackingStarted()
34 InspectorTest.log("SUCCESS: tracking started");
37 function trackingStopped()
39 if (gotHeapStatsUpdateEvent)
40 InspectorTest.log("SUCCESS: heapStatsUpdate arrived");
41 if (gotLastSeenObjectIdEvent)
42 InspectorTest.log("SUCCESS: lastSeenObjectId arrived");
43 if (gotHeapProfilerHeader)
44 InspectorTest.log("SUCCESS: addProfileHeader arrived");
45 InspectorTest.log("SUCCESS: tracking stopped");
46 InspectorTest.completeTest();
50 InspectorTest.eventHandler["HeapProfiler.lastSeenObjectId"] = function(messageObject)
53 var params = messageObject["params"];
54 InspectorTest.assert(params, "no params found in event HeapProfiler.lastSeenObjectId");
55 InspectorTest.assert(params.lastSeenObjectId, "lastSeenObjectId is missing in event HeapProfiler.lastSeenObjectId");
56 InspectorTest.assert(params.timestamp, "timestamp is missing in event HeapProfiler.lastSeenObjectId");
57 InspectorTest.assert(fragments.length, "a heap stats fragment didn't arrive before HeapProfiler.lastSeenObjectId");
58 InspectorTest.sendCommand("HeapProfiler.stopTrackingHeapObjects", {}, trackingStopped);
59 gotLastSeenObjectIdEvent = true;
62 InspectorTest.eventHandler["HeapProfiler.heapStatsUpdate"] = function(messageObject)
64 var params = messageObject["params"];
65 InspectorTest.assert(params, "no params found in event HeapProfiler.heapStatsUpdate");
66 var statsUpdate = params.statsUpdate;
67 InspectorTest.assert(statsUpdate, "statsUpdata is missing in event HeapProfiler.heapStatsUpdate");
68 InspectorTest.assert(statsUpdate.length, "statsUpdate should have non zero length");
69 InspectorTest.assert(!(statsUpdate.length % 3), "statsUpdate length must be a multiple of three");
70 InspectorTest.assert(!(statsUpdate.length % 3), "statsUpdate length must be a multiple of three");
71 InspectorTest.assert(!statsUpdate[0], "statsUpdate: first fragmentIndex in first update has to be zero");
72 InspectorTest.assert(statsUpdate[1], "statsUpdate: total count of objects should be not zero");
73 InspectorTest.assert(statsUpdate[2], "statsUpdate: total size of objects should be not zero");
74 fragments.push(statsUpdate);
75 gotHeapStatsUpdateEvent = true;
78 InspectorTest.eventHandler["HeapProfiler.addProfileHeader"] = function(messageObject)
80 gotHeapProfilerHeader = true;
83 InspectorTest.sendCommand("HeapProfiler.startTrackingHeapObjects", {}, trackingStarted);
84 //@ sourceURL=heap-objects-tracking.html
88 <body onload="setupIntervalAndRunTest()">
89 <p>Test that heap tracking actually reports data fragments.</p>