summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/unit/test_defineESModuleGetters_options_worker.js
blob: f1eab22d2b74585fd98a92328bf27afe7b9aa281 (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

add_task(async function testWorker() {
  let worker = new ChromeWorker("resource://test/lazy_non_shared_in_worker.js");
  let { promise, resolve } = Promise.withResolvers();
  worker.onmessage = event => {
    resolve(event.data);
  };
  worker.postMessage("");

  const result = await promise;

  Assert.ok(result.equal1);
  Assert.ok(result.equal2);
});

add_task(async function testSharedInWorker() {
  let worker = new ChromeWorker("resource://test/lazy_shared_in_worker.js");
  let { promise, resolve } = Promise.withResolvers();
  worker.onmessage = event => {
    resolve(event.data);
  };
  worker.postMessage("");

  const result = await promise;

  Assert.equal(result.caught1, true);
  Assert.equal(result.caught2, true);
  Assert.equal(result.caught3, true);
  Assert.equal(result.caught4, true);
});