Index: LayoutTests/http/tests/inspector-protocol/tracing-test.js |
diff --git a/LayoutTests/http/tests/inspector-protocol/tracing-test.js b/LayoutTests/http/tests/inspector-protocol/tracing-test.js |
index c814263d5aecc227a3f1a0c76fd0e5daa5803ae3..afe431621c4b1accc37aefc6b13d482d038106e0 100644 |
--- a/LayoutTests/http/tests/inspector-protocol/tracing-test.js |
+++ b/LayoutTests/http/tests/inspector-protocol/tracing-test.js |
@@ -43,6 +43,57 @@ InspectorTest.stopTracing = function(callback) |
} |
} |
+InspectorTest.stopTracingAndSaveAsStream = function(callback) |
+{ |
+ InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete; |
+ InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected; |
+ InspectorTest.sendCommand("Tracing.end", { returnAsStream: true }); |
+ |
+ function dataCollected(reply) |
+ { |
+ InspectorTest.log("FAIL: dataCollected event should not be fired when returning trace as stream."); |
+ |
+ } |
+ |
+ function tracingComplete(event) |
+ { |
+ InspectorTest.log("Tracing complete"); |
+ InspectorTest.eventHandler["Tracing.tracingComplete"] = null; |
+ InspectorTest.eventHandler["Tracing.dataCollected"] = null; |
+ callback(event.params.streamId); |
+ } |
+} |
+ |
+InspectorTest.retrieveStream = function(streamId, offset, chunkSize, callback) |
+{ |
+ var result = ""; |
+ var had_eof = false; |
+ |
+ var readArguments = { id: streamId }; |
+ if (typeof chunkSize === "number") |
+ readArguments.size = chunkSize; |
+ var firstReadArguments = JSON.parse(JSON.stringify(readArguments)); |
+ if (typeof offset === "number") |
+ firstReadArguments.offset = 0; |
+ InspectorTest.sendCommandOrDie("IO.read", firstReadArguments, onChunkRead); |
+ // Assure multiple in-lfight reads are fine (also, save on latencies). |
+ InspectorTest.sendCommandOrDie("IO.read", readArguments, onChunkRead); |
+ |
+ function onChunkRead(response) |
+ { |
+ if (had_eof) |
+ return; |
+ result += response.data; |
+ if (response.eof) { |
+ // Ignore stray callbacks from proactive read requests. |
+ had_eof = true; |
+ callback(result); |
+ return; |
+ } |
+ InspectorTest.sendCommandOrDie("IO.read", readArguments, onChunkRead); |
+ } |
+} |
+ |
InspectorTest.findEvent = function(name, ph, condition) |
{ |
for (var i = 0; i < InspectorTest.devtoolsEvents.length; i++) { |
@@ -99,4 +150,3 @@ InspectorTest.didInvokePageFunctionAsync = function(callId, value) |
} |
} |
- |