mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Ensure that the PDFDocumentLoadingTask
is rejected when "setting up fake worker" failed (issue 10135)
This should, hopefully, cover all the possible ways[1] in which "fake workers" are loaded. Given the different code-paths, adding unit-tests might not be that simple. Note that in order to make this work, the various `fakeWorkerFilesLoader` functions were converted to return `Promises`. --- [1] Unfortunately there's lots of them, for various build targets and configurations.
This commit is contained in:
parent
d4469da22b
commit
755c6edc5e
2 changed files with 55 additions and 29 deletions
14
web/app.js
14
web/app.js
|
@ -263,7 +263,9 @@ let PDFViewerApplication = {
|
|||
AppOptions.set('locale', hashParams['locale']);
|
||||
}
|
||||
|
||||
return Promise.all(waitOn);
|
||||
return Promise.all(waitOn).catch((reason) => {
|
||||
console.error(`_parseHashParameters: "${reason.message}".`);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1464,10 +1466,14 @@ function loadFakeWorker() {
|
|||
SystemJS.import('pdfjs/core/worker').then((worker) => {
|
||||
window.pdfjsWorker = worker;
|
||||
resolve();
|
||||
});
|
||||
}).catch(reject);
|
||||
} else if (typeof require === 'function') {
|
||||
window.pdfjsWorker = require('../src/core/worker.js');
|
||||
resolve();
|
||||
try {
|
||||
window.pdfjsWorker = require('../src/core/worker.js');
|
||||
resolve();
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
}
|
||||
} else {
|
||||
reject(new Error(
|
||||
'SystemJS or CommonJS must be used to load fake worker.'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue