1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #16305 from Snuffleupagus/PDFJSDev-skip-PRODUCTION

Remove the `PRODUCTION` build-target
This commit is contained in:
Tim van der Meij 2023-04-22 14:53:30 +02:00 committed by GitHub
commit c9359957e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 89 additions and 269 deletions

View file

@ -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."

View file

@ -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."

View file

@ -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.'

View file

@ -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,

View file

@ -705,10 +705,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;
@ -762,10 +759,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.'
@ -1426,10 +1420,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."

View file

@ -4529,10 +4529,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."

View file

@ -296,10 +296,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}".`
@ -309,10 +306,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}".`

View file

@ -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.'

View file

@ -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."

View file

@ -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.'

View file

@ -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) {

View file

@ -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."

View file

@ -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."

View file

@ -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.'

View file

@ -489,10 +489,7 @@ class AnnotationElement {
* @returns {Array<HTMLElement>} 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");
}

View file

@ -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"),
@ -1799,10 +1799,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.'
@ -1869,10 +1866,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.'
@ -2139,7 +2133,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" })
@ -2330,7 +2324,7 @@ class PDFWorker {
// The worker was already loaded using e.g. a `<script>` tag.
return mainWorkerMessageHandler;
}
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
if (typeof PDFJSDev === "undefined") {
const worker = await import("pdfjs/pdf.worker.js");
return worker.WorkerMessageHandler;
}

View file

@ -85,10 +85,7 @@ class FreeTextEditor extends AnnotationEditor {
const style = getComputedStyle(document.documentElement);
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
const lineHeight = parseFloat(
style.getPropertyValue("--freetext-line-height")
);

View file

@ -32,7 +32,7 @@ class FontLoader {
this.nativeFontFaces = [];
this.styleElement =
typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || TESTING")
typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")
? styleElement
: null;
@ -116,10 +116,7 @@ class FontLoader {
get isFontLoadingAPISupported() {
const hasFonts = !!this._document?.fonts;
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
return shadow(
this,
"isFontLoadingAPISupported",

View file

@ -27,10 +27,7 @@ function validateRangeRequestCapabilities({
rangeChunkSize,
disableRange,
}) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
Number.isInteger(rangeChunkSize) && rangeChunkSize > 0,
"rangeChunkSize must be an integer larger than zero."

View file

@ -34,10 +34,7 @@ let SVGGraphics = class {
}
};
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
const SVG_DEFAULTS = {
fontStyle: "normal",
fontWeight: "normal",

View file

@ -55,12 +55,12 @@ class Sandbox {
}
create(data) {
if (PDFJSDev.test("!PRODUCTION || TESTING")) {
if (PDFJSDev.test("TESTING")) {
this._module.ccall("nukeSandbox", null, []);
}
const code = [PDFJSDev.eval("PDF_SCRIPTING_JS_SOURCE")];
if (PDFJSDev.test("!PRODUCTION || TESTING")) {
if (PDFJSDev.test("TESTING")) {
code.push(
`globalThis.sendResultForTesting = callExternalFunction.bind(null, "send");`
);
@ -122,7 +122,7 @@ class Sandbox {
}
evalForTesting(code, key) {
if (PDFJSDev.test("!PRODUCTION || TESTING")) {
if (PDFJSDev.test("TESTING")) {
this._module.ccall(
"evalInSandbox",
null,

View file

@ -149,10 +149,7 @@ class MessageHandler {
}
on(actionName, handler) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
typeof handler === "function",
'MessageHandler.on: Expected "handler" to be a function.'

View file

@ -452,10 +452,7 @@ function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
}
function shadow(obj, prop, value, nonSerializable = false) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
prop in obj,
`shadow: Property "${prop && prop.toString()}" not found in object.`
@ -574,10 +571,7 @@ function stringToBytes(str) {
}
function string32(value) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
typeof value === "number" && Math.abs(value) < 2 ** 32,
`string32: Unexpected input "${value}".`