Bug 1315611 - Ignore GFX sanity check window during startup of Firefox. r=ato

On Windows systems an additional chrome window will be opened during startup.
It's used for testing specific GFX related features. It's located off-screen
and will usually be closed immediately. But in some situations it can take longer.

To avoid an inconsistent list of start window handles Marionette should wait
with starting the test until this window has actually been closed.

MozReview-Commit-ID: Izh3dPQSHC

--HG--
extra : rebase_source : ce5d9f9c15d5255ed6acf85b808ad0e616d14f03
This commit is contained in:
Henrik Skupin 2017-03-07 19:38:51 +01:00
Родитель 6d5a642e48
Коммит fa37fb63b3
2 изменённых файлов: 49 добавлений и 38 удалений

Просмотреть файл

@ -55,6 +55,7 @@ MarionetteComponent.prototype = {
],
enabled: false,
finalUiStartup: false,
gfxWindow: null,
server: null,
};
@ -113,13 +114,15 @@ MarionetteComponent.prototype.handle = function (cmdLine) {
}
};
MarionetteComponent.prototype.observe = function (subj, topic, data) {
MarionetteComponent.prototype.observe = function (subject, topic, data) {
switch (topic) {
case "profile-after-change":
this.maybeReadPrefsFromEnvironment();
// Using final-ui-startup as the xpcom category doesn't seem to work,
// Using sessionstore-windows-restored as the xpcom category doesn't seem to work,
// so we wait for that by adding an observer here.
this.observerService.addObserver(this, "final-ui-startup", false);
this.observerService.addObserver(this, "sessionstore-windows-restored", false);
this.maybeReadPrefsFromEnvironment();
#ifdef ENABLE_MARIONETTE
this.enabled = Preferences.get(ENABLED_PREF, false);
if (this.enabled) {
@ -134,11 +137,14 @@ MarionetteComponent.prototype.observe = function (subj, topic, data) {
#endif
break;
case "final-ui-startup":
this.finalUiStartup = true;
this.observerService.removeObserver(this, topic);
this.observerService.addObserver(this, "xpcom-shutdown", false);
this.init();
case "domwindowclosed":
if (this.gfxWindow === null || subject === this.gfxWindow) {
this.observerService.removeObserver(this, topic);
this.observerService.addObserver(this, "xpcom-shutdown", false);
this.finalUiStartup = true;
this.init();
}
break;
case "domwindowopened":
@ -146,6 +152,30 @@ MarionetteComponent.prototype.observe = function (subj, topic, data) {
this.suppressSafeModeDialog_(subj);
break;
case "sessionstore-windows-restored":
this.observerService.removeObserver(this, topic);
// When Firefox starts on Windows, an additional GFX sanity test window
// may appear off-screen. Marionette should wait for it to close.
let winEn = Services.wm.getEnumerator(null);
while (winEn.hasMoreElements()) {
let win = winEn.getNext();
if (win.document.documentURI == "chrome://gfxsanity/content/sanityparent.html") {
this.gfxWindow = win;
break;
}
}
if (this.gfxWindow) {
this.observerService.addObserver(this, "domwindowclosed", false);
} else {
this.observerService.addObserver(this, "xpcom-shutdown", false);
this.finalUiStartup = true;
this.init();
}
break;
case "xpcom-shutdown":
this.observerService.removeObserver(this, "xpcom-shutdown");
this.uninit();

Просмотреть файл

@ -41,7 +41,7 @@ Cu.import("chrome://marionette/content/wait.js");
this.EXPORTED_SYMBOLS = ["GeckoDriver", "Context"];
var FRAME_SCRIPT = "chrome://marionette/content/listener.js";
const BROWSER_STARTUP_FINISHED = "browser-delayed-startup-finished";
const CLICK_TO_START_PREF = "marionette.debugging.clicktostart";
const CONTENT_LISTENER_PREF = "marionette.contentListener";
@ -70,13 +70,6 @@ Services.obs.addObserver(function() {
systemMessageListenerReady = true;
}, "system-message-listener-ready", false);
// This is used on desktop to prevent newSession from returning before a page
// load initiated by the Firefox command line has completed.
var delayedBrowserStarted = false;
Services.obs.addObserver(function () {
delayedBrowserStarted = true;
}, BROWSER_STARTUP_FINISHED, false);
this.Context = {
CHROME: "chrome",
CONTENT: "content",
@ -622,29 +615,17 @@ GeckoDriver.prototype.newSession = function* (cmd, resp) {
}
};
let runSessionStart = function() {
if (!Preferences.get(CONTENT_LISTENER_PREF)) {
waitForWindow.call(this);
} else if (this.appName != "Firefox" && this.curBrowser === null) {
// if there is a content listener, then we just wake it up
this.addBrowser(this.getCurrentWindow());
this.curBrowser.startSession(this.whenBrowserStarted.bind(this));
this.mm.broadcastAsyncMessage("Marionette:restart", {});
} else {
throw new WebDriverError("Session already running");
}
this.switchToGlobalMessageManager();
};
if (!delayedBrowserStarted && this.appName != "B2G") {
let self = this;
Services.obs.addObserver(function onStart() {
Services.obs.removeObserver(onStart, BROWSER_STARTUP_FINISHED);
runSessionStart.call(self);
}, BROWSER_STARTUP_FINISHED, false);
if (!Preferences.get(CONTENT_LISTENER_PREF)) {
waitForWindow.call(this);
} else if (this.appName != "Firefox" && this.curBrowser === null) {
// if there is a content listener, then we just wake it up
this.addBrowser(this.getCurrentWindow());
this.curBrowser.startSession(this.whenBrowserStarted.bind(this));
this.mm.broadcastAsyncMessage("Marionette:restart", {});
} else {
runSessionStart.call(this);
throw new WebDriverError("Session already running");
}
this.switchToGlobalMessageManager();
yield registerBrowsers;
yield browserListening;