summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/xpcshell/data/TestWorkerWatcherParent.sys.mjs
blob: a9d919f1ed7ca9d49d75aa759a584e3b68af839b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
export class TestWorkerWatcherParent extends JSProcessActorParent {
  constructor() {
    super();
    // This is set by the test helper that does use these process actors.
    this.eventEmitter = null;
  }

  receiveMessage(msg) {
    switch (msg.name) {
      case "Test:WorkerSpawned":
        this.eventEmitter?.emit("worker-spawned", msg.data);
        break;
      case "Test:WorkerTerminated":
        this.eventEmitter?.emit("worker-terminated", msg.data);
        break;
      default:
        throw new Error(`Unexpected message received: ${msg.name}`);
    }
  }
}