mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #9769 from Snuffleupagus/node-unittest-rm-console-errors
Reduce the amount of errors logged, primarily in Node.js/Travis, when running the unit-tests
This commit is contained in:
commit
8ce24744f2
7 changed files with 41 additions and 22 deletions
|
@ -574,9 +574,9 @@ var WorkerMessageHandler = {
|
|||
finishWorkerTask(task);
|
||||
pdfManager.updatePassword(data.password);
|
||||
pdfManagerReady();
|
||||
}).catch(function (ex) {
|
||||
}).catch(function (boundException) {
|
||||
finishWorkerTask(task);
|
||||
handler.send('PasswordException', ex);
|
||||
handler.send('PasswordException', boundException);
|
||||
}.bind(null, e));
|
||||
} else if (e instanceof InvalidPDFException) {
|
||||
handler.send('InvalidPDF', e);
|
||||
|
|
|
@ -274,7 +274,9 @@ function getDocument(src) {
|
|||
const NativeImageDecoderValues = Object.values(NativeImageDecoding);
|
||||
if (params.nativeImageDecoderSupport === undefined ||
|
||||
!NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
|
||||
params.nativeImageDecoderSupport = NativeImageDecoding.DECODE;
|
||||
params.nativeImageDecoderSupport =
|
||||
(apiCompatibilityParams.nativeImageDecoderSupport ||
|
||||
NativeImageDecoding.DECODE);
|
||||
}
|
||||
if (!Number.isInteger(params.maxImageSize)) {
|
||||
params.maxImageSize = -1;
|
||||
|
@ -283,7 +285,7 @@ function getDocument(src) {
|
|||
params.isEvalSupported = true;
|
||||
}
|
||||
if (typeof params.disableFontFace !== 'boolean') {
|
||||
params.disableFontFace = false;
|
||||
params.disableFontFace = apiCompatibilityParams.disableFontFace || false;
|
||||
}
|
||||
|
||||
if (typeof params.disableRange !== 'boolean') {
|
||||
|
@ -1786,7 +1788,11 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||
password,
|
||||
});
|
||||
};
|
||||
loadingTask.onPassword(updatePassword, exception.code);
|
||||
try {
|
||||
loadingTask.onPassword(updatePassword, exception.code);
|
||||
} catch (ex) {
|
||||
this._passwordCapability.reject(ex);
|
||||
}
|
||||
} else {
|
||||
this._passwordCapability.reject(
|
||||
new PasswordException(exception.message, exception.code));
|
||||
|
@ -2168,6 +2174,8 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||
disableStream: params.disableStream,
|
||||
disableAutoFetch: params.disableAutoFetch,
|
||||
disableCreateObjectURL: params.disableCreateObjectURL,
|
||||
disableFontFace: params.disableFontFace,
|
||||
nativeImageDecoderSupport: params.nativeImageDecoderSupport,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
let compatibilityParams = Object.create(null);
|
||||
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
||||
const isNodeJS = require('../shared/is_node');
|
||||
|
||||
const userAgent =
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent) || '';
|
||||
const isIE = /Trident/.test(userAgent);
|
||||
|
@ -42,9 +44,15 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
|||
compatibilityParams.disableStream = true;
|
||||
}
|
||||
})();
|
||||
}
|
||||
const apiCompatibilityParams = Object.freeze(compatibilityParams);
|
||||
|
||||
export {
|
||||
apiCompatibilityParams,
|
||||
};
|
||||
// Support: Node.js
|
||||
(function checkFontFaceAndImage() {
|
||||
// Node.js is missing native support for `@font-face` and `Image`.
|
||||
if (isNodeJS()) {
|
||||
compatibilityParams.disableFontFace = true;
|
||||
compatibilityParams.nativeImageDecoderSupport = 'none';
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
exports.apiCompatibilityParams = Object.freeze(compatibilityParams);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue