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

Unified Diff: LayoutTests/http/tests/inspector-protocol/tracing-test.js

Issue 1301373004: DevTools: add protocol test for retrieving traces as stream (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/timeline/fetch-as-stream.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..230a0128be2e65d525be84614b04a88c0e671465 100644
--- a/LayoutTests/http/tests/inspector-protocol/tracing-test.js
+++ b/LayoutTests/http/tests/inspector-protocol/tracing-test.js
@@ -9,7 +9,23 @@ initialize_tracingHarness = function()
InspectorTest.startTracing = function(callback)
{
- InspectorTest.sendCommand("Tracing.start", { "categories": "-*,disabled-by-default-devtools.timeline,devtools.timeline", "type": "", "options": "" }, onStart);
+ InspectorTest.startTracingWithArguments({ "categories": "-*,disabled-by-default-devtools.timeline,devtools.timeline", "type": "", "options": "" }, callback);
+}
+
+InspectorTest.startTracingAndSaveAsStream = function(callback)
+{
+ var args = {
+ "categories": "-*,disabled-by-default-devtools.timeline,devtools.timeline",
+ "type": "",
+ "options": "",
+ "transferMode": "ReturnAsStream"
+ };
+ InspectorTest.startTracingWithArguments(args, callback);
+}
+
+InspectorTest.startTracingWithArguments = function(args, callback)
+{
+ InspectorTest.sendCommand("Tracing.start", args, onStart);
function onStart(response)
{
@@ -43,6 +59,57 @@ InspectorTest.stopTracing = function(callback)
}
}
+InspectorTest.stopTracingAndReturnStream = function(callback)
+{
+ InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete;
+ InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected;
+ InspectorTest.sendCommand("Tracing.end");
+
+ 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.stream);
+ }
+}
+
+InspectorTest.retrieveStream = function(streamHandle, offset, chunkSize, callback)
+{
+ var result = "";
+ var had_eof = false;
+
+ var readArguments = { handle: streamHandle };
+ 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 +166,3 @@ InspectorTest.didInvokePageFunctionAsync = function(callId, value)
}
}
-
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/timeline/fetch-as-stream.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698