Bug 1428795 - Reset Marionette state when initialisation fails. r=automatedtester
authorAndreas Tolfsen <ato@sny.no>
Mon, 26 Feb 2018 20:37:58 +0000
changeset 762126 672e7d5d8f40a04ccd87b0f84eb4ade0f19cbdd4
parent 762125 d1cb6c61dcf8dee823bf9416cd7046af8c1dd00b
child 762127 fbe5a80f2f5b2a7235fd17ba296c66b38846efeb
push id101094
push userbmo:edilee@mozilla.com
push dateThu, 01 Mar 2018 21:25:03 +0000
reviewersautomatedtester
bugs1428795
milestone60.0a1
Bug 1428795 - Reset Marionette state when initialisation fails. r=automatedtester If Marionette throws inside try...catch block that spawns the TCP listener, we fail to reset the altered recommended preferences to their original state, leaving a possibility of tainting the profile. By calling the uninitialisation code when an error is thrown we ensure all relevant state gets reset. MozReview-Commit-ID: XiiIEFMZQY
testing/marionette/components/marionette.js
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -544,16 +544,17 @@ class MarionetteMainProcess {
 
       try {
         ChromeUtils.import("chrome://marionette/content/server.js");
         let listener = new server.TCPListener(prefs.port);
         listener.start();
         this.server = listener;
       } catch (e) {
         log.fatal("Remote protocol server failed to start", e);
+        this.uninit();
         Services.startup.quit(Ci.nsIAppStartup.eForceQuit);
       }
 
       env.set(ENV_ENABLED, "1");
       Services.obs.notifyObservers(this, NOTIFY_RUNNING, true);
       log.info(`Listening on port ${this.server.port}`);
     });
   }