Bug 1470646 - Update Mn and Fxfn tests to use WebDriver conforming platformName. r?whimboo
MozReview-Commit-ID: 387jlJCbV59
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
@@ -16,18 +16,27 @@ class TestCapabilities(MarionetteTestCas
with self.marionette.using_context("chrome"):
self.appinfo = self.marionette.execute_script("""
return {
name: Services.appinfo.name,
version: Services.appinfo.version,
processID: Services.appinfo.processID,
}
""")
- self.os_name = self.marionette.execute_script(
- "return Services.sysinfo.getProperty('name')").lower()
+ self.os_name = self.marionette.execute_script("""
+ let name = Services.sysinfo.getProperty("name");
+ switch (name) {
+ case "Windows_NT":
+ return "windows";
+ case "Darwin":
+ return "mac";
+ default:
+ return name.toLowerCase();
+ }
+ """)
self.os_version = self.marionette.execute_script(
"return Services.sysinfo.getProperty('version')")
def get_fennec_profile(self):
profile = self.marionette.instance.runner.device.app_ctx.remote_profile
if self.caps["moz:profile"].lower() != profile.lower():
# mozdevice may be using a symlink and readlink is not
# universally available (missing from sdk 18).
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_key_actions.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_key_actions.py
@@ -16,17 +16,17 @@ from marionette_harness import Marionett
def inline(doc):
return "data:text/html;charset=utf-8,{}".format(urllib.quote(doc))
class TestKeyActions(WindowManagerMixin, MarionetteTestCase):
def setUp(self):
super(TestKeyActions, self).setUp()
- if self.marionette.session_capabilities["platformName"] == "darwin":
+ if self.marionette.session_capabilities["platformName"] == "mac":
self.mod_key = Keys.META
else:
self.mod_key = Keys.CONTROL
test_html = self.marionette.absolute_url("keyboard.html")
self.marionette.navigate(test_html)
self.reporter_element = self.marionette.find_element(By.ID, "keyReporter")
self.reporter_element.click()
self.key_action = Actions(self.marionette)
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_legacy_mouse_action.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_legacy_mouse_action.py
@@ -17,17 +17,17 @@ def inline(doc):
return "data:text/html;charset=utf-8,{}".format(urllib.quote(doc))
class BaseLegacyMouseAction(MarionetteTestCase):
def setUp(self):
super(BaseLegacyMouseAction, self).setUp()
- if self.marionette.session_capabilities["platformName"] == "darwin":
+ if self.marionette.session_capabilities["platformName"] == "mac":
self.mod_key = Keys.META
else:
self.mod_key = Keys.CONTROL
self.action = Actions(self.marionette)
class TestLegacyMouseAction(BaseLegacyMouseAction):
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py
@@ -60,17 +60,17 @@ class Actions(object):
return self
class BaseMouseAction(MarionetteTestCase):
def setUp(self):
super(BaseMouseAction, self).setUp()
- if self.marionette.session_capabilities["platformName"] == "darwin":
+ if self.marionette.session_capabilities["platformName"] == "mac":
self.mod_key = Keys.META
else:
self.mod_key = Keys.CONTROL
self.action = Actions(self.marionette)
def tearDown(self):
super(BaseMouseAction, self).tearDown()
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
@@ -45,17 +45,17 @@ class BaseNavigationTestCase(WindowManag
self.test_page_file_url = "file:///{}".format(file_path)
self.test_page_frameset = self.marionette.absolute_url("frameset.html")
self.test_page_insecure = self.fixtures.where_is("test.html", on="https")
self.test_page_not_remote = "about:robots"
self.test_page_push_state = self.marionette.absolute_url("navigation_pushstate.html")
self.test_page_remote = self.marionette.absolute_url("test.html")
self.test_page_slow_resource = self.marionette.absolute_url("slow_resource.html")
- if self.marionette.session_capabilities["platformName"] == "darwin":
+ if self.marionette.session_capabilities["platformName"] == "mac":
self.mod_key = Keys.META
else:
self.mod_key = Keys.CONTROL
def open_with_link():
link = self.marionette.find_element(By.ID, "new-blank-tab")
link.click()
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_switch_window_content.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_switch_window_content.py
@@ -10,17 +10,17 @@ from marionette_driver.keys import Keys
from marionette_harness import MarionetteTestCase, skip_if_mobile, WindowManagerMixin
class TestSwitchToWindowContent(WindowManagerMixin, MarionetteTestCase):
def setUp(self):
super(TestSwitchToWindowContent, self).setUp()
- if self.marionette.session_capabilities["platformName"] == "darwin":
+ if self.marionette.session_capabilities["platformName"] == "mac":
self.mod_key = Keys.META
else:
self.mod_key = Keys.CONTROL
self.empty_page = self.marionette.absolute_url("empty.html")
self.test_page = self.marionette.absolute_url("windowHandles.html")
self.selected_tab_index = self.get_selected_tab_index()
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_typing.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_typing.py
@@ -17,17 +17,17 @@ def inline(doc):
return "data:text/html;charset=utf-8,{}".format(urllib.quote(doc))
class TypingTestCase(MarionetteTestCase):
def setUp(self):
super(TypingTestCase, self).setUp()
- if self.marionette.session_capabilities["platformName"] == "darwin":
+ if self.marionette.session_capabilities["platformName"] == "mac":
self.mod_key = Keys.META
else:
self.mod_key = Keys.CONTROL
class TestTypingChrome(TypingTestCase):
def setUp(self):
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_window_maximize.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_window_maximize.py
@@ -26,17 +26,17 @@ class TestWindowMaximize(MarionetteTestC
self.original_size = actual
def tearDown(self):
self.marionette.set_window_rect(
width=self.original_size["width"], height=self.original_size["height"])
def assert_window_maximized(self, actual, delta=None):
- if self.marionette.session_capabilities["platformName"] == "windows_nt":
+ if self.marionette.session_capabilities["platformName"] == "windows":
delta = 16
else:
delta = 22
self.assertGreaterEqual(
actual["width"], self.max["width"] - delta,
msg="Window width is not within {delta} px of availWidth: "
"current width {current} should be greater than or equal to max width {max}"
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_window_rect.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_window_rect.py
@@ -181,23 +181,23 @@ class TestWindowRect(MarionetteTestCase)
elif os == "linux":
# certain WMs prohibit windows from being moved off-screen
self.assertLessEqual(new_position["x"], 0)
self.assertLessEqual(new_position["y"], 0)
# On macOS, windows can only be moved off the screen on the
# horizontal axis. The system menu bar also blocks windows from
# being moved to (0,0).
- elif os == "darwin":
+ elif os == "mac":
self.assertEqual(-8, new_position["x"])
self.assertEqual(23, new_position["y"])
# It turns out that Windows is the only platform on which the
# window can be reliably positioned off-screen.
- elif os == "windows_nt":
+ elif os == "windows":
self.assertEqual(-8, new_position["x"])
self.assertEqual(-8, new_position["y"])
def test_resize_larger_than_screen(self):
new_size = self.marionette.set_window_rect(
width=self.max["width"] * 2, height=self.max["height"] * 2)
actual_size = self.marionette.window_rect
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/keys.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/keys.py
@@ -3,17 +3,19 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import
import marionette_driver
class Keys(marionette_driver.keys.Keys):
- """Proxy to marionette's keys with an "accel" provided for convenience
- testing across platforms."""
+ """
+ Proxy to Marionette's keys with an "accel" provided for convenience
+ testing across platforms.
+ """
def __init__(self, marionette):
- self.isDarwin = marionette.session_capabilities['platformName'] == 'darwin'
+ self.is_mac = marionette.session_capabilities["platformName"] == "mac"
@property
def ACCEL(self):
- return self.META if self.isDarwin else self.CONTROL
+ return self.META if self.is_mac else self.CONTROL
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
@@ -241,17 +241,17 @@ class BrowserWindow(BaseWindow):
"""
def callback(win):
# Prepare action which triggers the opening of the browser window
if callable(trigger):
trigger(win)
elif trigger == 'menu':
self.menubar.select_by_id('tools-menu', 'menu_pageInfo')
elif trigger == 'shortcut':
- if win.marionette.session_capabilities['platformName'] == 'windows_nt':
+ if win.marionette.session_capabilities['platformName'] == 'windows':
raise ValueError('Page info shortcut not available on Windows.')
win.send_shortcut(win.localize_entity('pageInfoCmd.commandkey'),
accel=True)
elif trigger == 'context_menu':
# TODO: Add once we can do right clicks
pass
else:
raise ValueError('Unknown opening method: "%s"' % trigger)
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/windows.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/windows.py
@@ -389,17 +389,17 @@ class BaseWindow(BaseLib):
:param shift: Optional, If `True`, the `Shift` modifier key is pressed.
Defaults to `False`.
"""
platform = self.marionette.session_capabilities['platformName']
keymap = {
- 'accel': Keys.META if platform == 'darwin' else Keys.CONTROL,
+ 'accel': Keys.META if platform == "mac" else Keys.CONTROL,
'alt': Keys.ALT,
'cmd': Keys.COMMAND,
'ctrl': Keys.CONTROL,
'meta': Keys.META,
'shift': Keys.SHIFT,
}
# Append all to press modifier keys