OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var evalCallbackCallId = 3; | 5 var evalCallbackCallId = 3; |
6 | 6 |
7 initialize_tracingHarness = function() | 7 initialize_tracingHarness = function() |
8 { | 8 { |
9 | 9 |
10 InspectorTest.startTracing = function(callback) | 10 InspectorTest.startTracing = function(callback) |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 function tracingComplete(event) | 37 function tracingComplete(event) |
38 { | 38 { |
39 InspectorTest.log("Tracing complete"); | 39 InspectorTest.log("Tracing complete"); |
40 InspectorTest.eventHandler["Tracing.tracingComplete"] = null; | 40 InspectorTest.eventHandler["Tracing.tracingComplete"] = null; |
41 InspectorTest.eventHandler["Tracing.dataCollected"] = null; | 41 InspectorTest.eventHandler["Tracing.dataCollected"] = null; |
42 callback(InspectorTest.devtoolsEvents); | 42 callback(InspectorTest.devtoolsEvents); |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
| 46 InspectorTest.stopTracingAndSaveAsStream = function(callback) |
| 47 { |
| 48 InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete; |
| 49 InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected; |
| 50 InspectorTest.sendCommand("Tracing.end", { returnAsStream: true }); |
| 51 |
| 52 function dataCollected(reply) |
| 53 { |
| 54 InspectorTest.log("FAIL: dataCollected event should not be fired when re
turning trace as stream."); |
| 55 |
| 56 } |
| 57 |
| 58 function tracingComplete(event) |
| 59 { |
| 60 InspectorTest.log("Tracing complete"); |
| 61 InspectorTest.eventHandler["Tracing.tracingComplete"] = null; |
| 62 InspectorTest.eventHandler["Tracing.dataCollected"] = null; |
| 63 callback(event.params.streamId); |
| 64 } |
| 65 } |
| 66 |
| 67 InspectorTest.retrieveStream = function(streamId, offset, chunkSize, callback) |
| 68 { |
| 69 var result = ""; |
| 70 var had_eof = false; |
| 71 |
| 72 var readArguments = { id: streamId }; |
| 73 if (typeof chunkSize === "number") |
| 74 readArguments.size = chunkSize; |
| 75 var firstReadArguments = JSON.parse(JSON.stringify(readArguments)); |
| 76 if (typeof offset === "number") |
| 77 firstReadArguments.offset = 0; |
| 78 InspectorTest.sendCommandOrDie("IO.read", firstReadArguments, onChunkRead); |
| 79 // Assure multiple in-lfight reads are fine (also, save on latencies). |
| 80 InspectorTest.sendCommandOrDie("IO.read", readArguments, onChunkRead); |
| 81 |
| 82 function onChunkRead(response) |
| 83 { |
| 84 if (had_eof) |
| 85 return; |
| 86 result += response.data; |
| 87 if (response.eof) { |
| 88 // Ignore stray callbacks from proactive read requests. |
| 89 had_eof = true; |
| 90 callback(result); |
| 91 return; |
| 92 } |
| 93 InspectorTest.sendCommandOrDie("IO.read", readArguments, onChunkRead); |
| 94 } |
| 95 } |
| 96 |
46 InspectorTest.findEvent = function(name, ph, condition) | 97 InspectorTest.findEvent = function(name, ph, condition) |
47 { | 98 { |
48 for (var i = 0; i < InspectorTest.devtoolsEvents.length; i++) { | 99 for (var i = 0; i < InspectorTest.devtoolsEvents.length; i++) { |
49 var e = InspectorTest.devtoolsEvents[i]; | 100 var e = InspectorTest.devtoolsEvents[i]; |
50 if (e.name === name && e.ph === ph && (!condition || condition(e))) | 101 if (e.name === name && e.ph === ph && (!condition || condition(e))) |
51 return e; | 102 return e; |
52 } | 103 } |
53 throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in " + JS
ON.stringify(InspectorTest.devtoolsEvents, null, 2)); | 104 throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in " + JS
ON.stringify(InspectorTest.devtoolsEvents, null, 2)); |
54 } | 105 } |
55 | 106 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 143 |
93 if (!callback) { | 144 if (!callback) { |
94 InspectorTest.addResult("Missing callback for async eval " + callId + ",
perhaps callback invoked twice?"); | 145 InspectorTest.addResult("Missing callback for async eval " + callId + ",
perhaps callback invoked twice?"); |
95 return; | 146 return; |
96 } | 147 } |
97 delete InspectorTest._pendingEvalRequests[callId]; | 148 delete InspectorTest._pendingEvalRequests[callId]; |
98 callback(value); | 149 callback(value); |
99 } | 150 } |
100 | 151 |
101 } | 152 } |
102 | |
OLD | NEW |