Bug 857599 - Clone profile for Marionette tests to prevent polluting the original profile. r=jgriffin, a=test-only
authorDave Hunt <dhunt@mozilla.com>
Wed, 10 Apr 2013 09:31:35 +0100
changeset 119032 423f7851bdb56a218da985b5b6ac503839d29e0b
parent 119031 b644771c03f5aa28d01e798b3d5d29b22c9f04d5
child 119033 84f2fee5d8e838ec0cb09471d008c3e35df628b9
push id650
push userdhunt@mozilla.com
push dateWed, 10 Apr 2013 12:43:05 +0000
reviewersjgriffin, test-only
bugs857599
milestone18.0
Bug 857599 - Clone profile for Marionette tests to prevent polluting the original profile. r=jgriffin, a=test-only
testing/marionette/client/marionette/geckoinstance.py
--- a/testing/marionette/client/marionette/geckoinstance.py
+++ b/testing/marionette/client/marionette/geckoinstance.py
@@ -1,12 +1,13 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/
 
+from mozprofile import Profile
 from mozrunner import Runner
 
 
 class GeckoInstance(object):
 
     required_prefs = {"marionette.defaultPrefs.enabled": True,
                       "marionette.defaultPrefs.port": 2828,
                       "browser.warnOnQuit": False}
@@ -17,27 +18,34 @@ class GeckoInstance(object):
         self.bin = bin
         self.profile = profile
         self.runner = None
 
     def start(self):
         profile_path = self.profile
         profile_args = {"preferences": self.required_prefs}
         if not profile_path:
+            runner_class = Runner
             profile_args["restore"] = False
         else:
-            profile_args["profile"] = profile_path
+            runner_class = CloneRunner
+            profile_args["path_from"] = profile_path
         print "starting runner"
-        self.runner = Runner.create(binary=self.bin,
-                                    profile_args=profile_args,
-                                    cmdargs=['-no-remote'])
+        self.runner = runner_class.create(binary=self.bin,
+                                         profile_args=profile_args,
+                                         cmdargs=['-no-remote'])
         self.runner.start()
 
     def close(self):
         self.runner.stop()
         self.runner.cleanup()
 
 
 class B2GDesktopInstance(GeckoInstance):
 
     required_prefs = {"focusmanager.testmode": True}
 
 apps = {'b2gdesktop': B2GDesktopInstance}
+
+
+class CloneRunner(Runner):
+
+    profile_class = Profile.clone