Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / heap-profiler / heap-objects-tracking.html
blob0bfe268b02fc90aa0202ee34371ed200fd72ab51
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <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);
22 runTest();
25 function test()
27 var lastSeenObjectIdEventCount = 0;
28 var heapStatsUpdateEventCount = 0;
29 function trackingStarted()
31 InspectorTest.log("SUCCESS: tracking started");
34 function trackingStopped()
36 InspectorTest.log("Number of heapStatsUpdate events >= numbrt of lastSeenObjectId events: " + (heapStatsUpdateEventCount >= lastSeenObjectIdEventCount));
37 InspectorTest.log("At least 2 lastSeenObjectId arrived: " + (lastSeenObjectIdEventCount >= 2));
38 InspectorTest.log("SUCCESS: tracking stopped");
39 InspectorTest.completeTest();
42 var fragments = [];
43 InspectorTest.eventHandler["HeapProfiler.lastSeenObjectId"] = function(messageObject)
45 if (++lastSeenObjectIdEventCount <= 2) {
46 var params = messageObject["params"];
47 InspectorTest.log("HeapProfiler.lastSeenObjectId has params: " + !!params);
48 InspectorTest.log("HeapProfiler.lastSeenObjectId has params.lastSeenObjectId: " + !!params.lastSeenObjectId);
49 InspectorTest.log("HeapProfiler.lastSeenObjectId has timestamp: " + !!params.timestamp);
50 InspectorTest.log("A heap stats fragment did arrive before HeapProfiler.lastSeenObjectId: " + !!fragments.length);
51 InspectorTest.log("");
53 if (lastSeenObjectIdEventCount == 2) {
54 // Wait for two updates and then stop tracing.
55 InspectorTest.sendCommand("HeapProfiler.stopTrackingHeapObjects", {}, trackingStopped);
59 InspectorTest.eventHandler["HeapProfiler.heapStatsUpdate"] = function(messageObject)
61 ++heapStatsUpdateEventCount
62 var params = messageObject["params"];
63 if (heapStatsUpdateEventCount <= 2)
64 InspectorTest.log("HeapProfiler.heapStatsUpdate has params: " + !!params);
65 var statsUpdate = params.statsUpdate;
66 if (heapStatsUpdateEventCount <= 2) {
67 InspectorTest.log("HeapProfiler.heapStatsUpdate has statsUpdate: " + !!statsUpdate);
68 InspectorTest.log("statsUpdate length is not zero: " + !!statsUpdate.length);
69 InspectorTest.log("statsUpdate length is a multiple of three: " + !(statsUpdate.length % 3));
70 InspectorTest.log("statsUpdate: first fragmentIndex in first update: " + statsUpdate[0]);
71 InspectorTest.log("statsUpdate: total count of objects is not zero: " + !!statsUpdate[1]);
72 InspectorTest.log("statsUpdate: total size of objects is not zero: " + !!statsUpdate[2]);
73 InspectorTest.log("");
75 fragments.push(statsUpdate);
78 InspectorTest.sendCommand("HeapProfiler.startTrackingHeapObjects", {}, trackingStarted);
79 //@ sourceURL=heap-objects-tracking.html
81 </script>
82 </head>
83 <body onload="setupIntervalAndRunTest()">
84 <p>Test that heap tracking actually reports data fragments.</p>
85 </body>
86 </html>