Bug 1820738 - Used a custom Module base class for WebDriver BiDi. r=jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D175232
This commit is contained in:
Victoria Ajala 2023-04-18 21:05:49 +00:00
Родитель 6170eb43cc
Коммит df57e6b178
7 изменённых файлов: 30 добавлений и 16 удалений

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

@ -59,10 +59,6 @@ export class WindowGlobalMessageHandler extends MessageHandler {
return this.#innerWindowId;
}
get processActor() {
return ChromeUtils.domProcessChild.getActor("WebDriverProcessData");
}
get window() {
return this.context.window;
}

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

@ -13,6 +13,7 @@ remote.jar:
# WebDriver BiDi modules
content/webdriver-bidi/modules/ModuleRegistry.sys.mjs (modules/ModuleRegistry.sys.mjs)
content/webdriver-bidi/modules/WindowGlobalBiDiModule.sys.mjs (modules/WindowGlobalBiDiModule.sys.mjs)
# WebDriver BiDi root modules
content/webdriver-bidi/modules/root/browsingContext.sys.mjs (modules/root/browsingContext.sys.mjs)

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

@ -0,0 +1,18 @@
/* 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/. */
import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs";
/**
* Base class for all WindowGlobal BiDi MessageHandler modules.
*/
export class WindowGlobalBiDiModule extends Module {
get nodeCache() {
return this.processActor.getNodeCache();
}
get processActor() {
return ChromeUtils.domProcessChild.getActor("WebDriverProcessData");
}
}

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

@ -2,7 +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/. */
import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs";
import { WindowGlobalBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/WindowGlobalBiDiModule.sys.mjs";
const lazy = {};
@ -10,7 +10,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
LoadListener: "chrome://remote/content/shared/listeners/LoadListener.sys.mjs",
});
class BrowsingContextModule extends Module {
class BrowsingContextModule extends WindowGlobalBiDiModule {
#loadListener;
#subscribedEvents;

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

@ -2,7 +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/. */
import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs";
import { WindowGlobalBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/WindowGlobalBiDiModule.sys.mjs";
const lazy = {};
@ -10,7 +10,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
action: "chrome://remote/content/shared/webdriver/Actions.sys.mjs",
});
class InputModule extends Module {
class InputModule extends WindowGlobalBiDiModule {
#actionState;
constructor(messageHandler) {

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

@ -2,7 +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/. */
import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs";
import { WindowGlobalBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/WindowGlobalBiDiModule.sys.mjs";
const lazy = {};
@ -18,7 +18,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
"chrome://remote/content/webdriver-bidi/RemoteValue.sys.mjs",
});
class LogModule extends Module {
class LogModule extends WindowGlobalBiDiModule {
#consoleAPIListener;
#consoleMessageListener;
#subscribedEvents;
@ -137,7 +137,7 @@ class LogModule extends Module {
text += args.map(String).join(" ");
// Serialize each arg as remote value.
const nodeCache = this.messageHandler.processActor.getNodeCache();
const nodeCache = this.nodeCache;
const serializedArgs = [];
for (const arg of args) {
// Note that we can pass a `null` realm for now since realms are only

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

@ -2,7 +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/. */
import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs";
import { WindowGlobalBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/WindowGlobalBiDiModule.sys.mjs";
const lazy = {};
@ -33,7 +33,7 @@ const EvaluationStatus = {
Throw: "throw",
};
class ScriptModule extends Module {
class ScriptModule extends WindowGlobalBiDiModule {
#defaultRealm;
#observerListening;
#preloadScripts;
@ -325,7 +325,7 @@ class ScriptModule extends Module {
} = options;
const realm = this.#getRealm(realmId, sandboxName);
const nodeCache = this.messageHandler.processActor.getNodeCache();
const nodeCache = this.nodeCache;
const deserializedArguments =
commandArguments !== null
@ -411,7 +411,6 @@ class ScriptModule extends Module {
} = options;
const realm = this.#getRealm(realmId, sandboxName);
const nodeCache = this.messageHandler.processActor.getNodeCache();
const rv = realm.executeInGlobal(expression);
@ -422,7 +421,7 @@ class ScriptModule extends Module {
resultOwnership,
serializationOptions,
{
nodeCache,
nodeCache: this.nodeCache,
}
);
}