mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-18 14:19:15 +00:00
Throw in openpgp.initWorker if worker failed to load
This commit is contained in:
@@ -37,7 +37,11 @@ let pubKey;
|
||||
tryTests('Async Proxy', tests, {
|
||||
if: typeof window !== 'undefined' && window.Worker && window.MessageChannel,
|
||||
before: async function() {
|
||||
await openpgp.initWorker({ path:'../dist/openpgp.worker.js' });
|
||||
try {
|
||||
await openpgp.initWorker({ path:'../dist/openpgp.worker.js' });
|
||||
} catch (e) {
|
||||
openpgp.util.print_debug_error(e);
|
||||
}
|
||||
pubKey = (await openpgp.key.readArmored(pub_key)).keys[0];
|
||||
},
|
||||
after: async function() {
|
||||
@@ -50,11 +54,14 @@ function tests() {
|
||||
describe('Random number pipeline', function() {
|
||||
it('Random number buffer automatically reseeded', async function() {
|
||||
const worker = new Worker('../dist/openpgp.worker.js');
|
||||
const wProxy = new openpgp.AsyncProxy({ path:'../dist/openpgp.worker.js', workers: [worker] });
|
||||
const loaded = await wProxy.loaded();
|
||||
if (loaded) {
|
||||
return wProxy.delegate('encrypt', { publicKeys:[pubKey], message:openpgp.message.fromText(plaintext) });
|
||||
const wProxy = new openpgp.AsyncProxy();
|
||||
try {
|
||||
await wProxy.init({ path:'../dist/openpgp.worker.js', workers: [worker] });
|
||||
} catch (e) {
|
||||
openpgp.util.print_debug_error(e);
|
||||
return;
|
||||
}
|
||||
return wProxy.delegate('encrypt', { publicKeys:[pubKey], message:openpgp.message.fromText(plaintext) });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user