summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/xpcshell/data/TestWorkerWatcherParent.jsm
blob: bf7836385cff6acbc67b3a85a99d9abd68b3f312 (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
"use strict";

var EXPORTED_SYMBOLS = ["TestWorkerWatcherParent"];

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}`);
    }
  }
}