Bug 1321278 - Return profile directory in capabilities; r=whimboo
authorAndreas Tolfsen <ato@mozilla.com>
Wed, 30 Nov 2016 14:56:34 +0000
changeset 324884 df839937b41595803dc81cda22f1f02eb1805245
parent 324883 da9707f081f9ee54f59bc52da81f22540f64d313
child 324885 2bb4237ef57486be880f36451a7deb55b0c233f5
push id34847
push useratolfsen@mozilla.com
push dateThu, 01 Dec 2016 13:16:47 +0000
treeherderautoland@df839937b415 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1321278
milestone53.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 1321278 - Return profile directory in capabilities; r=whimboo This introduces a new capability, `moz:profile`, which contains the path to the currently used profile directory. MozReview-Commit-ID: FKF4Hde3tF9
testing/marionette/client/marionette_driver/marionette.py
testing/marionette/driver.js
testing/marionette/harness/marionette/tests/unit/test_capabilities.py
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -569,16 +569,17 @@ class Marionette(object):
         """
         self.host = host
         self.port = self.local_port = int(port)
         self.bin = bin
         self.instance = None
         self.session = None
         self.session_id = None
         self.process_id = None
+        self.profile = None
         self.window = None
         self.chrome_window = None
         self.baseurl = baseurl
         self._test_name = None
         self.socket_timeout = socket_timeout
         self.crashed = 0
 
         startup_timeout = startup_timeout or self.DEFAULT_STARTUP_TIMEOUT
@@ -1269,16 +1270,17 @@ class Marionette(object):
 
         body = {"capabilities": desired_capabilities, "sessionId": session_id}
         resp = self._send_message("newSession", body)
 
         self.session_id = resp["sessionId"]
         self.session = resp["value"] if self.protocol == 1 else resp["capabilities"]
         # fallback to processId can be removed in Firefox 55
         self.process_id = self.session.get("moz:processID", self.session.get("processId"))
+        self.profile = self.session.get("moz:profile")
 
         return self.session
 
     @property
     def test_name(self):
         return self._test_name
 
     @test_name.setter
@@ -1299,16 +1301,17 @@ class Marionette(object):
         try:
             if send_request:
                 self._send_message("deleteSession")
         finally:
             if reset_session_id:
                 self.session_id = None
             self.session = None
             self.process_id = None
+            self.profile = None
             self.window = None
             self.client.close()
 
     @property
     def session_capabilities(self):
         """A JSON dictionary representing the capabilities of the
         current session.
 
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -156,16 +156,17 @@ this.GeckoDriver = function(appName, ser
     // supported features
     "raisesAccessibilityExceptions": false,
     "rotatable": this.appName == "B2G",
     "proxy": {},
 
     // proprietary extensions
     "specificationLevel": 0,
     "moz:processID": Services.appinfo.processID,
+    "moz:profile": Services.dirsvc.get("ProfD", Ci.nsIFile).path,
   };
 
   this.mm = globalMessageManager;
   this.listener = proxy.toListener(() => this.mm, this.sendAsync.bind(this));
 
   // always keep weak reference to current dialogue
   this.dialog = null;
   let handleDialog = (subject, topic) => {
--- a/testing/marionette/harness/marionette/tests/unit/test_capabilities.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_capabilities.py
@@ -37,16 +37,21 @@ class TestCapabilities(MarionetteTestCas
         self.assertIn("acceptInsecureCerts", self.caps)
         self.assertFalse(self.caps["acceptInsecureCerts"])
 
     def test_additional_capabilities(self):
         self.assertIn("moz:processID", self.caps)
         self.assertEqual(self.caps["moz:processID"], self.appinfo["processID"])
         self.assertEqual(self.marionette.process_id, self.appinfo["processID"])
 
+        current_profile = self.marionette.instance.runner.profile.profile
+        self.assertIn("moz:profile", self.caps)
+        self.assertEqual(self.caps["moz:profile"], current_profile)
+        self.assertEqual(self.marionette.profile, current_profile)
+
     def test_we_can_pass_in_capabilities_on_session_start(self):
         self.marionette.delete_session()
         capabilities = {"desiredCapabilities": {"somethingAwesome": "cake"}}
         self.marionette.start_session(capabilities)
         caps = self.marionette.session_capabilities
         self.assertIn("somethingAwesome", caps)
 
     def test_set_specification_level(self):