Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: LayoutTests/inspector-protocol/heap-profiler/heap-objects-tracking.html

Issue 1021543002: DevTools: remove InspectorTest.assert from inspector-protocol tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script> 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script>
4 <script> 4 <script>
5 5
6 if (window.testRunner) { 6 if (window.testRunner) {
7 testRunner.dumpAsText(); 7 testRunner.dumpAsText();
8 testRunner.waitUntilDone(); 8 testRunner.waitUntilDone();
9 } 9 }
10 10
11 function junkGenerator() 11 function junkGenerator()
12 { 12 {
13 var junkArray = new Array(1000); 13 var junkArray = new Array(1000);
14 for (var i = 0; i < junkArray.length; ++i) 14 for (var i = 0; i < junkArray.length; ++i)
15 junkArray[i] = "42 " + i; 15 junkArray[i] = "42 " + i;
16 window.junkArray = junkArray; 16 window.junkArray = junkArray;
17 } 17 }
18 18
19 function setupIntervalAndRunTest() 19 function setupIntervalAndRunTest()
20 { 20 {
21 setInterval(junkGenerator, 0); 21 setInterval(junkGenerator, 0);
22 runTest(); 22 runTest();
23 } 23 }
24 24
25 function test() 25 function test()
26 { 26 {
27 InspectorTest.importScript("../../../../inspector-protocol/heap-profiler/res ources/heap-snapshot-common.js"); 27 InspectorTest.importScript("../../../../inspector-protocol/heap-profiler/res ources/heap-snapshot-common.js");
28 28
29 var gotLastSeenObjectIdEvent = false; 29 var lastSeenObjectIdEventCount = 0;
30 var gotHeapStatsUpdateEvent = false; 30 var heapStatsUpdateEventCount = 0;
31 function trackingStarted() 31 function trackingStarted()
32 { 32 {
33 InspectorTest.log("SUCCESS: tracking started"); 33 InspectorTest.log("SUCCESS: tracking started");
34 } 34 }
35 35
36 function trackingStopped() 36 function trackingStopped()
37 { 37 {
38 if (gotHeapStatsUpdateEvent) 38 InspectorTest.log("Number of heapStatsUpdate events >= numbrt of lastSee nObjectId events: " + (heapStatsUpdateEventCount >= lastSeenObjectIdEventCount)) ;
39 InspectorTest.log("SUCCESS: heapStatsUpdate arrived"); 39 InspectorTest.log("At least 2 lastSeenObjectId arrived: " + (lastSeenObj ectIdEventCount >= 2));
40 if (gotLastSeenObjectIdEvent)
41 InspectorTest.log("SUCCESS: lastSeenObjectId arrived");
42 InspectorTest.log("SUCCESS: tracking stopped"); 40 InspectorTest.log("SUCCESS: tracking stopped");
43 InspectorTest.completeTest(); 41 InspectorTest.completeTest();
44 } 42 }
45 43
46 var fragments = []; 44 var fragments = [];
47 InspectorTest.eventHandler["HeapProfiler.lastSeenObjectId"] = function(messa geObject) 45 InspectorTest.eventHandler["HeapProfiler.lastSeenObjectId"] = function(messa geObject)
48 { 46 {
49 47 if (++lastSeenObjectIdEventCount <= 2) {
50 var params = messageObject["params"]; 48 var params = messageObject["params"];
51 InspectorTest.assert(params, "no params found in event HeapProfiler.last SeenObjectId"); 49 InspectorTest.log("HeapProfiler.lastSeenObjectId has params: " + !!p arams);
52 InspectorTest.assert(params.lastSeenObjectId, "lastSeenObjectId is missi ng in event HeapProfiler.lastSeenObjectId"); 50 InspectorTest.log("HeapProfiler.lastSeenObjectId has params.lastSeen ObjectId: " + !!params.lastSeenObjectId);
53 InspectorTest.assert(params.timestamp, "timestamp is missing in event He apProfiler.lastSeenObjectId"); 51 InspectorTest.log("HeapProfiler.lastSeenObjectId has timestamp: " + !!params.timestamp);
54 InspectorTest.assert(fragments.length, "a heap stats fragment didn't arr ive before HeapProfiler.lastSeenObjectId"); 52 InspectorTest.log("A heap stats fragment did arrive before HeapProfi ler.lastSeenObjectId: " + !!fragments.length);
55 InspectorTest.sendCommand("HeapProfiler.stopTrackingHeapObjects", {}, tr ackingStopped); 53 InspectorTest.log("");
56 gotLastSeenObjectIdEvent = true; 54 }
55 if (lastSeenObjectIdEventCount == 2) {
56 // Wait for two updates and then stop tracing.
57 InspectorTest.sendCommand("HeapProfiler.stopTrackingHeapObjects", { }, trackingStopped);
58 }
57 } 59 }
58 60
59 InspectorTest.eventHandler["HeapProfiler.heapStatsUpdate"] = function(messag eObject) 61 InspectorTest.eventHandler["HeapProfiler.heapStatsUpdate"] = function(messag eObject)
60 { 62 {
61 var params = messageObject["params"]; 63 var params = messageObject["params"];
62 InspectorTest.assert(params, "no params found in event HeapProfiler.heap StatsUpdate"); 64 InspectorTest.log("HeapProfiler.heapStatsUpdate has params: " + !!param s);
63 var statsUpdate = params.statsUpdate; 65 var statsUpdate = params.statsUpdate;
64 InspectorTest.assert(statsUpdate, "statsUpdata is missing in event HeapP rofiler.heapStatsUpdate"); 66 if (++heapStatsUpdateEventCount < 2) {
65 InspectorTest.assert(statsUpdate.length, "statsUpdate should have non ze ro length"); 67 InspectorTest.log("HeapProfiler.heapStatsUpdate has statsUpdate: " + !!statsUpdate);
66 InspectorTest.assert(!(statsUpdate.length % 3), "statsUpdate length must be a multiple of three"); 68 InspectorTest.log("statsUpdate length is not zero: " + !!statsUpdate .length);
67 InspectorTest.assert(!(statsUpdate.length % 3), "statsUpdate length must be a multiple of three"); 69 InspectorTest.log("statsUpdate length is a multiple of three: " + !( statsUpdate.length % 3));
68 InspectorTest.assert(!statsUpdate[0], "statsUpdate: first fragmentIndex in first update has to be zero"); 70 InspectorTest.log("statsUpdate: first fragmentIndex in first update: " + statsUpdate[0]);
69 InspectorTest.assert(statsUpdate[1], "statsUpdate: total count of object s should be not zero"); 71 InspectorTest.log("statsUpdate: total count of objects is not zero: " + !!statsUpdate[1]);
70 InspectorTest.assert(statsUpdate[2], "statsUpdate: total size of objects should be not zero"); 72 InspectorTest.log("statsUpdate: total size of objects is not zero: " + !!statsUpdate[2]);
71 fragments.push(statsUpdate); 73 InspectorTest.log("");
72 gotHeapStatsUpdateEvent = true; 74 }
75 fragments.push(statsUpdate);
73 } 76 }
74 77
75 InspectorTest.sendCommand("HeapProfiler.startTrackingHeapObjects", {}, track ingStarted); 78 InspectorTest.sendCommand("HeapProfiler.startTrackingHeapObjects", {}, track ingStarted);
76 //@ sourceURL=heap-objects-tracking.html 79 //@ sourceURL=heap-objects-tracking.html
77 } 80 }
78 </script> 81 </script>
79 </head> 82 </head>
80 <body onload="setupIntervalAndRunTest()"> 83 <body onload="setupIntervalAndRunTest()">
81 <p>Test that heap tracking actually reports data fragments.</p> 84 <p>Test that heap tracking actually reports data fragments.</p>
82 </body> 85 </body>
83 </html> 86 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698