1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Add a TESTING build option, to enable using non-production/test-only code-paths

Since the tests (currently) run with the `pdf.worker.js` file built, i.e. with `PRODUCTION = true` set, there's no simple way to add e.g. `assert` calls for both non-production *and* test-only builds without also affecting PRODUCTION builds.
This commit is contained in:
Jonas Jenwald 2018-06-11 17:25:50 +02:00
parent f01e54eae1
commit 4b69bb7fe9
3 changed files with 24 additions and 12 deletions

View file

@ -34,8 +34,10 @@ const MAX_ADLER32_LENGTH = 5552;
function computeAdler32(bytes) {
let bytesLength = bytes.length;
if (bytesLength >= MAX_ADLER32_LENGTH) {
throw new Error('computeAdler32: The input is too large.');
if (typeof PDFJSDev === 'undefined' ||
PDFJSDev.test('!PRODUCTION || TESTING')) {
assert(bytesLength < MAX_ADLER32_LENGTH,
'computeAdler32: Unsupported "bytes" length.');
}
let a = 1, b = 0;
for (let i = 0; i < bytesLength; ++i) {