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

Side by Side 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, 3 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
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/timeline/fetch-as-stream.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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)
11 { 11 {
12 InspectorTest.sendCommand("Tracing.start", { "categories": "-*,disabled-by-d efault-devtools.timeline,devtools.timeline", "type": "", "options": "" }, onStar t); 12 InspectorTest.startTracingWithArguments({ "categories": "-*,disabled-by-defa ult-devtools.timeline,devtools.timeline", "type": "", "options": "" }, callback) ;
13 }
14
15 InspectorTest.startTracingAndSaveAsStream = function(callback)
16 {
17 var args = {
18 "categories": "-*,disabled-by-default-devtools.timeline,devtools.timelin e",
19 "type": "",
20 "options": "",
21 "transferMode": "ReturnAsStream"
22 };
23 InspectorTest.startTracingWithArguments(args, callback);
24 }
25
26 InspectorTest.startTracingWithArguments = function(args, callback)
27 {
28 InspectorTest.sendCommand("Tracing.start", args, onStart);
13 29
14 function onStart(response) 30 function onStart(response)
15 { 31 {
16 InspectorTest.log("Recording started"); 32 InspectorTest.log("Recording started");
17 callback(); 33 callback();
18 } 34 }
19 } 35 }
20 36
21 InspectorTest.stopTracing = function(callback) 37 InspectorTest.stopTracing = function(callback)
22 { 38 {
(...skipping 13 matching lines...) Expand all
36 52
37 function tracingComplete(event) 53 function tracingComplete(event)
38 { 54 {
39 InspectorTest.log("Tracing complete"); 55 InspectorTest.log("Tracing complete");
40 InspectorTest.eventHandler["Tracing.tracingComplete"] = null; 56 InspectorTest.eventHandler["Tracing.tracingComplete"] = null;
41 InspectorTest.eventHandler["Tracing.dataCollected"] = null; 57 InspectorTest.eventHandler["Tracing.dataCollected"] = null;
42 callback(InspectorTest.devtoolsEvents); 58 callback(InspectorTest.devtoolsEvents);
43 } 59 }
44 } 60 }
45 61
62 InspectorTest.stopTracingAndReturnStream = function(callback)
63 {
64 InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete;
65 InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected;
66 InspectorTest.sendCommand("Tracing.end");
67
68 function dataCollected(reply)
69 {
70 InspectorTest.log("FAIL: dataCollected event should not be fired when re turning trace as stream.");
71
72 }
73
74 function tracingComplete(event)
75 {
76 InspectorTest.log("Tracing complete");
77 InspectorTest.eventHandler["Tracing.tracingComplete"] = null;
78 InspectorTest.eventHandler["Tracing.dataCollected"] = null;
79 callback(event.params.stream);
80 }
81 }
82
83 InspectorTest.retrieveStream = function(streamHandle, offset, chunkSize, callbac k)
84 {
85 var result = "";
86 var had_eof = false;
87
88 var readArguments = { handle: streamHandle };
89 if (typeof chunkSize === "number")
90 readArguments.size = chunkSize;
91 var firstReadArguments = JSON.parse(JSON.stringify(readArguments));
92 if (typeof offset === "number")
93 firstReadArguments.offset = 0;
94 InspectorTest.sendCommandOrDie("IO.read", firstReadArguments, onChunkRead);
95 // Assure multiple in-lfight reads are fine (also, save on latencies).
96 InspectorTest.sendCommandOrDie("IO.read", readArguments, onChunkRead);
97
98 function onChunkRead(response)
99 {
100 if (had_eof)
101 return;
102 result += response.data;
103 if (response.eof) {
104 // Ignore stray callbacks from proactive read requests.
105 had_eof = true;
106 callback(result);
107 return;
108 }
109 InspectorTest.sendCommandOrDie("IO.read", readArguments, onChunkRead);
110 }
111 }
112
46 InspectorTest.findEvent = function(name, ph, condition) 113 InspectorTest.findEvent = function(name, ph, condition)
47 { 114 {
48 for (var i = 0; i < InspectorTest.devtoolsEvents.length; i++) { 115 for (var i = 0; i < InspectorTest.devtoolsEvents.length; i++) {
49 var e = InspectorTest.devtoolsEvents[i]; 116 var e = InspectorTest.devtoolsEvents[i];
50 if (e.name === name && e.ph === ph && (!condition || condition(e))) 117 if (e.name === name && e.ph === ph && (!condition || condition(e)))
51 return e; 118 return e;
52 } 119 }
53 throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in " + JS ON.stringify(InspectorTest.devtoolsEvents, null, 2)); 120 throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in " + JS ON.stringify(InspectorTest.devtoolsEvents, null, 2));
54 } 121 }
55 122
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 159
93 if (!callback) { 160 if (!callback) {
94 InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?"); 161 InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?");
95 return; 162 return;
96 } 163 }
97 delete InspectorTest._pendingEvalRequests[callId]; 164 delete InspectorTest._pendingEvalRequests[callId];
98 callback(value); 165 callback(value);
99 } 166 }
100 167
101 } 168 }
102
OLDNEW
« 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