diff --git a/testing/marionette/client/marionette/tests/unit/test_about_pages.py b/testing/marionette/client/marionette/tests/unit/test_about_pages.py index 729dd9884df7..23dcb0221358 100644 --- a/testing/marionette/client/marionette/tests/unit/test_about_pages.py +++ b/testing/marionette/client/marionette/tests/unit/test_about_pages.py @@ -11,8 +11,7 @@ class TestAboutPages(MarionetteTestCase): def setUp(self): MarionetteTestCase.setUp(self) - - if self.marionette.session_capabilities['platformName'] == 'DARWIN': + if self.marionette.session_capabilities['platformName'] == 'Darwin': self.mod_key = Keys.META else: self.mod_key = Keys.CONTROL diff --git a/testing/marionette/client/marionette/tests/unit/test_capabilities.py b/testing/marionette/client/marionette/tests/unit/test_capabilities.py index 2e4fb10c9276..e873d3b26554 100644 --- a/testing/marionette/client/marionette/tests/unit/test_capabilities.py +++ b/testing/marionette/client/marionette/tests/unit/test_capabilities.py @@ -5,13 +5,23 @@ from marionette import MarionetteTestCase from marionette_driver.errors import SessionNotCreatedException + class TestCapabilities(MarionetteTestCase): + def setUp(self): super(TestCapabilities, self).setUp() self.caps = self.marionette.session_capabilities - self.marionette.set_context("chrome") - self.appinfo = self.marionette.execute_script( - "return Services.appinfo") + with self.marionette.using_context("chrome"): + self.appinfo = self.marionette.execute_script( + "return Services.appinfo") + self.os_name = self.marionette.execute_script( + "return Services.sysinfo.getProperty('name')") + self.os_version = self.marionette.execute_script( + "return Services.sysinfo.getProperty('version')") + + @property + def is_b2g(self): + return self.appinfo["name"] == "B2G" def test_mandates_capabilities(self): self.assertIn("browserName", self.caps) @@ -22,9 +32,8 @@ class TestCapabilities(MarionetteTestCase): self.assertEqual(self.caps["browserName"], self.appinfo["name"]) self.assertEqual(self.caps["browserVersion"], self.appinfo["version"]) - self.assertEqual(self.caps["platformName"], self.appinfo["OS"].upper()) - self.assertEqual(self.caps["platformVersion"], - self.appinfo["platformVersion"]) + self.assertEqual(self.caps["platformName"], self.os_name) + self.assertEqual(self.caps["platformVersion"], self.os_version) def test_supported_features(self): self.assertIn("rotatable", self.caps) @@ -32,14 +41,14 @@ class TestCapabilities(MarionetteTestCase): self.assertIn("takesElementScreenshot", self.caps) self.assertIn("takesScreenshot", self.caps) - self.assertEqual(self.caps["rotatable"], self.appinfo["name"] == "B2G") + self.assertEqual(self.caps["rotatable"], self.is_b2g) self.assertFalse(self.caps["acceptSslCerts"]) self.assertTrue(self.caps["takesElementScreenshot"]) self.assertTrue(self.caps["takesScreenshot"]) def test_selenium2_compat(self): self.assertIn("platform", self.caps) - self.assertEqual(self.caps["platform"], self.caps["platformName"]) + self.assertEqual(self.caps["platform"], self.caps["platformName"].upper()) def test_extensions(self): self.assertIn("XULappId", self.caps) @@ -53,14 +62,14 @@ class TestCapabilities(MarionetteTestCase): def test_we_can_pass_in_capabilities_on_session_start(self): self.marionette.delete_session() - capabilities = { "desiredCapabilities": {"somethingAwesome": "cake"}} + capabilities = {"desiredCapabilities": {"somethingAwesome": "cake"}} self.marionette.start_session(capabilities) caps = self.marionette.session_capabilities self.assertIn("somethingAwesome", caps) def test_we_dont_overwrite_server_capabilities(self): self.marionette.delete_session() - capabilities = { "desiredCapabilities": {"browserName": "ChocolateCake"}} + capabilities = {"desiredCapabilities": {"browserName": "ChocolateCake"}} self.marionette.start_session(capabilities) caps = self.marionette.session_capabilities self.assertEqual(caps["browserName"], self.appinfo["name"], @@ -68,14 +77,14 @@ class TestCapabilities(MarionetteTestCase): def test_we_can_pass_in_required_capabilities_on_session_start(self): self.marionette.delete_session() - capabilities = { "requiredCapabilities": {"browserName": self.appinfo["name"]}} + capabilities = {"requiredCapabilities": {"browserName": self.appinfo["name"]}} self.marionette.start_session(capabilities) caps = self.marionette.session_capabilities self.assertIn("browserName", caps) def test_we_pass_in_required_capability_we_cant_fulfil_raises_exception(self): self.marionette.delete_session() - capabilities = { "requiredCapabilities": {"browserName": "CookiesAndCream"}} + capabilities = {"requiredCapabilities": {"browserName": "CookiesAndCream"}} try: self.marionette.start_session(capabilities) self.fail("Marionette Should have throw an exception") @@ -87,6 +96,6 @@ class TestCapabilities(MarionetteTestCase): # same state it was before it started the test self.marionette.start_session() - def test_we_get_valid_uuid_4_when_creating_a_session(self): - self.assertNotIn("{", self.marionette.session_id, 'Session ID has {} in it. %s ' \ - % self.marionette.session_id) + def test_we_get_valid_uuid4_when_creating_a_session(self): + self.assertNotIn("{", self.marionette.session_id, + "Session ID has {} in it: %s" % self.marionette.session_id) diff --git a/testing/marionette/client/marionette/tests/unit/test_key_actions.py b/testing/marionette/client/marionette/tests/unit/test_key_actions.py index 13a231d6a653..a7d5c5badbd3 100644 --- a/testing/marionette/client/marionette/tests/unit/test_key_actions.py +++ b/testing/marionette/client/marionette/tests/unit/test_key_actions.py @@ -10,7 +10,7 @@ class TestKeyActions(MarionetteTestCase): def setUp(self): MarionetteTestCase.setUp(self) - if self.marionette.session_capabilities['platformName'] == 'DARWIN': + if self.marionette.session_capabilities['platformName'] == 'Darwin': self.mod_key = Keys.META else: self.mod_key = Keys.CONTROL diff --git a/testing/marionette/client/marionette/tests/unit/test_mouse_action.py b/testing/marionette/client/marionette/tests/unit/test_mouse_action.py index a0b6c9c2d773..611adbaf7dce 100644 --- a/testing/marionette/client/marionette/tests/unit/test_mouse_action.py +++ b/testing/marionette/client/marionette/tests/unit/test_mouse_action.py @@ -11,7 +11,7 @@ class TestMouseAction(MarionetteTestCase): def setUp(self): MarionetteTestCase.setUp(self) - if self.marionette.session_capabilities['platformName'] == 'DARWIN': + if self.marionette.session_capabilities['platformName'] == 'Darwin': self.mod_key = Keys.META else: self.mod_key = Keys.CONTROL diff --git a/testing/marionette/client/marionette/tests/unit/test_typing.py b/testing/marionette/client/marionette/tests/unit/test_typing.py index 081c84fa2ce9..2f3474cfc9d5 100644 --- a/testing/marionette/client/marionette/tests/unit/test_typing.py +++ b/testing/marionette/client/marionette/tests/unit/test_typing.py @@ -58,7 +58,7 @@ class TestTyping(MarionetteTestCase): @skip_if_b2g def testCutAndPasteShortcuts(self): # Test that modifier keys work via copy/paste shortcuts. - if self.marionette.session_capabilities['platformName'] == 'DARWIN': + if self.marionette.session_capabilities['platformName'] == 'Darwin': mod_key = Keys.META else: mod_key = Keys.CONTROL diff --git a/testing/marionette/client/marionette/tests/unit/test_window_handles.py b/testing/marionette/client/marionette/tests/unit/test_window_handles.py index c0fba8025115..4aca3f7239b5 100644 --- a/testing/marionette/client/marionette/tests/unit/test_window_handles.py +++ b/testing/marionette/client/marionette/tests/unit/test_window_handles.py @@ -11,7 +11,7 @@ class TestWindowHandles(MarionetteTestCase): def test_new_tab_window_handles(self): keys = [] - if self.marionette.session_capabilities['platformName'] == 'DARWIN': + if self.marionette.session_capabilities['platformName'] == 'Darwin': keys.append(Keys.META) else: keys.append(Keys.CONTROL) diff --git a/testing/marionette/driver.js b/testing/marionette/driver.js index f591bf58e2bd..71ee581e0ff4 100644 --- a/testing/marionette/driver.js +++ b/testing/marionette/driver.js @@ -136,14 +136,14 @@ this.GeckoDriver = function(appName, device, emulator) { this.actions = new ActionChain(utils); this.sessionCapabilities = { - // Mandated capabilities - "browserName": this.appName, + // mandated capabilities + "browserName": Services.appinfo.name, "browserVersion": Services.appinfo.version, - "platformName": Services.appinfo.OS.toUpperCase(), - "platformVersion": Services.appinfo.platformVersion, + "platformName": Services.sysinfo.getProperty("name"), + "platformVersion": Services.sysinfo.getProperty("version"), "specificationLevel": "1", - // Supported features + // supported features "raisesAccessibilityExceptions": false, "rotatable": this.appName == "B2G", "acceptSslCerts": false, @@ -152,13 +152,13 @@ this.GeckoDriver = function(appName, device, emulator) { "proxy": {}, // Selenium 2 compat - "platform": Services.appinfo.OS.toUpperCase(), + "platform": Services.sysinfo.getProperty("name").toUpperCase(), - // Proprietary extensions + // proprietary extensions "XULappId" : Services.appinfo.ID, "appBuildId" : Services.appinfo.appBuildID, "device": device, - "version": Services.appinfo.version + "version": Services.appinfo.version, }; this.mm = globalMessageManager;