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
This commit is contained in:
Henrik Skupin 2020-08-17 16:52:37 +00:00
Родитель f619c49685
Коммит e626ef7b33
2 изменённых файлов: 19 добавлений и 8 удалений

Просмотреть файл

@ -440,7 +440,7 @@ class Capabilities extends Map {
["acceptInsecureCerts", false],
["pageLoadStrategy", PageLoadStrategy.Normal],
["proxy", new Proxy()],
["setWindowRect", appinfo.name == "firefox"],
["setWindowRect", !Services.androidBridge],
["timeouts", new Timeouts()],
["strictFileInteractability", false],
["unhandledPromptBehavior", UnhandledPromptBehavior.DismissAndNotify],
@ -541,11 +541,11 @@ class Capabilities extends Map {
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;

Просмотреть файл

@ -7,6 +7,7 @@
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"
@ -411,7 +412,7 @@ add_test(function test_Capabilities_ctor() {
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"));
@ -506,9 +507,19 @@ add_test(function test_Capabilities_fromJSON() {
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"));