Bug 1472136 - Detect XML parsing errors during Marionette startup. r=ato
authorHenrik Skupin <mail@hskupin.info>
Fri, 29 Jun 2018 13:14:32 +0200
changeset 479733 d9ba5e1359a11e48b4069eac7ffba364d7b7d7bc
parent 479732 50c10bf4d10f144d1a89e50c3fc32aa2f9810aba
child 479734 4d792e8bdc7be4444528ec090f6eb3b93cb2f056
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1472136
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1472136 - Detect XML parsing errors during Marionette startup. r=ato 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
testing/marionette/components/marionette.js
--- 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") {