Bug 1650872 - [marionette] Allow setWindowRect capability for all desktop but not Android. r=marionette-reviewers,maja_zf
authorHenrik Skupin <mail@hskupin.info>
Mon, 17 Aug 2020 16:52:37 +0000
changeset 609602 1f03b2cb3e24dfdc3a47234454f88516ff65a6f6
parent 609601 d3d9b27cdf360546b520e31c1d0513a8c98e7f62
child 609603 c1bb5b123bde03f87200258ed4e73dae9b1fde00
push id13553
push userffxbld-merge
push dateMon, 24 Aug 2020 12:51:36 +0000
treeherdermozilla-beta@a54f8b5d0977 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarionette-reviewers, maja_zf
bugs1650872
milestone81.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 1650872 - [marionette] Allow setWindowRect capability for all desktop but not Android. r=marionette-reviewers,maja_zf Differential Revision: https://phabricator.services.mozilla.com/D86956
testing/marionette/capabilities.js
testing/marionette/test/unit/test_capabilities.js
--- a/testing/marionette/capabilities.js
+++ b/testing/marionette/capabilities.js
@@ -435,17 +435,17 @@ class Capabilities extends Map {
       // webdriver
       ["browserName", getWebDriverBrowserName()],
       ["browserVersion", appinfo.version],
       ["platformName", getWebDriverPlatformName()],
       ["platformVersion", Services.sysinfo.getProperty("version")],
       ["acceptInsecureCerts", false],
       ["pageLoadStrategy", PageLoadStrategy.Normal],
       ["proxy", new Proxy()],
-      ["setWindowRect", appinfo.name == "firefox"],
+      ["setWindowRect", !Services.androidBridge],
       ["timeouts", new Timeouts()],
       ["strictFileInteractability", false],
       ["unhandledPromptBehavior", UnhandledPromptBehavior.DismissAndNotify],
 
       // features
       ["rotatable", appinfo.name == "B2G"],
 
       // proprietary
@@ -536,21 +536,21 @@ class Capabilities extends Map {
           break;
 
         case "proxy":
           v = Proxy.fromJSON(v);
           break;
 
         case "setWindowRect":
           assert.boolean(v, pprint`Expected ${k} to be boolean, got ${v}`);
-          if (appinfo.name == "firefox" && !v) {
+          if (!Services.androidBridge && !v) {
             throw new InvalidArgumentError("setWindowRect cannot be disabled");
-          } else if (appinfo.name != "firefox" && v) {
+          } else if (Services.androidBridge && v) {
             throw new InvalidArgumentError(
-              "setWindowRect is only supported in Firefox desktop"
+              "setWindowRect is only supported on desktop"
             );
           }
           break;
 
         case "timeouts":
           v = Timeouts.fromJSON(v);
           break;
 
--- a/testing/marionette/test/unit/test_capabilities.js
+++ b/testing/marionette/test/unit/test_capabilities.js
@@ -2,16 +2,17 @@
  * 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 { Preferences } = ChromeUtils.import(
   "resource://gre/modules/Preferences.jsm"
 );
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 const { InvalidArgumentError } = ChromeUtils.import(
   "chrome://marionette/content/error.js"
 );
 const {
   Capabilities,
   PageLoadStrategy,
   Proxy,
@@ -406,17 +407,17 @@ add_test(function test_Capabilities_ctor
   ok(caps.has("browserVersion"));
   ok(caps.has("platformName"));
   ok(["linux", "mac", "windows", "android"].includes(caps.get("platformName")));
   ok(caps.has("platformVersion"));
   equal(PageLoadStrategy.Normal, caps.get("pageLoadStrategy"));
   equal(false, caps.get("acceptInsecureCerts"));
   ok(caps.get("timeouts") instanceof Timeouts);
   ok(caps.get("proxy") instanceof Proxy);
-  equal(caps.get("setWindowRect"), false); // xpcshell does not populate appinfo
+  equal(caps.get("setWindowRect"), !Services.androidBridge);
   equal(caps.get("strictFileInteractability"), false);
 
   ok(caps.has("rotatable"));
 
   equal(false, caps.get("moz:accessibilityChecks"));
   ok(caps.has("moz:buildID"));
   ok(caps.has("moz:processID"));
   ok(caps.has("moz:profile"));
@@ -501,19 +502,29 @@ add_test(function test_Capabilities_from
   let proxyConfig = { proxyType: "manual" };
   caps = fromJSON({ proxy: proxyConfig });
   equal("manual", caps.get("proxy").proxyType);
 
   let timeoutsConfig = { implicit: 123 };
   caps = fromJSON({ timeouts: timeoutsConfig });
   equal(123, caps.get("timeouts").implicit);
 
-  caps = fromJSON({ setWindowRect: false });
-  equal(false, caps.get("setWindowRect"));
-  Assert.throws(() => fromJSON({ setWindowRect: true }), InvalidArgumentError);
+  if (!Services.androidBridge) {
+    caps = fromJSON({ setWindowRect: true });
+    equal(true, caps.get("setWindowRect"));
+    Assert.throws(
+      () => fromJSON({ setWindowRect: false }),
+      InvalidArgumentError
+    );
+  } else {
+    Assert.throws(
+      () => fromJSON({ setWindowRect: true }),
+      InvalidArgumentError
+    );
+  }
 
   caps = fromJSON({ strictFileInteractability: false });
   equal(false, caps.get("strictFileInteractability"));
   caps = fromJSON({ strictFileInteractability: true });
   equal(true, caps.get("strictFileInteractability"));
 
   caps = fromJSON({ "moz:accessibilityChecks": true });
   equal(true, caps.get("moz:accessibilityChecks"));