| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 if (response.eof) { | 103 if (response.eof) { |
| 104 // Ignore stray callbacks from proactive read requests. | 104 // Ignore stray callbacks from proactive read requests. |
| 105 had_eof = true; | 105 had_eof = true; |
| 106 callback(result); | 106 callback(result); |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 InspectorTest.sendCommandOrDie("IO.read", readArguments, onChunkRead); | 109 InspectorTest.sendCommandOrDie("IO.read", readArguments, onChunkRead); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 InspectorTest.findEvents = function(name, ph, condition) |
| 114 { |
| 115 return InspectorTest.devtoolsEvents.filter(e => e.name === name && e.ph ===
ph && (!condition || condition(e))); |
| 116 } |
| 117 |
| 113 InspectorTest.findEvent = function(name, ph, condition) | 118 InspectorTest.findEvent = function(name, ph, condition) |
| 114 { | 119 { |
| 115 for (var i = 0; i < InspectorTest.devtoolsEvents.length; i++) { | 120 var events = InspectorTest.findEvents(name, ph, condition); |
| 116 var e = InspectorTest.devtoolsEvents[i]; | 121 if (events.length) |
| 117 if (e.name === name && e.ph === ph && (!condition || condition(e))) | 122 return events[0]; |
| 118 return e; | |
| 119 } | |
| 120 throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in " + JS
ON.stringify(InspectorTest.devtoolsEvents, null, 2)); | 123 throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in " + JS
ON.stringify(InspectorTest.devtoolsEvents, null, 2)); |
| 121 } | 124 } |
| 122 | 125 |
| 123 InspectorTest.invokeAsyncWithTracing = function(functionName, callback) | 126 InspectorTest.invokeAsyncWithTracing = function(functionName, callback) |
| 124 { | 127 { |
| 125 InspectorTest.startTracing(onStart); | 128 InspectorTest.startTracing(onStart); |
| 126 | 129 |
| 127 function onStart() | 130 function onStart() |
| 128 { | 131 { |
| 129 InspectorTest.evaluateInPageAsync(functionName + "()").then((data) => In
spectorTest.stopTracing((devtoolsEvents) => callback(devtoolsEvents, data))); | 132 InspectorTest.evaluateInPageAsync(functionName + "()").then((data) => In
spectorTest.stopTracing((devtoolsEvents) => callback(devtoolsEvents, data))); |
| 130 } | 133 } |
| 131 } | 134 } |
| 132 | 135 |
| 133 } | 136 } |
| OLD | NEW |