OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
yurys
2014/07/21 06:32:22
This file should be under .../timeline/tracing/
loislo
2014/07/21 07:28:48
there is no timeline tracing tests and correspondi
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 var evalCallbackCallId = 3; | |
6 | |
7 initialize_tracingHarness = function() | |
8 { | |
9 | |
10 InspectorTest.startTracing = function(callback) | |
11 { | |
12 InspectorTest.sendCommand("Tracing.start", { "categories": "-*,disabled-by-d efault-devtools.timeline", "type": "", "options": "" }, onStart); | |
13 | |
14 function onStart(response) | |
15 { | |
16 InspectorTest.log("Recording started"); | |
17 callback(); | |
18 } | |
19 } | |
20 | |
21 InspectorTest.stopTracing = function(callback) | |
22 { | |
23 InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete; | |
24 InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected; | |
25 InspectorTest.sendCommand("Tracing.end", { }, onStop); | |
26 | |
27 InspectorTest.devtoolsEvents = []; | |
28 function dataCollected(reply) | |
29 { | |
30 var allEvents = reply.params.value; | |
31 InspectorTest.devtoolsEvents = InspectorTest.devtoolsEvents.concat(allEv ents.filter(function(e) | |
32 { | |
33 return e.cat === "disabled-by-default-devtools.timeline"; | |
34 })); | |
35 } | |
36 | |
37 function tracingComplete(event) | |
38 { | |
39 InspectorTest.log("Tracing complete"); | |
40 InspectorTest.eventHandler["Tracing.tracingComplete"] = null; | |
41 InspectorTest.eventHandler["Tracing.dataCollected"] = null; | |
42 callback(InspectorTest.devtoolsEvents); | |
43 } | |
44 | |
45 function onStop(response) | |
46 { | |
47 InspectorTest.log("Recording stopped"); | |
48 } | |
49 } | |
50 | |
51 InspectorTest.findEvent = function(name, ph, condition) | |
52 { | |
53 for (var i = 0; i < InspectorTest.devtoolsEvents.length; i++) { | |
54 var e = InspectorTest.devtoolsEvents[i]; | |
55 if (e.name === name && e.ph === ph && (!condition || condition(e))) | |
56 return e; | |
57 } | |
58 throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in " + JS ON.stringify(InspectorTest.devtoolsEvents, null, 2)); | |
59 } | |
60 | |
61 InspectorTest.invokeAsyncWithTracing = function(functionName, callback) | |
62 { | |
63 InspectorTest.startTracing(onStart); | |
64 | |
65 function onStart() | |
66 { | |
67 InspectorTest.invokePageFunctionAsync(functionName, done); | |
68 } | |
69 | |
70 function done() | |
71 { | |
72 InspectorTest.stopTracing(callback); | |
73 } | |
74 } | |
75 | |
76 var lastEvalId = 0; | |
yurys
2014/07/21 06:32:22
pendingEvalRequests._lastEvalId
loislo
2014/07/21 07:28:48
Done.
| |
77 var pendingEvalRequests = {}; | |
yurys
2014/07/21 06:32:22
InspectorTest._pendingEvalRequests
loislo
2014/07/21 07:28:48
Done.
| |
78 | |
79 InspectorTest.invokePageFunctionAsync = function(functionName, callback) | |
80 { | |
81 var id = ++lastEvalId; | |
82 pendingEvalRequests[id] = callback; | |
83 var asyncEvalWrapper = function(callId, functionName) | |
84 { | |
85 function evalCallback(result) | |
86 { | |
87 testRunner.evaluateInWebInspector(evalCallbackCallId, "InspectorTest .didInvokePageFunctionAsync(" + callId + ", " + JSON.stringify(result) + ");"); | |
yurys
2014/07/21 06:32:22
evaluateInFrontend(...)
loislo
2014/07/21 07:28:48
Done.
| |
88 } | |
89 eval(functionName + "(" + evalCallback + ")"); | |
90 } | |
91 InspectorTest.evaluateInPage("(" + asyncEvalWrapper.toString() + ")(" + id + ", unescape('" + escape(functionName) + "'))", function() { }); | |
92 } | |
93 | |
94 InspectorTest.didInvokePageFunctionAsync = function(callId, value) | |
95 { | |
96 var callback = pendingEvalRequests[callId]; | |
97 | |
98 if (!callback) { | |
99 InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?"); | |
100 return; | |
101 } | |
102 delete pendingEvalRequests[callId]; | |
103 callback(value); | |
104 } | |
105 | |
106 } | |
107 | |
OLD | NEW |