summaryrefslogtreecommitdiffstats
path: root/dom/ipc/tests/JSProcessActor/browser_getActor_filter.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/ipc/tests/JSProcessActor/browser_getActor_filter.js')
-rw-r--r--dom/ipc/tests/JSProcessActor/browser_getActor_filter.js80
1 files changed, 80 insertions, 0 deletions
diff --git a/dom/ipc/tests/JSProcessActor/browser_getActor_filter.js b/dom/ipc/tests/JSProcessActor/browser_getActor_filter.js
new file mode 100644
index 0000000000..f79340fd89
--- /dev/null
+++ b/dom/ipc/tests/JSProcessActor/browser_getActor_filter.js
@@ -0,0 +1,80 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+declTest("getActor with remoteType match", {
+ remoteTypes: ["web"],
+
+ async test(browser) {
+ let parent = browser.browsingContext.currentWindowGlobal.domProcess;
+ ok(
+ parent.getActor("TestProcessActor"),
+ "JSProcessActorParent should have value."
+ );
+
+ await SpecialPowers.spawn(browser, [], async function () {
+ let child = ChromeUtils.domProcessChild;
+ ok(child, "DOMProcessChild should have value.");
+ ok(
+ child.getActor("TestProcessActor"),
+ "JSProcessActorChild should have value."
+ );
+ });
+ },
+});
+
+declTest("getActor with remoteType mismatch", {
+ remoteTypes: ["privilegedabout"],
+ url: TEST_URL,
+
+ async test(browser) {
+ let parent = browser.browsingContext.currentWindowGlobal.domProcess;
+ Assert.throws(
+ () => parent.getActor("TestProcessActor"),
+ /NotSupportedError/,
+ "Should throw if its remoteTypes don't match."
+ );
+
+ await SpecialPowers.spawn(browser, [], async function () {
+ let child = ChromeUtils.domProcessChild;
+ ok(child, "DOMProcessChild should have value.");
+ Assert.throws(
+ () => child.getActor("TestProcessActor"),
+ /NotSupportedError/,
+ "Should throw if its remoteTypes don't match."
+ );
+ });
+ },
+});
+
+declTest("getActor without includeParent", {
+ includeParent: false,
+
+ async test(_browser, win) {
+ let parent = win.docShell.browsingContext.currentWindowGlobal.domProcess;
+ SimpleTest.doesThrow(
+ () => parent.getActor("TestProcessActor"),
+ "Should throw if includeParent is false."
+ );
+
+ let child = ChromeUtils.domProcessChild;
+ SimpleTest.doesThrow(
+ () => child.getActor("TestProcessActor"),
+ "Should throw if includeParent is false."
+ );
+ },
+});
+
+declTest("getActor with includeParent", {
+ includeParent: true,
+
+ async test(_browser, win) {
+ let parent = win.docShell.browsingContext.currentWindowGlobal.domProcess;
+ let actorParent = parent.getActor("TestProcessActor");
+ ok(actorParent, "JSProcessActorParent should have value.");
+
+ let child = ChromeUtils.domProcessChild;
+ let actorChild = child.getActor("TestProcessActor");
+ ok(actorChild, "JSProcessActorChild should have value.");
+ },
+});