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
--- 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();