test_defineESModuleGetters_options_worker.js (981B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 add_task(async function testWorker() { 6 let worker = new ChromeWorker("resource://test/lazy_non_shared_in_worker.js"); 7 let { promise, resolve } = Promise.withResolvers(); 8 worker.onmessage = event => { 9 resolve(event.data); 10 }; 11 worker.postMessage(""); 12 13 const result = await promise; 14 15 Assert.ok(result.equal1); 16 Assert.ok(result.equal2); 17 }); 18 19 add_task(async function testSharedInWorker() { 20 let worker = new ChromeWorker("resource://test/lazy_shared_in_worker.js"); 21 let { promise, resolve } = Promise.withResolvers(); 22 worker.onmessage = event => { 23 resolve(event.data); 24 }; 25 worker.postMessage(""); 26 27 const result = await promise; 28 29 Assert.equal(result.caught1, true); 30 Assert.equal(result.caught2, true); 31 Assert.equal(result.caught3, true); 32 });