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

Unified Diff: third_party/WebKit/Source/devtools/front_end/main/Tests.js

Issue 1704723002: DevTools: add input event instrumentation test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: speculative attempt to fix MacOS 10.6 flakiness Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/common/TestBase.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e63ad970792b6cf8a8a99612efb519969a7b3133..4e3588faf341348ae949105e738d39ccf318b96e 100644
--- a/third_party/WebKit/Source/devtools/front_end/main/Tests.js
+++ b/third_party/WebKit/Source/devtools/front_end/main/Tests.js
@@ -47,6 +47,7 @@ function createTestSuite(domAutomationController)
function TestSuite()
{
WebInspector.TestBase.call(this, domAutomationController);
+ this._asyncInvocationId = 0;
};
TestSuite.prototype = {
@@ -651,10 +652,9 @@ TestSuite.prototype.waitForTestResultsInConsole = function()
this.takeControl();
};
-TestSuite.prototype.invokeAsyncWithTimeline_ = function(functionName, callback)
+TestSuite.prototype.startTimeline = function(callback)
{
- var test = this;
- test.showPanel("timeline").then(function() {
+ this.showPanel("timeline").then(function() {
WebInspector.panels.timeline._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStarted, onRecordingStarted);
WebInspector.panels.timeline._toggleRecording();
});
@@ -662,32 +662,77 @@ TestSuite.prototype.invokeAsyncWithTimeline_ = function(functionName, callback)
function onRecordingStarted()
{
WebInspector.panels.timeline._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStarted, onRecordingStarted);
- test.evaluateInConsole_(functionName + "(function() { console.log('DONE'); });", function() {});
- WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage);
+ callback();
+ }
+}
+
+TestSuite.prototype.stopTimeline = function(callback)
+{
+ 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 === "DONE") {
+ if (text === doneMessage) {
WebInspector.multitargetConsoleModel.removeEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage);
- pageActionsDone();
+ callback();
}
}
+}
- function pageActionsDone()
+TestSuite.prototype.invokeAsyncWithTimeline_ = function(functionName, callback)
+{
+ var test = this;
+
+ this.startTimeline(onRecordingStarted);
+
+ function onRecordingStarted()
{
- WebInspector.panels.timeline._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped, onRecordingStopped);
- WebInspector.panels.timeline._toggleRecording();
+ test.invokePageFunctionAsync(functionName, pageActionsDone);
}
- function onRecordingStopped()
+ function pageActionsDone()
{
- WebInspector.panels.timeline._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStopped, onRecordingStopped);
- callback();
+ 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.
* @param {!Array.<!WebInspectorUISourceCode>} uiSourceCodes
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/common/TestBase.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698