To support realm events for shared and service workers - which can have more than 1 related context - we need to adapt our logic to match several browsing contexts to a single context descriptor. On the bidi spec, this is expressed in the event is enabled algorithm (https://w3c.github.io/webdriver-bidi/#event-is-enabled )which takes an array of navigables as parameter. In order to enable this, a few event-related APIs are modified to support matching several browsing context ids. We should be able to emit an event related to N contexts, and the event should be emitted if: - any subscription monitors any of the related contexts - any subscription monitors the user context of any of the related contexts - any subscription is global Note that this allows to emit an event related to 0 browsing contexts. In that case, global subscriptions should still get the event. While this is handy given that we can't currently retrieve the contexts related to service and shared worker, this is also an important feature in the long run. It is completely possible to have a worker instance for a service worker which. starts running even if no related context is open at the moment. A dedicated browser mochitest is added to cover the new feature. Differential Revision: https://phabricator.services.mozilla.com/D282748
59 lines
2.6 KiB
JavaScript
59 lines
2.6 KiB
JavaScript
/* 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/. */
|
|
|
|
export const modules = {
|
|
root: { vendor: {} },
|
|
"windowglobal-in-root": { vendor: {} },
|
|
windowglobal: { vendor: {} },
|
|
};
|
|
|
|
const BASE_FOLDER =
|
|
"chrome://mochitests/content/browser/remote/shared/messagehandler/test/browser/resources/modules";
|
|
|
|
// eslint-disable-next-line mozilla/lazy-getter-object-name
|
|
ChromeUtils.defineESModuleGetters(modules.root, {
|
|
command: `${BASE_FOLDER}/root/command.sys.mjs`,
|
|
event: `${BASE_FOLDER}/root/event.sys.mjs`,
|
|
invalid: `${BASE_FOLDER}/root/invalid.sys.mjs`,
|
|
retry: `${BASE_FOLDER}/root/retry.sys.mjs`,
|
|
rootOnly: `${BASE_FOLDER}/root/rootOnly.sys.mjs`,
|
|
windowglobaltoroot: `${BASE_FOLDER}/root/windowglobaltoroot.sys.mjs`,
|
|
});
|
|
|
|
// eslint-disable-next-line mozilla/lazy-getter-object-name
|
|
ChromeUtils.defineESModuleGetters(modules.root.vendor, {
|
|
vendored: `${BASE_FOLDER}/root/vendor/vendored.sys.mjs`,
|
|
});
|
|
|
|
// eslint-disable-next-line mozilla/lazy-getter-object-name
|
|
ChromeUtils.defineESModuleGetters(modules["windowglobal-in-root"], {
|
|
command: `${BASE_FOLDER}/windowglobal-in-root/command.sys.mjs`,
|
|
event: `${BASE_FOLDER}/windowglobal-in-root/event.sys.mjs`,
|
|
});
|
|
|
|
// eslint-disable-next-line mozilla/lazy-getter-object-name
|
|
ChromeUtils.defineESModuleGetters(modules["windowglobal-in-root"].vendor, {
|
|
vendored: `${BASE_FOLDER}/windowglobal-in-root/vendor/vendored.sys.mjs`,
|
|
});
|
|
|
|
// eslint-disable-next-line mozilla/lazy-getter-object-name
|
|
ChromeUtils.defineESModuleGetters(modules.windowglobal, {
|
|
command: `${BASE_FOLDER}/windowglobal/command.sys.mjs`,
|
|
commandwindowglobalonly: `${BASE_FOLDER}/windowglobal/commandwindowglobalonly.sys.mjs`,
|
|
event: `${BASE_FOLDER}/windowglobal/event.sys.mjs`,
|
|
eventemitter: `${BASE_FOLDER}/windowglobal/eventemitter.sys.mjs`,
|
|
eventemitterrelatedcontexts: `${BASE_FOLDER}/windowglobal/eventemitterrelatedcontexts.sys.mjs`,
|
|
eventnointercept: `${BASE_FOLDER}/windowglobal/eventnointercept.sys.mjs`,
|
|
eventonprefchange: `${BASE_FOLDER}/windowglobal/eventonprefchange.sys.mjs`,
|
|
retry: `${BASE_FOLDER}/windowglobal/retry.sys.mjs`,
|
|
sessiondataupdate: `${BASE_FOLDER}/windowglobal/sessiondataupdate.sys.mjs`,
|
|
timeout: `${BASE_FOLDER}/windowglobal/timeout.sys.mjs`,
|
|
windowglobaltoroot: `${BASE_FOLDER}/windowglobal/windowglobaltoroot.sys.mjs`,
|
|
});
|
|
|
|
// eslint-disable-next-line mozilla/lazy-getter-object-name
|
|
ChromeUtils.defineESModuleGetters(modules.windowglobal.vendor, {
|
|
vendored: `${BASE_FOLDER}/windowglobal/vendor/vendored.sys.mjs`,
|
|
});
|