Bug 1789357 - [remote] Make AppInfo a shared class for remote protocols. r=webdriver-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D156745
This commit is contained in:
Henrik Skupin 2022-09-09 11:58:44 +00:00
parent 5e049236e4
commit 16d96ac3fd
21 changed files with 29 additions and 32 deletions

View file

@ -50,8 +50,8 @@ add_task(async function testArrowKeys({ client }) {
await checkInputContent("haHa", 2);
info("Send ALT/CONTROL + Right");
let modCode = isMac ? alt : ctrl;
let modKey = isMac ? "Alt" : "Control";
const modCode = AppInfo.isMac ? alt : ctrl;
const modKey = AppInfo.isMac ? "Alt" : "Control";
await dispatchKeyEvent(Input, modKey, "rawKeyDown", modCode);
await dispatchKeyEvent(Input, "ArrowRight", "rawKeyDown", modCode);
await dispatchKeyEvent(Input, "ArrowRight", "keyUp");
@ -132,7 +132,7 @@ add_task(async function testSelectDelete({ client }) {
await sendRawKey(Input, "ArrowLeft");
await checkInputContent("word 2 word4", 10);
if (isMac) {
if (AppInfo.isMac) {
info("Send Meta + Backspace (deleteSoftLineBackward)");
await dispatchKeyEvent(Input, "Meta", "rawKeyDown", meta);
await sendRawKey(Input, "Backspace", meta);

View file

@ -41,7 +41,7 @@ add_task(async function testAltEvents({ client }) {
const { Input } = client;
await withModifier(Input, "Alt", "alt", "a");
if (isMac) {
if (AppInfo.isMac) {
await checkInputContent("a", 1);
} else {
await checkInputContent("", 0);
@ -63,7 +63,7 @@ add_task(async function testControlEvents({ client }) {
});
add_task(async function testMetaEvents({ client }) {
if (!isMac) {
if (!AppInfo.isMac) {
return;
}
await setupForInput(PAGE_URL);

View file

@ -13,11 +13,12 @@ Services.scriptloader.loadSubScript(
const { Input: I } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/parent/Input.jsm"
);
const { AppInfo } = ChromeUtils.import(
"chrome://remote/content/shared/AppInfo.jsm"
);
const { alt, ctrl, meta, shift } = I.Modifier;
const isMac = Services.appinfo.OS === "Darwin";
// Map of key codes used in Input tests.
const KEYCODES = {
a: KeyboardEvent.DOM_VK_A,
@ -105,7 +106,7 @@ function keyForPlatform() {
// TODO add cases for other key-combinations as the need arises
let primary = ctrl;
let primaryKey = "Control";
if (isMac) {
if (AppInfo.isMac) {
primary = alt;
primaryKey = "Alt";
}

View file

@ -13,6 +13,7 @@ remote.jar:
content/server/WebSocketTransport.jsm (server/WebSocketTransport.jsm)
# shared modules (all protocols)
content/shared/AppInfo.jsm (shared/AppInfo.jsm)
content/shared/Format.jsm (shared/Format.jsm)
content/shared/Log.jsm (shared/Log.jsm)
content/shared/MobileTabBrowser.jsm (shared/MobileTabBrowser.jsm)

View file

@ -16,7 +16,7 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
AppInfo: "chrome://remote/content/marionette/appinfo.js",
AppInfo: "chrome://remote/content/shared/AppInfo.jsm",
assert: "chrome://remote/content/shared/webdriver/Assert.jsm",
element: "chrome://remote/content/marionette/element.js",
error: "chrome://remote/content/shared/webdriver/Errors.jsm",

View file

@ -13,7 +13,7 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
AppInfo: "chrome://remote/content/marionette/appinfo.js",
AppInfo: "chrome://remote/content/shared/AppInfo.jsm",
error: "chrome://remote/content/shared/webdriver/Errors.jsm",
EventPromise: "chrome://remote/content/shared/Sync.jsm",
MessageManagerDestroyedPromise: "chrome://remote/content/marionette/sync.js",

View file

@ -18,7 +18,7 @@ const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
Addon: "chrome://remote/content/marionette/addon.js",
AppInfo: "chrome://remote/content/marionette/appinfo.js",
AppInfo: "chrome://remote/content/shared/AppInfo.jsm",
assert: "chrome://remote/content/shared/webdriver/Assert.jsm",
atom: "chrome://remote/content/marionette/atom.js",
browser: "chrome://remote/content/marionette/browser.js",

View file

@ -13,7 +13,6 @@ remote.jar:
content/marionette/actors/MarionetteReftestChild.jsm (actors/MarionetteReftestChild.jsm)
content/marionette/actors/MarionetteReftestParent.jsm (actors/MarionetteReftestParent.jsm)
content/marionette/addon.js (addon.js)
content/marionette/appinfo.js (appinfo.js)
content/marionette/atom.js (atom.js)
content/marionette/browser.js (browser.js)
content/marionette/capture.js (capture.js)

View file

@ -13,7 +13,7 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
AppInfo: "chrome://remote/content/marionette/appinfo.js",
AppInfo: "chrome://remote/content/shared/AppInfo.jsm",
Log: "chrome://remote/content/shared/Log.jsm",
});

View file

@ -15,7 +15,7 @@ const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
E10SUtils: "resource://gre/modules/E10SUtils.jsm",
AppInfo: "chrome://remote/content/marionette/appinfo.js",
AppInfo: "chrome://remote/content/shared/AppInfo.jsm",
assert: "chrome://remote/content/shared/webdriver/Assert.jsm",
capture: "chrome://remote/content/marionette/capture.js",
Log: "chrome://remote/content/shared/Log.jsm",

View file

@ -7,7 +7,6 @@ skip-if = appname == "thunderbird"
[test_action.js]
[test_actors.js]
[test_appinfo.js]
[test_browser.js]
[test_cookie.js]
[test_dom.js]

View file

@ -15,9 +15,9 @@ const ID_THUNDERBIRD = "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
/**
* Extends Services.appinfo with further properties that are
* used across Marionette.
* used by different protocols as handled by the Remote Agent.
*
* @typedef {object} Marionette.AppInfo
* @typedef {object} RemoteAgent.AppInfo
* @property {Boolean} isAndroid - Whether the application runs on Android.
* @property {Boolean} isLinux - Whether the application runs on Linux.
* @property {Boolean} isMac - Whether the application runs on Mac OS.

View file

@ -13,7 +13,7 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
AppInfo: "chrome://remote/content/marionette/appinfo.js",
AppInfo: "chrome://remote/content/shared/AppInfo.jsm",
EventPromise: "chrome://remote/content/shared/Sync.jsm",
MobileTabBrowser: "chrome://remote/content/shared/MobileTabBrowser.jsm",
});
@ -108,12 +108,9 @@ var TabManager = {
* Tab browser or null if it's not a browser window.
*/
getTabBrowser(win) {
// GeckoView
// TODO: Migrate to AppInfo.isAndroid after AppInfo moves to shared/
if (Services.appinfo.OS === "Android") {
if (lazy.AppInfo.isAndroid) {
return new lazy.MobileTabBrowser(win);
// Firefox
} else if ("gBrowser" in win) {
} else if (lazy.AppInfo.isFirefox) {
return win.gBrowser;
}
@ -298,7 +295,7 @@ var TabManager = {
supportsTabs() {
// TODO: Only Firefox supports adding tabs at the moment.
// Geckoview support should be added via Bug 1506782.
return lazy.AppInfo.name === "Firefox";
return lazy.AppInfo.isFirefox;
},
_getWindowForTab(tab) {

View file

@ -13,7 +13,7 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
AppInfo: "chrome://remote/content/marionette/appinfo.js",
AppInfo: "chrome://remote/content/shared/AppInfo.jsm",
error: "chrome://remote/content/shared/webdriver/Errors.jsm",
TabManager: "chrome://remote/content/shared/TabManager.jsm",
TimedPromise: "chrome://remote/content/marionette/sync.js",

View file

@ -5,7 +5,7 @@
"use strict";
const { AppInfo } = ChromeUtils.import(
"chrome://remote/content/marionette/appinfo.js"
"chrome://remote/content/shared/AppInfo.jsm"
);
// Minimal xpcshell tests for AppInfo; Services.appinfo.* is not available

View file

@ -2,6 +2,7 @@
# 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/.
[test_AppInfo.js]
[test_Format.js]
[test_Navigate.js]
[test_RecommendedPreferences.js]

View file

@ -13,7 +13,7 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
AppInfo: "chrome://remote/content/marionette/appinfo.js",
AppInfo: "chrome://remote/content/shared/AppInfo.jsm",
error: "chrome://remote/content/shared/webdriver/Errors.jsm",
pprint: "chrome://remote/content/shared/Format.jsm",
});

View file

@ -21,7 +21,7 @@ const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
Preferences: "resource://gre/modules/Preferences.jsm",
AppInfo: "chrome://remote/content/marionette/appinfo.js",
AppInfo: "chrome://remote/content/shared/AppInfo.jsm",
assert: "chrome://remote/content/shared/webdriver/Assert.jsm",
error: "chrome://remote/content/shared/webdriver/Errors.jsm",
pprint: "chrome://remote/content/shared/Format.jsm",

View file

@ -9,7 +9,7 @@ const { Preferences } = ChromeUtils.import(
);
const { AppInfo } = ChromeUtils.import(
"chrome://remote/content/marionette/appinfo.js"
"chrome://remote/content/shared/AppInfo.jsm"
);
const { error } = ChromeUtils.import(
"chrome://remote/content/shared/webdriver/Errors.jsm"

View file

@ -17,7 +17,7 @@ const { Module } = ChromeUtils.import(
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
AppInfo: "chrome://remote/content/marionette/appinfo.js",
AppInfo: "chrome://remote/content/shared/AppInfo.jsm",
assert: "chrome://remote/content/shared/webdriver/Assert.jsm",
BrowsingContextListener:
"chrome://remote/content/shared/listeners/BrowsingContextListener.jsm",

View file

@ -147,8 +147,6 @@
"chrome://remote/content/marionette/actors/MarionetteReftestParent.jsm":
"remote/marionette/actors/MarionetteReftestParent.jsm",
"chrome://remote/content/marionette/addon.js": "remote/marionette/addon.js",
"chrome://remote/content/marionette/appinfo.js":
"remote/marionette/appinfo.js",
"chrome://remote/content/marionette/atom.js": "remote/marionette/atom.js",
"chrome://remote/content/marionette/browser.js":
"remote/marionette/browser.js",
@ -190,6 +188,7 @@
"remote/server/WebSocketHandshake.jsm",
"chrome://remote/content/server/WebSocketTransport.jsm":
"remote/server/WebSocketTransport.jsm",
"chrome://remote/content/shared/AppInfo.jsm": "remote/shared/AppInfo.jsm",
"chrome://remote/content/shared/Format.jsm": "remote/shared/Format.jsm",
"chrome://remote/content/shared/Log.jsm": "remote/shared/Log.jsm",
"chrome://remote/content/shared/MobileTabBrowser.jsm":