diff --git a/src/core/annotation.js b/src/core/annotation.js index b3f53460d..8963a807c 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -797,10 +797,7 @@ class Annotation { * @param {Dict} borderStyle - The border style dictionary */ setBorderStyle(borderStyle) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert(this.rectangle, "setRectangle must have been called previously."); } @@ -1062,8 +1059,7 @@ class Annotation { */ reset() { if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING")) && + (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) && this.appearance && !this._streams.includes(this.appearance) ) { @@ -1161,10 +1157,7 @@ class AnnotationBorderStyle { * @param {Array} rect - The annotation `Rect` entry. */ setWidth(width, rect = [0, 0, 0, 0]) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( Array.isArray(rect) && rect.length === 4, "A valid `rect` parameter must be provided." @@ -2381,10 +2374,7 @@ class WidgetAnnotation extends Annotation { * @private */ _getSaveFieldResources(xref) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( this.data.defaultAppearanceData, "Expected `_defaultAppearanceData` to have been set." diff --git a/src/core/chunked_stream.js b/src/core/chunked_stream.js index 940c419a0..fae201f9c 100644 --- a/src/core/chunked_stream.js +++ b/src/core/chunked_stream.js @@ -295,10 +295,7 @@ class ChunkedStreamManager { resolve(chunkData); return; } - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( value instanceof ArrayBuffer, "readChunk (sendRequest) - expected an ArrayBuffer." diff --git a/src/core/colorspace.js b/src/core/colorspace.js index 145498461..640249e5e 100644 --- a/src/core/colorspace.js +++ b/src/core/colorspace.js @@ -140,10 +140,7 @@ class ColorSpace { comps, alpha01 ) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'ColorSpace.fillRgb: Unsupported "dest" type.' @@ -326,10 +323,7 @@ class ColorSpace { pdfFunctionFactory, localColorSpaceCache, }) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( !this.getCached(cs, xref, localColorSpaceCache), "Expected `ColorSpace.getCached` to have been manually checked " + @@ -551,10 +545,7 @@ class AlternateCS extends ColorSpace { } getRgbItem(src, srcOffset, dest, destOffset) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'AlternateCS.getRgbItem: Unsupported "dest" type.' @@ -566,10 +557,7 @@ class AlternateCS extends ColorSpace { } getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'AlternateCS.getRgbBuffer: Unsupported "dest" type.' @@ -656,10 +644,7 @@ class IndexedCS extends ColorSpace { } getRgbItem(src, srcOffset, dest, destOffset) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'IndexedCS.getRgbItem: Unsupported "dest" type.' @@ -671,10 +656,7 @@ class IndexedCS extends ColorSpace { } getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'IndexedCS.getRgbBuffer: Unsupported "dest" type.' @@ -721,10 +703,7 @@ class DeviceGrayCS extends ColorSpace { } getRgbItem(src, srcOffset, dest, destOffset) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'DeviceGrayCS.getRgbItem: Unsupported "dest" type.' @@ -735,10 +714,7 @@ class DeviceGrayCS extends ColorSpace { } getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'DeviceGrayCS.getRgbBuffer: Unsupported "dest" type.' @@ -770,10 +746,7 @@ class DeviceRgbCS extends ColorSpace { } getRgbItem(src, srcOffset, dest, destOffset) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'DeviceRgbCS.getRgbItem: Unsupported "dest" type.' @@ -785,10 +758,7 @@ class DeviceRgbCS extends ColorSpace { } getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'DeviceRgbCS.getRgbBuffer: Unsupported "dest" type.' @@ -894,10 +864,7 @@ const DeviceCmykCS = (function DeviceCmykCSClosure() { } getRgbItem(src, srcOffset, dest, destOffset) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'DeviceCmykCS.getRgbItem: Unsupported "dest" type.' @@ -907,10 +874,7 @@ const DeviceCmykCS = (function DeviceCmykCSClosure() { } getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'DeviceCmykCS.getRgbBuffer: Unsupported "dest" type.' @@ -1008,10 +972,7 @@ const CalGrayCS = (function CalGrayCSClosure() { } getRgbItem(src, srcOffset, dest, destOffset) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'CalGrayCS.getRgbItem: Unsupported "dest" type.' @@ -1021,10 +982,7 @@ const CalGrayCS = (function CalGrayCSClosure() { } getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'CalGrayCS.getRgbBuffer: Unsupported "dest" type.' @@ -1317,10 +1275,7 @@ const CalRGBCS = (function CalRGBCSClosure() { } getRgbItem(src, srcOffset, dest, destOffset) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'CalRGBCS.getRgbItem: Unsupported "dest" type.' @@ -1330,10 +1285,7 @@ const CalRGBCS = (function CalRGBCSClosure() { } getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'CalRGBCS.getRgbBuffer: Unsupported "dest" type.' @@ -1484,10 +1436,7 @@ const LabCS = (function LabCSClosure() { } getRgbItem(src, srcOffset, dest, destOffset) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'LabCS.getRgbItem: Unsupported "dest" type.' @@ -1497,10 +1446,7 @@ const LabCS = (function LabCSClosure() { } getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( dest instanceof Uint8ClampedArray, 'LabCS.getRgbBuffer: Unsupported "dest" type.' diff --git a/src/core/core_utils.js b/src/core/core_utils.js index 7a2121043..884e8a784 100644 --- a/src/core/core_utils.js +++ b/src/core/core_utils.js @@ -86,10 +86,7 @@ class XRefParseException extends BaseException { * @returns {Uint8Array} */ function arrayBuffersToBytes(arr) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { for (const item of arr) { assert( item instanceof ArrayBuffer, diff --git a/src/core/document.js b/src/core/document.js index 6e4ca7cff..41967960a 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -698,10 +698,7 @@ const EMPTY_FINGERPRINT = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; function find(stream, signature, limit = 1024, backwards = false) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert(limit > 0, 'The "limit" must be a positive integer.'); } const signatureLength = signature.length; @@ -755,10 +752,7 @@ function find(stream, signature, limit = 1024, backwards = false) { */ class PDFDocument { constructor(pdfManager, stream) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( stream instanceof BaseStream, 'PDFDocument: Invalid "stream" argument.' @@ -1419,10 +1413,7 @@ class PDFDocument { async _getLinearizationPage(pageIndex) { const { catalog, linearization, xref } = this; - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( linearization && linearization.pageFirst === pageIndex, "_getLinearizationPage - invalid pageIndex argument." diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 4354130dd..e322c9920 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -4508,10 +4508,7 @@ class TranslatedFont { * @private */ _removeType3ColorOperators(operatorList, fontBBoxSize = NaN) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( operatorList.fnArray[0] === OPS.setCharWidthAndBounds, "Type3 glyph shall start with the d1 operator." diff --git a/src/core/fonts.js b/src/core/fonts.js index 37b91682a..77ccc2a79 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -316,10 +316,7 @@ function int32(b0, b1, b2, b3) { } function string16(value) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( typeof value === "number" && Math.abs(value) < 2 ** 16, `string16: Unexpected input "${value}".` @@ -329,10 +326,7 @@ function string16(value) { } function safeString16(value) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( typeof value === "number" && !Number.isNaN(value), `safeString16: Unexpected input "${value}".` diff --git a/src/core/image.js b/src/core/image.js index e1382e8cc..8c014b936 100644 --- a/src/core/image.js +++ b/src/core/image.js @@ -564,10 +564,7 @@ class PDFImage { } fillOpacity(rgbaBuf, width, height, actualHeight, image) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( rgbaBuf instanceof Uint8ClampedArray, 'PDFImage.fillOpacity: Unsupported "rgbaBuf" type.' @@ -637,10 +634,7 @@ class PDFImage { } undoPreblend(buffer, width, height) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( buffer instanceof Uint8ClampedArray, 'PDFImage.undoPreblend: Unsupported "buffer" type.' @@ -893,10 +887,7 @@ class PDFImage { } fillGrayBuffer(buffer) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( buffer instanceof Uint8ClampedArray, 'PDFImage.fillGrayBuffer: Unsupported "buffer" type.' diff --git a/src/core/image_utils.js b/src/core/image_utils.js index f93729c29..629d62288 100644 --- a/src/core/image_utils.js +++ b/src/core/image_utils.js @@ -186,10 +186,7 @@ class GlobalImageCache { } constructor() { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( GlobalImageCache.NUM_PAGES_THRESHOLD > 1, "GlobalImageCache - invalid NUM_PAGES_THRESHOLD constant." diff --git a/src/core/jpg.js b/src/core/jpg.js index 841305d22..777aa145f 100644 --- a/src/core/jpg.js +++ b/src/core/jpg.js @@ -1528,10 +1528,7 @@ class JpegImage { forceRGB = false, isSourcePDF = false, }) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( isSourcePDF === true, 'JpegImage.getData: Unexpected "isSourcePDF" value for PDF files.' diff --git a/src/core/parser.js b/src/core/parser.js index 0b046adfc..aad5f3371 100644 --- a/src/core/parser.js +++ b/src/core/parser.js @@ -202,10 +202,7 @@ class Parser { } else if (state === 1) { state = ch === I ? 2 : 0; } else { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert(state === 2, "findDefaultInlineStreamEnd - invalid state."); } if (ch === SPACE || ch === LF || ch === CR) { diff --git a/src/core/primitives.js b/src/core/primitives.js index b23de90d2..af5824722 100644 --- a/src/core/primitives.js +++ b/src/core/primitives.js @@ -25,8 +25,7 @@ const Name = (function NameClosure() { class Name { constructor(name) { if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING")) && + (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) && typeof name !== "string" ) { unreachable('Name: The "name" must be a string.'); @@ -54,8 +53,7 @@ const Cmd = (function CmdClosure() { class Cmd { constructor(cmd) { if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING")) && + (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) && typeof cmd !== "string" ) { unreachable('Cmd: The "cmd" must be a string.'); @@ -103,8 +101,7 @@ class Dict { let value = this._map[key1]; if (value === undefined && key2 !== undefined) { if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING")) && + (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) && key2.length < key1.length ) { unreachable("Dict.get: Expected keys to be ordered by length."); @@ -112,8 +109,7 @@ class Dict { value = this._map[key2]; if (value === undefined && key3 !== undefined) { if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING")) && + (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) && key3.length < key2.length ) { unreachable("Dict.get: Expected keys to be ordered by length."); @@ -132,8 +128,7 @@ class Dict { let value = this._map[key1]; if (value === undefined && key2 !== undefined) { if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING")) && + (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) && key2.length < key1.length ) { unreachable("Dict.getAsync: Expected keys to be ordered by length."); @@ -141,8 +136,7 @@ class Dict { value = this._map[key2]; if (value === undefined && key3 !== undefined) { if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING")) && + (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) && key3.length < key2.length ) { unreachable("Dict.getAsync: Expected keys to be ordered by length."); @@ -161,8 +155,7 @@ class Dict { let value = this._map[key1]; if (value === undefined && key2 !== undefined) { if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING")) && + (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) && key2.length < key1.length ) { unreachable("Dict.getArray: Expected keys to be ordered by length."); @@ -170,8 +163,7 @@ class Dict { value = this._map[key2]; if (value === undefined && key3 !== undefined) { if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING")) && + (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) && key3.length < key2.length ) { unreachable("Dict.getArray: Expected keys to be ordered by length."); @@ -209,10 +201,7 @@ class Dict { } set(key, value) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { if (typeof key !== "string") { unreachable('Dict.set: The "key" must be a string.'); } else if (value === undefined) { @@ -325,8 +314,7 @@ const Ref = (function RefClosure() { class RefSet { constructor(parent = null) { if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING")) && + (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) && parent && !(parent instanceof RefSet) ) { @@ -405,10 +393,7 @@ function isDict(v, type) { } function isRefsEqual(v1, v2) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( v1 instanceof Ref && v2 instanceof Ref, "isRefsEqual: Both parameters should be `Ref`s." diff --git a/src/core/worker.js b/src/core/worker.js index 13a1af4e8..f3e0b74f4 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -309,10 +309,7 @@ class WorkerMessageHandler { cancelXHRs = null; return; } - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( value instanceof ArrayBuffer, "readChunk (getPdfManager) - expected an ArrayBuffer." diff --git a/src/core/xref.js b/src/core/xref.js index 8b4d1549b..0606f814a 100644 --- a/src/core/xref.js +++ b/src/core/xref.js @@ -873,10 +873,7 @@ class XRef { xrefEntry = parser.getObj(); } if (!(xrefEntry instanceof BaseStream)) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( xrefEntry !== undefined, 'fetchUncompressed: The "xrefEntry" cannot be undefined.' @@ -947,10 +944,7 @@ class XRef { const num = nums[i], entry = this.entries[num]; if (entry && entry.offset === tableOffset && entry.gen === i) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( obj !== undefined, 'fetchCompressed: The "obj" cannot be undefined.' diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index 27d44a405..25d747dc4 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -489,10 +489,7 @@ class AnnotationElement { * @returns {Array} An array of section elements. */ _renderQuadrilaterals(className) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert(this.quadrilaterals, "Missing quadrilaterals during rendering"); } diff --git a/src/display/api.js b/src/display/api.js index de5ad9e6c..7ae89b2a4 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -89,7 +89,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC") && isNodeJS) { } let createPDFNetworkStream; -if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) { +if (typeof PDFJSDev === "undefined") { const streamsPromise = Promise.all([ import("./network.js"), import("./fetch_stream.js"), @@ -1793,10 +1793,7 @@ class PDFPageProxy { * @private */ _pumpOperatorList({ renderingIntent, cacheKey, annotationStorageMap }) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( Number.isInteger(renderingIntent) && renderingIntent > 0, '_pumpOperatorList: Expected valid "renderingIntent" argument.' @@ -1863,10 +1860,7 @@ class PDFPageProxy { * @private */ _abortOperatorList({ intentState, reason, force = false }) { - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { assert( reason instanceof Error, '_abortOperatorList: Expected valid "reason" argument.' @@ -2133,7 +2127,7 @@ class PDFWorker { // Some versions of FF can't create a worker on localhost, see: // https://bugzilla.mozilla.org/show_bug.cgi?id=683280 const worker = - (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) && + typeof PDFJSDev === "undefined" && !workerSrc.endsWith("/build/pdf.worker.js") && !workerSrc.endsWith("/src/worker_loader.js") ? new Worker(workerSrc, { type: "module" }) @@ -2324,7 +2318,7 @@ class PDFWorker { // The worker was already loaded using e.g. a `