Bug 1391691 - Make WebDriver:FullscreenWindow idempotent. r?automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Fri, 18 Aug 2017 18:32:11 +0100
changeset 649133 eb1c27d7d0319a13051966a512fd7a42b39c7e03
parent 649132 1e74874ab0f027a55494afba8babbf8913fda734
child 649134 a3285532c82c76aa7b1925bd48087430d027482e
push id74962
push userbmo:ato@sny.no
push dateFri, 18 Aug 2017 17:50:50 +0000
reviewersautomatedtester
bugs1391691
milestone57.0a1
Bug 1391691 - Make WebDriver:FullscreenWindow idempotent. r?automatedtester MozReview-Commit-ID: 4AQlYYNV03f
testing/marionette/driver.js
testing/marionette/harness/marionette_harness/tests/unit/test_window_fullscreen.py
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -3129,20 +3129,22 @@ GeckoDriver.prototype.maximizeWindow = a
  * @throws {UnexpectedAlertOpenError}
  *     A modal dialog is open, blocking this operation.
  */
 GeckoDriver.prototype.fullscreenWindow = async function(cmd, resp) {
   assert.firefox();
   const win = assert.window(this.getCurrentWindow());
   assert.noUserPrompt(this.dialog);
 
-  await new Promise(resolve => {
-    win.addEventListener("sizemodechange", resolve, {once: true});
-    win.fullScreen = !win.fullScreen;
-  });
+  if (!win.fullScreen) {
+    await new Promise(resolve => {
+      win.addEventListener("sizemodechange", resolve, {once: true});
+      win.fullScreen = true;
+    });
+  }
 
   return this.curBrowser.rect;
 };
 
 /**
  * Dismisses a currently displayed tab modal, or returns no such alert if
  * no modal is displayed.
  */
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_window_fullscreen.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_window_fullscreen.py
@@ -25,24 +25,24 @@ class TestWindowFullscreen(MarionetteTes
 
     def tearDown(self):
         fullscreen = self.marionette.execute_script("""
             return window.fullScreen;""", sandbox=None)
         if fullscreen:
             self.marionette.fullscreen()
 
     def assert_window_fullscreen(self, actual):
-        self.assertGreater(actual["width"], self.max["width"])
-        self.assertGreater(actual["height"], self.max["height"])
-        self.assertTrue(self.marionette.execute_script("""
-            return window.fullScreen;""", sandbox=None))
+        self.assertTrue(self.marionette.execute_script(
+            "return window.fullScreen", sandbox=None))
 
     def assert_window_restored(self, actual):
         self.assertEqual(self.original_size["width"], actual["width"])
         self.assertEqual(self.original_size["height"], actual["height"])
+        self.assertFalse(self.marionette.execute_script(
+            "return window.fullScreen", sandbox=None))
 
     def assert_window_rect(self, rect):
         self.assertIn("width", rect)
         self.assertIn("height", rect)
         self.assertIn("x", rect)
         self.assertIn("y", rect)
         self.assertIsInstance(rect["width"], int)
         self.assertIsInstance(rect["height"], int)
@@ -51,14 +51,11 @@ class TestWindowFullscreen(MarionetteTes
 
     def test_fullscreen(self):
         rect = self.marionette.fullscreen()
         self.assert_window_rect(rect)
         size = self.marionette.window_size
         self.assertEqual(size, rect)
         self.assert_window_fullscreen(size)
 
-    def test_fullscreen_twice_restores(self):
-        fullscreen = self.marionette.fullscreen()
-        self.assert_window_fullscreen(fullscreen)
-
-        restored = self.marionette.fullscreen()
-        self.assert_window_restored(restored)
+    def test_fullscreen_twice_is_idempotent(self):
+        self.assert_window_fullscreen(self.marionette.fullscreen())
+        self.assert_window_fullscreen(self.marionette.fullscreen())