Bug 1850682 - Add a base RootBiDiModule class r=webdriver-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D218482
This commit is contained in:
Temidayo 2024-08-05 15:32:59 +00:00
Родитель 39b81764ff
Коммит ade6951b93
11 изменённых файлов: 45 добавлений и 34 удалений

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

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

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

@ -0,0 +1,14 @@
/* 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 https://mozilla.org/MPL/2.0/. */
import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs";
export class RootBiDiModule extends Module {
_hasListener(eventName, contextInfo) {
return this.messageHandler.eventsDispatcher.hasListener(
eventName,
contextInfo
);
}
}

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

@ -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 { RootBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/RootBiDiModule.sys.mjs";
const lazy = {};
@ -35,7 +35,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
* Array of UserContextInfo for the current user contexts.
*/
class BrowserModule extends Module {
class BrowserModule extends RootBiDiModule {
constructor(messageHandler) {
super(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 { RootBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/RootBiDiModule.sys.mjs";
const lazy = {};
@ -156,7 +156,7 @@ const WaitCondition = {
Complete: "complete",
};
class BrowsingContextModule extends Module {
class BrowsingContextModule extends RootBiDiModule {
#contextListener;
#navigationListener;
#promptListener;

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

@ -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 { RootBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/RootBiDiModule.sys.mjs";
const lazy = {};
@ -15,7 +15,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
"chrome://remote/content/shared/messagehandler/WindowGlobalMessageHandler.sys.mjs",
});
class InputModule extends Module {
class InputModule extends RootBiDiModule {
destroy() {}
async performActions(options = {}) {

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

@ -2,9 +2,9 @@
* 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 { RootBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/RootBiDiModule.sys.mjs";
class LogModule extends Module {
class LogModule extends RootBiDiModule {
destroy() {}
static get supportedEvents() {

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

@ -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 { RootBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/RootBiDiModule.sys.mjs";
const lazy = {};
@ -298,7 +298,7 @@ const SameSite = {
*/
/* eslint-enable jsdoc/valid-types */
class NetworkModule extends Module {
class NetworkModule extends RootBiDiModule {
#beforeStopRequestListener;
#blockedRequests;
#decodedBodySizeMap;
@ -1590,10 +1590,9 @@ class NetworkModule extends Module {
const protocolEventName = "network.authRequired";
const isListening = this.messageHandler.eventsDispatcher.hasListener(
protocolEventName,
{ contextId: request.contextId }
);
const isListening = this._hasListener(protocolEventName, {
contextId: request.contextId,
});
if (!isListening) {
// If there are no listeners subscribed to this event and this context,
// bail out.
@ -1670,10 +1669,9 @@ class NetworkModule extends Module {
this.#getContextInfo(browsingContext)
);
const isListening = this.messageHandler.eventsDispatcher.hasListener(
protocolEventName,
{ contextId: request.contextId }
);
const isListening = this._hasListener(protocolEventName, {
contextId: request.contextId,
});
if (!isListening) {
// If there are no listeners subscribed to this event and this context,
// bail out.
@ -1753,10 +1751,9 @@ class NetworkModule extends Module {
this.#getContextInfo(browsingContext)
);
const isListening = this.messageHandler.eventsDispatcher.hasListener(
protocolEventName,
{ contextId: request.contextId }
);
const isListening = this._hasListener(protocolEventName, {
contextId: request.contextId,
});
if (!isListening) {
// If there are no listeners subscribed to this event and this context,
// bail out.
@ -1815,10 +1812,9 @@ class NetworkModule extends Module {
this.#getContextInfo(browsingContext)
);
const isListening = this.messageHandler.eventsDispatcher.hasListener(
protocolEventName,
{ contextId: request.contextId }
);
const isListening = this._hasListener(protocolEventName, {
contextId: request.contextId,
});
if (!isListening) {
// If there are no listeners subscribed to this event and this context,
// bail out.

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

@ -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 { RootBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/RootBiDiModule.sys.mjs";
const lazy = {};
@ -15,7 +15,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
"chrome://remote/content/shared/UserContextManager.sys.mjs",
});
class PermissionsModule extends Module {
class PermissionsModule extends RootBiDiModule {
constructor(messageHandler) {
super(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 { RootBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/RootBiDiModule.sys.mjs";
const lazy = {};
@ -41,7 +41,7 @@ const ScriptEvaluateResultType = {
Success: "success",
};
class ScriptModule extends Module {
class ScriptModule extends RootBiDiModule {
#preloadScriptMap;
#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 { RootBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/RootBiDiModule.sys.mjs";
const lazy = {};
@ -19,7 +19,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
TabManager: "chrome://remote/content/shared/TabManager.sys.mjs",
});
class SessionModule extends Module {
class SessionModule extends RootBiDiModule {
#browsingContextIdEventMap;
#globalEventSet;

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

@ -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 { RootBiDiModule } from "chrome://remote/content/webdriver-bidi/modules/RootBiDiModule.sys.mjs";
const lazy = {};
@ -69,7 +69,7 @@ const SameSiteType = {
[Ci.nsICookie.SAMESITE_STRICT]: "strict",
};
class StorageModule extends Module {
class StorageModule extends RootBiDiModule {
destroy() {}
/**