Bug 1432212 - Log error and quit Firefox when Marionette fails to start. r?maja_zf draft
authorAndreas Tolfsen <ato@sny.no>
Mon, 22 Jan 2018 17:27:54 +0000
changeset 723186 2fd139d4b52bf4cd85a6da9bdf5409fca19fc578
parent 723185 7e82ae59258a271b42d15a1396ec3b115cd6d59a
child 746788 755ccd4d4ba858a5d6b90805ea03426c9247c6fd
push id96350
push userbmo:ato@sny.no
push dateMon, 22 Jan 2018 17:33:36 +0000
reviewersmaja_zf
bugs1432212
milestone60.0a1
Bug 1432212 - Log error and quit Firefox when Marionette fails to start. r?maja_zf Log a fatal error when the Marionette remote protocol server fails to initialise, then quit Firefox. If we fail to start Marionette when passed the -marionette flag, there is little point in hanging around. MozReview-Commit-ID: 3s6ORJggNap
testing/marionette/components/marionette.js
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -289,27 +289,26 @@ MarionetteComponent.prototype.init = fun
     // ... and for startup tests
     let startupRecorder = Promise.resolve();
     if ("@mozilla.org/test/startuprecorder;1" in Cc) {
       startupRecorder = Cc["@mozilla.org/test/startuprecorder;1"]
           .getService().wrappedJSObject.done;
     }
     await startupRecorder;
 
-    let s;
     try {
       Cu.import("chrome://marionette/content/server.js");
-      s = new server.TCPListener(prefs.port);
-      s.start();
-      log.info(`Listening on port ${s.port}`);
-    } finally {
-      if (s) {
-        this.server = s;
-        this.running = true;
-      }
+      let listener = new server.TCPListener(prefs.port);
+      listener.start();
+      log.info(`Listening on port ${listener.port}`);
+      this.server = listener;
+      this.running = true;
+    } catch (e) {
+      log.fatal("Remote protocol server failed to start", e);
+      Services.startup.quit(Ci.nsIAppStartup.eForceQuit);
     }
   });
 };
 
 MarionetteComponent.prototype.uninit = function() {
   if (!this.running) {
     return;
   }