summaryrefslogtreecommitdiffstats
path: root/remote/shared/messagehandler/test/browser/resources/modules/ModuleRegistry.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /remote/shared/messagehandler/test/browser/resources/modules/ModuleRegistry.sys.mjs
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'remote/shared/messagehandler/test/browser/resources/modules/ModuleRegistry.sys.mjs')
-rw-r--r--remote/shared/messagehandler/test/browser/resources/modules/ModuleRegistry.sys.mjs30
1 files changed, 30 insertions, 0 deletions
diff --git a/remote/shared/messagehandler/test/browser/resources/modules/ModuleRegistry.sys.mjs b/remote/shared/messagehandler/test/browser/resources/modules/ModuleRegistry.sys.mjs
new file mode 100644
index 0000000000..e5d9c38719
--- /dev/null
+++ b/remote/shared/messagehandler/test/browser/resources/modules/ModuleRegistry.sys.mjs
@@ -0,0 +1,30 @@
+/* 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/. */
+
+/**
+ * Retrieve the WebDriver BiDi module class matching the provided module name
+ * and folder.
+ *
+ * @param {String} moduleName
+ * The name of the module to get the class for.
+ * @param {String} moduleFolder
+ * A valid folder name for modules.
+ * @return {Class=}
+ * The class corresponding to the module name and folder, null if no match
+ * was found.
+ * @throws {Error}
+ * If the provided module folder is unexpected.
+ **/
+export const getModuleClass = function(moduleName, moduleFolder) {
+ const root = `chrome://mochitests/content/browser/remote/shared/messagehandler/test/`;
+ const path = `${root}browser/resources/modules/${moduleFolder}/${moduleName}.sys.mjs`;
+ try {
+ return ChromeUtils.importESModule(path)[moduleName];
+ } catch (e) {
+ if (e.result == Cr.NS_ERROR_FILE_NOT_FOUND) {
+ return null;
+ }
+ throw e;
+ }
+};