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

Unified Diff: Source/devtools/front_end/Tests.js

Issue 553803003: [DevTools] Fix race in testDeviceMetricsOverrides. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: utility function Created 6 years, 3 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 | « no previous file | Source/devtools/front_end/common/Throttler.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/Tests.js
diff --git a/Source/devtools/front_end/Tests.js b/Source/devtools/front_end/Tests.js
index 7117132d72953b4d3012c7c94a1f97b68fd2ea4b..318dc19b6d88da247b4415bc56fb0638e3770256 100644
--- a/Source/devtools/front_end/Tests.js
+++ b/Source/devtools/front_end/Tests.js
@@ -224,6 +224,41 @@ TestSuite.prototype.addSniffer = function(receiver, methodName, override, opt_st
};
};
+/**
+ * Waits for current throttler invocations, if any.
+ * @param {!WebInspector.Throttler} throttler
+ * @param {!function} callback
+ */
+TestSuite.prototype.waitForThrottler = function(throttler, callback)
+{
+ var test = this;
+ var scheduleShouldFail = true;
+ test.addSniffer(throttler, "schedule", onSchedule);
+
+ function hasSomethingScheduled()
+ {
+ return throttler._isRunningProcess || throttler._process;
+ }
+
+ function checkState()
+ {
+ if (!hasSomethingScheduled()) {
+ scheduleShouldFail = false;
+ callback();
+ return;
+ }
+
+ test.addSniffer(throttler, "_processCompletedForTests", checkState);
+ }
+
+ function onSchedule()
+ {
+ if (scheduleShouldFail)
+ test.fail("Unexpected Throttler.schedule");
+ }
+
+ checkState();
+};
// UI Tests
@@ -615,8 +650,9 @@ TestSuite.prototype.testDeviceMetricsOverrides = function()
test.releaseControl();
}
- step1();
+ WebInspector.overridesSupport._deviceMetricsChangedListenerMuted = true;
test.takeControl();
+ this.waitForThrottler(WebInspector.overridesSupport._deviceMetricsThrottler, step1);
};
TestSuite.prototype.waitForTestResultsInConsole = function()
« no previous file with comments | « no previous file | Source/devtools/front_end/common/Throttler.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698