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

--HG--
extra : rebase_source : 207fce0eec9c74eb4d1218f0f088e6a05ae7a7ba
This commit is contained in:
Andreas Tolfsen 2016-11-30 14:56:34 +00:00
parent 41c8bcea79
commit 2a68e4a0f8
3 changed files with 9 additions and 0 deletions

View File

@ -574,6 +574,7 @@ class Marionette(object):
self.session = None
self.session_id = None
self.process_id = None
self.profile = None
self.window = None
self.chrome_window = None
self.baseurl = baseurl
@ -1274,6 +1275,7 @@ class Marionette(object):
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
@ -1304,6 +1306,7 @@ class Marionette(object):
self.session_id = None
self.session = None
self.process_id = None
self.profile = None
self.window = None
self.client.close()

View File

@ -161,6 +161,7 @@ this.GeckoDriver = function(appName, server) {
// proprietary extensions
"specificationLevel": 0,
"moz:processID": Services.appinfo.processID,
"moz:profile": Services.dirsvc.get("ProfD", Ci.nsIFile).path,
};
this.mm = globalMessageManager;

View File

@ -42,6 +42,11 @@ class TestCapabilities(MarionetteTestCase):
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"}}