Bug 1355147 - Fix test moving to negative coordinates in headless mac. r?automatedtester draft
authorBrendan Dahl <brendan.dahl@gmail.com>
Mon, 03 Jul 2017 15:43:39 -0700
changeset 617138 5d564ab4b2061acd3513a4a398f701b744e4363b
parent 617137 79791843773b103c172b2d0221d4b55def142f70
child 617139 00e4dc002eea78339ed30216a1e049c0a0bc1524
push id70939
push userbmo:bdahl@mozilla.com
push dateFri, 28 Jul 2017 00:20:56 +0000
reviewersautomatedtester
bugs1355147
milestone56.0a1
Bug 1355147 - Fix test moving to negative coordinates in headless mac. r?automatedtester 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,
@@ -234,16 +234,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],
     ]);
   }
 
   set(key, value) {
     if (key === "timeouts" && !(value instanceof session.Timeouts)) {
       throw new TypeError();
     } else if (key === "proxy" && !(value instanceof session.Proxy)) {
       throw new TypeError();