Bug 1355147 - Fix test moving to negative coordinates in headless mac. r=whimboo
authorBrendan Dahl <brendan.dahl@gmail.com>
Mon, 03 Jul 2017 15:43:39 -0700
changeset 420442 19854c39011d6650b0e70f6ff8e8f27999c18c02
parent 420441 803e1b08f00f20c61a9bc7892bb97470ab991a45
child 420443 a9e070c60d4b27ec494cf9d4955ec0a444803c1c
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1355147
milestone56.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 1355147 - Fix test moving to negative coordinates in headless mac. r=whimboo Expose if the browser is headless to marionette session capabilities so the tests can check headless behavior. MozReview-Commit-ID: 10va2Iv2ytO
testing/marionette/harness/marionette_harness/tests/unit/test_window_rect.py
testing/marionette/session.js
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_window_rect.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_window_rect.py
@@ -77,20 +77,26 @@ class TestPosition(MarionetteTestCase):
         # not throw.
         #
         # Because we have to cater to an unknown set of environments,
         # the following assertions are the most common denominator that
         # make this test pass, irregardless of system characteristics.
 
         os = self.marionette.session_capabilities["platformName"]
 
+        # Regardless of platform, headless always supports being positioned
+        # off-screen.
+        if self.marionette.session_capabilities["moz:headless"]:
+            self.assertEqual(-8, position["x"])
+            self.assertEqual(-8, position["y"])
+
         # Certain WMs prohibit windows from being moved off-screen,
         # but we don't have this information.  It should be safe to
         # assume a window can be moved to (0,0) or less.
-        if os == "linux":
+        elif os == "linux":
             # certain WMs prohibit windows from being moved off-screen
             self.assertLessEqual(position["x"], 0)
             self.assertLessEqual(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":
--- a/testing/marionette/session.js
+++ b/testing/marionette/session.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 "use strict";
 
-const {interfaces: Ci, utils: Cu} = Components;
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 Cu.import("chrome://marionette/content/assert.js");
 const {
   error,
@@ -262,16 +262,17 @@ session.Capabilities = class extends Map
       // features
       ["rotatable", appinfo.name == "B2G"],
 
       // proprietary
       ["specificationLevel", 0],
       ["moz:processID", Services.appinfo.processID],
       ["moz:profile", maybeProfile()],
       ["moz:accessibilityChecks", false],
+      ["moz:headless", Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo).isHeadless],
     ]);
   }
 
   /**
    * @param {string} key
    *     Capability name.
    * @param {(string|number|boolean)} value
    *     JSON-safe capability value.