Bug 1385453 - Move the mouse to the bottom center of the screen between test runs. r?Mossop
MozReview-Commit-ID: 8twQQ5cuxUm
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -390,16 +390,35 @@ Tester.prototype = {
this.structuredLogger.info("TEST-INFO | (browser-test.js) | " + msg.replace(/\n$/, "") + "\n");
} catch (ex) {
// Swallow exception so we don't lead to another error being reported,
// throwing us into an infinite loop
}
},
nextTest: Task.async(function*() {
+ let winUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
+
+ // Move the mouse out of the way. Certain behaviours might be triggered
+ // by the mouse hovering in a particular place. Currently, we figure the
+ // safest place to put the cursor to avoid this (and things like Windows 8
+ // hot corners) is in the bottom center of the screen.
+ yield new Promise(resolve => {
+ let observer = (subject, topic, data) => {
+ if (topic == "mouseevent") {
+ resolve();
+ }
+ };
+
+ winUtils.sendNativeMouseEvent(Math.floor(window.screen.width / 2),
+ window.screen.height, null, 0, null,
+ observer);
+ });
+
if (this.currentTest) {
if (this._coverageCollector) {
this._coverageCollector.recordTestCoverage(this.currentTest.path);
}
// Run cleanup functions for the current test before moving on to the
// next one.
let testScope = this.currentTest.scope;
@@ -422,18 +441,16 @@ Tester.prototype = {
this.currentTest.todoCount === 0) {
this.currentTest.addResult(new testResult({
name: "This test contains no passes, no fails and no todos. Maybe" +
" it threw a silent exception? Make sure you use" +
" waitForExplicitFinish() if you need it.",
}));
}
- let winUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils);
if (winUtils.isTestControllingRefreshes) {
this.currentTest.addResult(new testResult({
name: "test left refresh driver under test control",
}));
winUtils.restoreNormalRefresh();
}
if (this.SimpleTest.isExpectingUncaughtException()) {