Bug 1472136 - Detect XML parsing errors during Marionette startup.
The patch lets Marionette detect a XML parser error window
during startup, which usually leaves the browser in an
unusable state. Marionette client then times out after
120s with a generic and not helpful error message.
In case such a window opens Marionette logs a fatal message
to the console, which then can be picked-up by Treeherder
for the failure summary.
MozReview-Commit-ID: L3zW3TcaJhE
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -18,16 +18,18 @@ XPCOMUtils.defineLazyModuleGetters(this,
TCPListener: "chrome://marionette/content/server.js",
});
XPCOMUtils.defineLazyGetter(this, "log", Log.get);
XPCOMUtils.defineLazyServiceGetter(
this, "env", "@mozilla.org/process/environment;1", "nsIEnvironment");
+const XMLURI_PARSE_ERROR = "http://www.mozilla.org/newlayout/xml/parsererror.xml";
+
const NOTIFY_RUNNING = "remote-active";
// Complements -marionette flag for starting the Marionette server.
// We also set this if Marionette is running in order to start the server
// again after a Firefox restart.
const ENV_ENABLED = "MOZ_MARIONETTE";
const PREF_ENABLED = "marionette.enabled";
@@ -314,16 +316,17 @@ class MarionetteParentProcess {
} else {
this.uninit();
}
break;
case "profile-after-change":
Services.obs.addObserver(this, "command-line-startup");
Services.obs.addObserver(this, "sessionstore-windows-restored");
+ Services.obs.addObserver(this, "toplevel-window-ready");
for (let [pref, value] of EnvironmentPrefs.from(ENV_PRESERVE_PREFS)) {
Preferences.set(pref, value);
}
break;
// In safe mode the command line handlers are getting parsed after the
// safe mode dialog has been closed. To allow Marionette to start
@@ -354,18 +357,32 @@ class MarionetteParentProcess {
}
break;
case "domwindowopened":
Services.obs.removeObserver(this, topic);
this.suppressSafeModeDialog(subject);
break;
+ case "toplevel-window-ready":
+ subject.addEventListener("load", ev => {
+ if (ev.target.documentElement.namespaceURI == XMLURI_PARSE_ERROR) {
+ Services.obs.removeObserver(this, topic);
+
+ let parserError = ev.target.querySelector("parsererror");
+ log.fatal(parserError.textContent);
+ this.uninit();
+ Services.startup.quit(Ci.nsIAppStartup.eForceQuit);
+ }
+ }, {once: true});
+ break;
+
case "sessionstore-windows-restored":
Services.obs.removeObserver(this, topic);
+ Services.obs.removeObserver(this, "toplevel-window-ready");
// 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") {