summaryrefslogtreecommitdiffstats
path: root/dom/ipc/tests/JSProcessActor/browser_getActor_filter.js
blob: f79340fd89d800a46efbd6be9ca4df60a7d7d7f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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.");
  },
});