Bug 1257526 - Return unsupported operation error for screen orientation on desktop; r=automatedtester
☠☠ backed out by d087c2f9a1ca ☠ ☠
authorAndreas Tolfsen <ato@mozilla.com>
Thu, 17 Mar 2016 14:54:48 +0000
changeset 289723 f8c07a51e7ce426f17f3998ed646d9f0300d331c
parent 289722 39cfff135061a1754c5e475a3b918c5c535304cf
child 289724 c1fb88d419ca6788f6d0594fb6eafe65d42771df
push id73981
push useratolfsen@mozilla.com
push dateTue, 22 Mar 2016 11:19:07 +0000
treeherdermozilla-inbound@c1fb88d419ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester
bugs1257526
milestone48.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 1257526 - Return unsupported operation error for screen orientation on desktop; r=automatedtester MozReview-Commit-ID: 4G9Bwaqxm5k
testing/marionette/driver.js
testing/marionette/harness/marionette/__init__.py
testing/marionette/harness/marionette/tests/unit/test_screen_orientation.py
testing/marionette/harness/marionette/tests/unit/unit-tests.ini
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -2578,31 +2578,38 @@ GeckoDriver.prototype.takeScreenshot = f
 /**
  * Get the current browser orientation.
  *
  * Will return one of the valid primary orientation values
  * portrait-primary, landscape-primary, portrait-secondary, or
  * landscape-secondary.
  */
 GeckoDriver.prototype.getScreenOrientation = function(cmd, resp) {
+  if (this.appName == "Firefox") {
+    throw new UnsupportedOperationError();
+  }
   resp.body.value = this.getCurrentWindow().screen.mozOrientation;
 };
 
 /**
  * Set the current browser orientation.
  *
  * The supplied orientation should be given as one of the valid
  * orientation values.  If the orientation is unknown, an error will
  * be raised.
  *
  * Valid orientations are "portrait" and "landscape", which fall
  * back to "portrait-primary" and "landscape-primary" respectively,
  * and "portrait-secondary" as well as "landscape-secondary".
  */
 GeckoDriver.prototype.setScreenOrientation = function(cmd, resp) {
+  if (this.appName == "Firefox") {
+    throw new UnsupportedOperationError();
+  }
+
   const ors = [
     "portrait", "landscape",
     "portrait-primary", "landscape-primary",
     "portrait-secondary", "landscape-secondary"
   ];
 
   let or = String(cmd.parameters.orientation);
   let mozOr = or.toLowerCase();
--- a/testing/marionette/harness/marionette/__init__.py
+++ b/testing/marionette/harness/marionette/__init__.py
@@ -6,16 +6,17 @@
 
 from .marionette_test import (
     CommonTestCase,
     expectedFailure,
     MarionetteJSTestCase,
     MarionetteTestCase,
     skip,
     skip_if_b2g,
+    skip_if_desktop,
     SkipTest,
     skip_unless_protocol,
 )
 from .runner import (
     B2GTestCaseMixin,
     B2GTestResultMixin,
     BaseMarionetteArguments,
     BaseMarionetteTestRunner,
--- a/testing/marionette/harness/marionette/tests/unit/test_screen_orientation.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_screen_orientation.py
@@ -1,90 +1,107 @@
-# -*- fill-column: 100; comment-column: 100; -*-
-
 # 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 marionette_driver.errors import MarionetteException
-from marionette import MarionetteTestCase
+from marionette_driver import errors
+from marionette import MarionetteTestCase, skip_if_b2g, skip_if_desktop
 from mozrunner.devices.emulator_screen import EmulatorScreen
 
 default_orientation = "portrait-primary"
 unknown_orientation = "Unknown screen orientation: %s"
 
 class TestScreenOrientation(MarionetteTestCase):
+    def setUp(self):
+        MarionetteTestCase.setUp(self)
+        self.is_mobile = self.marionette.session_capabilities["platformName"] != "Firefox"
+
     def tearDown(self):
-        self.marionette.set_orientation(default_orientation)
-        self.assertEqual(self.marionette.orientation, default_orientation, "invalid state")
-        super(MarionetteTestCase, self).tearDown()
+        if self.is_mobile:
+            self.marionette.set_orientation(default_orientation)
+            self.assertEqual(self.marionette.orientation, default_orientation, "invalid state")
+        MarionetteTestCase.tearDown(self)
 
+    @skip_if_desktop
     def test_set_orientation_to_portrait_primary(self):
         self.marionette.set_orientation("portrait-primary")
         new_orientation = self.marionette.orientation
         self.assertEqual(new_orientation, "portrait-primary")
 
         if self.marionette.emulator:
             emulator_orientation = self.marionette.emulator.screen.orientation
             self.assertEqual(emulator_orientation, EmulatorScreen.SO_PORTRAIT_PRIMARY)
 
+    @skip_if_desktop
     def test_set_orientation_to_landscape_primary(self):
         self.marionette.set_orientation("landscape-primary")
         new_orientation = self.marionette.orientation
         self.assertEqual(new_orientation, "landscape-primary")
 
         if self.marionette.emulator:
             emulator_orientation = self.marionette.emulator.screen.orientation
             self.assertEqual(emulator_orientation, EmulatorScreen.SO_LANDSCAPE_PRIMARY)
 
+    @skip_if_desktop
     def test_set_orientation_to_portrait_secondary(self):
         self.marionette.set_orientation("portrait-secondary")
         new_orientation = self.marionette.orientation
         self.assertEqual(new_orientation, "portrait-secondary")
 
         if self.marionette.emulator:
             emulator_orientation = self.marionette.emulator.screen.orientation
             self.assertEqual(emulator_orientation, EmulatorScreen.SO_PORTRAIT_SECONDARY)
 
+    @skip_if_desktop
     def test_set_orientation_to_landscape_secondary(self):
         self.marionette.set_orientation("landscape-secondary")
         new_orientation = self.marionette.orientation
         self.assertEqual(new_orientation, "landscape-secondary")
 
         if self.marionette.emulator:
             emulator_orientation = self.marionette.emulator.screen.orientation
             self.assertEqual(emulator_orientation, EmulatorScreen.SO_LANDSCAPE_SECONDARY)
 
+    @skip_if_desktop
     def test_set_orientation_to_shorthand_portrait(self):
         # Set orientation to something other than portrait-primary first, since the default is
         # portrait-primary.
         self.marionette.set_orientation("landscape-primary")
         self.assertEqual(self.marionette.orientation, "landscape-primary", "invalid state")
 
         self.marionette.set_orientation("portrait")
         new_orientation = self.marionette.orientation
         self.assertEqual(new_orientation, "portrait-primary")
 
         if self.marionette.emulator:
             emulator_orientation = self.marionette.emulator.screen.orientation
             self.assertEqual(emulator_orientation, EmulatorScreen.SO_PORTRAIT_PRIMARY)
 
+    @skip_if_desktop
     def test_set_orientation_to_shorthand_landscape(self):
         self.marionette.set_orientation("landscape")
         new_orientation = self.marionette.orientation
         self.assertEqual(new_orientation, "landscape-primary")
 
         if self.marionette.emulator:
             emulator_orientation = self.marionette.emulator.screen.orientation
             self.assertEqual(emulator_orientation, EmulatorScreen.SO_LANDSCAPE_PRIMARY)
 
+    @skip_if_desktop
     def test_set_orientation_with_mixed_casing(self):
         self.marionette.set_orientation("lAnDsCaPe")
         new_orientation = self.marionette.orientation
         self.assertEqual(new_orientation, "landscape-primary")
 
+    @skip_if_desktop
     def test_set_invalid_orientation(self):
-        with self.assertRaisesRegexp(MarionetteException, unknown_orientation % "cheese"):
+        with self.assertRaisesRegexp(errors.MarionetteException, unknown_orientation % "cheese"):
             self.marionette.set_orientation("cheese")
 
+    @skip_if_desktop
     def test_set_null_orientation(self):
-        with self.assertRaisesRegexp(MarionetteException, unknown_orientation % "null"):
+        with self.assertRaisesRegexp(errors.MarionetteException, unknown_orientation % "null"):
             self.marionette.set_orientation(None)
+
+    @skip_if_b2g
+    def test_unsupported_operation_on_desktop(self):
+        with self.assertRaises(errors.UnsupportedOperationException):
+            self.marionette.set_orientation("landscape-primary")
--- a/testing/marionette/harness/marionette/tests/unit/unit-tests.ini
+++ b/testing/marionette/harness/marionette/tests/unit/unit-tests.ini
@@ -129,17 +129,16 @@ b2g = false
 [test_wait.py]
 [test_expected.py]
 [test_date_time_value.py]
 [test_getactiveframe_oop.py]
 disabled = "Bug 925688"
 b2g = false
 [test_chrome_async_finish.js]
 [test_screen_orientation.py]
-browser = false
 [test_errors.py]
 
 [test_execute_isolate.py]
 [test_click_scrolling.py]
 [test_profile_management.py]
 b2g = false
 [test_set_window_size.py]
 b2g = false