diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/server/tests/browser/browser_setup_in_parent.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/tests/browser/browser_setup_in_parent.js')
-rw-r--r-- | devtools/server/tests/browser/browser_setup_in_parent.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/devtools/server/tests/browser/browser_setup_in_parent.js b/devtools/server/tests/browser/browser_setup_in_parent.js new file mode 100644 index 0000000000..fa09cf6b6e --- /dev/null +++ b/devtools/server/tests/browser/browser_setup_in_parent.js @@ -0,0 +1,52 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const ACTOR_URL = + "chrome://mochitests/content/browser/devtools/server/tests/browser/test-setup-in-parent.js"; + +const { TestSetupInParentFront } = require(ACTOR_URL); + +add_task(async function() { + const browser = await addTab("data:text/html;charset=utf-8,foo"); + + info("Register target-scoped actor in the content process"); + await registerActorInContentProcess(ACTOR_URL, { + prefix: "testSetupInParent", + constructor: "TestSetupInParentActor", + type: { target: true }, + }); + + const tab = gBrowser.getTabForBrowser(browser); + const target = await TargetFactory.forTab(tab); + await target.attach(); + const { client } = target; + const form = target.targetForm; + + // As this Front isn't instantiated by protocol.js, we have to manually + // set its actor ID and manage it: + const front = new TestSetupInParentFront(client); + front.actorID = form.testSetupInParentActor; + front.manage(front); + + // Wait also for a reponse from setupInParent called from setup-in-child.js + const onDone = new Promise(resolve => { + const onParent = (_, topic, args) => { + Services.obs.removeObserver(onParent, "test:setupParent"); + args = JSON.parse(args); + + is(args[0], true, "Got `mm` argument, a message manager"); + ok(args[1].match(/server\d+.conn\d+.child\d+/), "Got `prefix` argument"); + + resolve(); + }; + Services.obs.addObserver(onParent, "test:setupParent"); + }); + + await front.callSetupInParent(); + await onDone; + + await target.destroy(); + gBrowser.removeCurrentTab(); +}); |