diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /remote/shared/messagehandler/test/browser/browser_windowglobal_to_root.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'remote/shared/messagehandler/test/browser/browser_windowglobal_to_root.js')
-rw-r--r-- | remote/shared/messagehandler/test/browser/browser_windowglobal_to_root.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/remote/shared/messagehandler/test/browser/browser_windowglobal_to_root.js b/remote/shared/messagehandler/test/browser/browser_windowglobal_to_root.js new file mode 100644 index 0000000000..57629e5485 --- /dev/null +++ b/remote/shared/messagehandler/test/browser/browser_windowglobal_to_root.js @@ -0,0 +1,47 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const { RootMessageHandler } = ChromeUtils.importESModule( + "chrome://remote/content/shared/messagehandler/RootMessageHandler.sys.mjs" +); + +add_task(async function test_windowGlobal_to_root_command() { + // Navigate to a page to make sure that the windowglobal modules run in a + // different process than the root module. + const tab = BrowserTestUtils.addTab( + gBrowser, + "https://example.com/document-builder.sjs?html=tab" + ); + await BrowserTestUtils.browserLoaded(tab.linkedBrowser); + const browsingContextId = tab.linkedBrowser.browsingContext.id; + + const rootMessageHandler = createRootMessageHandler( + "session-id-windowglobal-to-rootModule" + ); + + for (const commandName of [ + "testHandleCommandToRoot", + "testSendRootCommand", + ]) { + const valueFromRoot = await rootMessageHandler.handleCommand({ + moduleName: "windowglobaltoroot", + commandName, + destination: { + type: WindowGlobalMessageHandler.type, + id: browsingContextId, + }, + }); + + is( + valueFromRoot, + "root-value-called-from-windowglobal", + "Retrieved the expected value from windowglobaltoroot using " + + commandName + ); + } + + rootMessageHandler.destroy(); + gBrowser.removeTab(tab); +}); |