| Index: third_party/WebKit/Source/devtools/front_end/main/Tests.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/main/Tests.js b/third_party/WebKit/Source/devtools/front_end/main/Tests.js
|
| index 4e3588faf341348ae949105e738d39ccf318b96e..e63ad970792b6cf8a8a99612efb519969a7b3133 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/main/Tests.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/main/Tests.js
|
| @@ -47,7 +47,6 @@
|
| function TestSuite()
|
| {
|
| WebInspector.TestBase.call(this, domAutomationController);
|
| - this._asyncInvocationId = 0;
|
| };
|
|
|
| TestSuite.prototype = {
|
| @@ -652,9 +651,10 @@
|
| this.takeControl();
|
| };
|
|
|
| -TestSuite.prototype.startTimeline = function(callback)
|
| -{
|
| - this.showPanel("timeline").then(function() {
|
| +TestSuite.prototype.invokeAsyncWithTimeline_ = function(functionName, callback)
|
| +{
|
| + var test = this;
|
| + test.showPanel("timeline").then(function() {
|
| WebInspector.panels.timeline._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStarted, onRecordingStarted);
|
| WebInspector.panels.timeline._toggleRecording();
|
| });
|
| @@ -662,76 +662,31 @@
|
| function onRecordingStarted()
|
| {
|
| WebInspector.panels.timeline._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStarted, onRecordingStarted);
|
| - callback();
|
| - }
|
| -}
|
| -
|
| -TestSuite.prototype.stopTimeline = function(callback)
|
| -{
|
| - WebInspector.panels.timeline._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped, onRecordingStopped);
|
| - WebInspector.panels.timeline._toggleRecording();
|
| + test.evaluateInConsole_(functionName + "(function() { console.log('DONE'); });", function() {});
|
| + WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage);
|
| + }
|
| +
|
| + function onConsoleMessage(event)
|
| + {
|
| + var text = event.data.messageText;
|
| + if (text === "DONE") {
|
| + WebInspector.multitargetConsoleModel.removeEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage);
|
| + pageActionsDone();
|
| + }
|
| + }
|
| +
|
| + function pageActionsDone()
|
| + {
|
| + WebInspector.panels.timeline._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped, onRecordingStopped);
|
| + WebInspector.panels.timeline._toggleRecording();
|
| + }
|
| +
|
| function onRecordingStopped()
|
| {
|
| WebInspector.panels.timeline._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStopped, onRecordingStopped);
|
| callback();
|
| }
|
| -}
|
| -
|
| -TestSuite.prototype.invokePageFunctionAsync = function(functionName, opt_args, callback_is_always_last)
|
| -{
|
| - var callback = arguments[arguments.length - 1];
|
| - var doneMessage = `DONE: ${functionName}.${++this._asyncInvocationId}`;
|
| - var argsString = arguments.length < 3 ? "" : Array.prototype.slice.call(arguments, 1, -1).map(arg => JSON.stringify(arg)).join(",") + ",";
|
| - this.evaluateInConsole_(`${functionName}(${argsString} function() { console.log('${doneMessage}'); });`, function() {});
|
| - WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage);
|
| -
|
| - function onConsoleMessage(event)
|
| - {
|
| - var text = event.data.messageText;
|
| - if (text === doneMessage) {
|
| - WebInspector.multitargetConsoleModel.removeEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage);
|
| - callback();
|
| - }
|
| - }
|
| -}
|
| -
|
| -TestSuite.prototype.invokeAsyncWithTimeline_ = function(functionName, callback)
|
| -{
|
| - var test = this;
|
| -
|
| - this.startTimeline(onRecordingStarted);
|
| -
|
| - function onRecordingStarted()
|
| - {
|
| - test.invokePageFunctionAsync(functionName, pageActionsDone);
|
| - }
|
| -
|
| - function pageActionsDone()
|
| - {
|
| - test.stopTimeline(callback);
|
| - }
|
| -};
|
| -
|
| -TestSuite.prototype.enableExperiment = function(name)
|
| -{
|
| - Runtime.experiments.enableForTest(name);
|
| -}
|
| -
|
| -TestSuite.prototype.checkInputEventsPresent = function()
|
| -{
|
| - var expectedEvents = new Set(arguments);
|
| - var model = WebInspector.panels.timeline._model;
|
| - var asyncEvents = model.mainThreadAsyncEvents();
|
| - var input = asyncEvents.get(WebInspector.TimelineUIUtils.asyncEventGroups().input) || [];
|
| - var prefix = "InputLatency::";
|
| - for (var e of input) {
|
| - if (!e.name.startsWith(prefix))
|
| - continue;
|
| - expectedEvents.delete(e.name.substr(prefix.length));
|
| - }
|
| - if (expectedEvents.size)
|
| - throw "Some expected events are not found: " + Array.from(expectedEvents.keys()).join(",");
|
| -}
|
| +};
|
|
|
| /**
|
| * Serializes array of uiSourceCodes to string.
|
|
|