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

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/resources/tracing-test.js

Issue 2942573003: [DevTools] New harness for inspector-protocol layout tests (Closed)
Patch Set: unified Created 3 years, 6 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
Index: third_party/WebKit/LayoutTests/inspector-protocol/resources/tracing-test.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/tracing-test.js b/third_party/WebKit/LayoutTests/inspector-protocol/resources/tracing-test.js
similarity index 72%
rename from third_party/WebKit/LayoutTests/http/tests/inspector-protocol/tracing-test.js
rename to third_party/WebKit/LayoutTests/inspector-protocol/resources/tracing-test.js
index 0c545b56164c1f4c2583754af0934c562e8b66d8..dcbce009d6ce615ce5e03a1250c8e71913d795a0 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/tracing-test.js
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/resources/tracing-test.js
@@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var evalCallbackCallId = 3;
-
-initialize_tracingHarness = function()
+(function initialize_tracingHarness(session)
{
InspectorTest.startTracing = function(callback)
@@ -25,7 +23,7 @@ InspectorTest.startTracingAndSaveAsStream = function(callback)
InspectorTest.startTracingWithArguments = function(args, callback)
{
- InspectorTest.sendCommand("Tracing.start", args, onStart);
+ session.Protocol.Tracing.start(args).then(onStart);
function onStart(response)
{
@@ -36,9 +34,9 @@ InspectorTest.startTracingWithArguments = function(args, callback)
InspectorTest.stopTracing = function(callback)
{
- InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete;
- InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected;
- InspectorTest.sendCommand("Tracing.end", { });
+ session.Protocol.Tracing.onTracingComplete(tracingComplete);
+ session.Protocol.Tracing.onDataCollected(dataCollected);
+ session.Protocol.Tracing.end();
InspectorTest.devtoolsEvents = [];
function dataCollected(reply)
@@ -53,17 +51,17 @@ InspectorTest.stopTracing = function(callback)
function tracingComplete(event)
{
InspectorTest.log("Tracing complete");
- InspectorTest.eventHandler["Tracing.tracingComplete"] = null;
- InspectorTest.eventHandler["Tracing.dataCollected"] = null;
+ session.Protocol.Tracing.offTracingComplete(tracingComplete);
+ session.Protocol.Tracing.offDataCollected(dataCollected);
callback(InspectorTest.devtoolsEvents);
}
}
InspectorTest.stopTracingAndReturnStream = function(callback)
{
- InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete;
- InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected;
- InspectorTest.sendCommand("Tracing.end");
+ session.Protocol.Tracing.onTracingComplete(tracingComplete);
+ session.Protocol.Tracing.onDataCollected(dataCollected);
+ session.Protocol.Tracing.end();
function dataCollected(reply)
{
@@ -74,8 +72,8 @@ InspectorTest.stopTracingAndReturnStream = function(callback)
function tracingComplete(event)
{
InspectorTest.log("Tracing complete");
- InspectorTest.eventHandler["Tracing.tracingComplete"] = null;
- InspectorTest.eventHandler["Tracing.dataCollected"] = null;
+ session.Protocol.Tracing.offTracingComplete(tracingComplete);
+ session.Protocol.Tracing.offDataCollected(dataCollected);
callback(event.params.stream);
}
}
@@ -91,9 +89,9 @@ InspectorTest.retrieveStream = function(streamHandle, offset, chunkSize, callbac
var firstReadArguments = JSON.parse(JSON.stringify(readArguments));
if (typeof offset === "number")
firstReadArguments.offset = 0;
- InspectorTest.sendCommandOrDie("IO.read", firstReadArguments, onChunkRead);
+ session.Protocol.IO.read(firstReadArguments).then(message => onChunkRead(message.result));
// Assure multiple in-lfight reads are fine (also, save on latencies).
- InspectorTest.sendCommandOrDie("IO.read", readArguments, onChunkRead);
+ session.Protocol.IO.read(readArguments).then(message => onChunkRead(message.result));
function onChunkRead(response)
{
@@ -106,7 +104,7 @@ InspectorTest.retrieveStream = function(streamHandle, offset, chunkSize, callbac
callback(result);
return;
}
- InspectorTest.sendCommandOrDie("IO.read", readArguments, onChunkRead);
+ session.Protocol.IO.read(readArguments).then(message => onChunkRead(message.result));
}
}
@@ -129,8 +127,8 @@ InspectorTest.invokeAsyncWithTracing = function(functionName, callback)
function onStart()
{
- InspectorTest.evaluateInPageAsync(functionName + "()").then((data) => InspectorTest.stopTracing((devtoolsEvents) => callback(devtoolsEvents, data)));
+ session.evaluateAsync(functionName + "()").then((data) => InspectorTest.stopTracing((devtoolsEvents) => callback(devtoolsEvents, data)));
}
}
-}
+})

Powered by Google App Engine
This is Rietveld 408576698