Simplify, and tweak, a couple of PDFJSDev checks

This removes a couple of, thanks to preceeding code, unnecessary `typeof PDFJSDev` checks, and also fixes a couple of incorrectly implemented (my fault) checks intended for `TESTING` builds.
This commit is contained in:
Jonas Jenwald 2020-01-08 15:33:11 +01:00
parent 7322a24ce4
commit a39943554a
6 changed files with 11 additions and 11 deletions

View File

@ -1291,7 +1291,10 @@ var JpegImage = (function JpegImageClosure() {
}, },
getData({ width, height, forceRGB = false, isSourcePDF = false }) { getData({ width, height, forceRGB = false, isSourcePDF = false }) {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING && !LIB")) { if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
isSourcePDF === true, isSourcePDF === true,
'JpegImage.getData: Unexpected "isSourcePDF" value for PDF files.' 'JpegImage.getData: Unexpected "isSourcePDF" value for PDF files.'

View File

@ -1639,7 +1639,6 @@ const PDFWorker = (function PDFWorkerClosure() {
return worker.WorkerMessageHandler; return worker.WorkerMessageHandler;
} }
if ( if (
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("GENERIC") && PDFJSDev.test("GENERIC") &&
isNodeJS && isNodeJS &&
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef

View File

@ -53,7 +53,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
return new PDFNetworkStream(params); return new PDFNetworkStream(params);
}); });
} }
} else if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) { } else if (PDFJSDev.test("CHROME")) {
let PDFNetworkStream = require("./display/network.js").PDFNetworkStream; let PDFNetworkStream = require("./display/network.js").PDFNetworkStream;
let PDFFetchStream; let PDFFetchStream;
let isChromeWithFetchCredentials = function() { let isChromeWithFetchCredentials = function() {

View File

@ -51,10 +51,11 @@ function wrapReason(reason) {
(typeof reason === "object" && reason !== null), (typeof reason === "object" && reason !== null),
'wrapReason: Expected "reason" to be a (possibly cloned) Error.' 'wrapReason: Expected "reason" to be a (possibly cloned) Error.'
); );
} } else {
if (typeof reason !== "object" || reason === null) { if (typeof reason !== "object" || reason === null) {
return reason; return reason;
} }
}
switch (reason.name) { switch (reason.name) {
case "AbortException": case "AbortException":
return new AbortException(reason.message); return new AbortException(reason.message);

View File

@ -731,10 +731,7 @@ const PDFViewerApplication = {
if (key === "docBaseUrl" && !value) { if (key === "docBaseUrl" && !value) {
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) { if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
value = document.URL.split("#")[0]; value = document.URL.split("#")[0];
} else if ( } else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("MOZCENTRAL || CHROME")
) {
value = this.baseUrl; value = this.baseUrl;
} }
} }

View File

@ -745,7 +745,7 @@ function waitOnEventOrTimeout({ target, name, delay = 0 }) {
const animationStarted = new Promise(function(resolve) { const animationStarted = new Promise(function(resolve) {
if ( if (
typeof PDFJSDev !== "undefined" && typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("LIB") && PDFJSDev.test("LIB && TESTING") &&
typeof window === "undefined" typeof window === "undefined"
) { ) {
// Prevent "ReferenceError: window is not defined" errors when running the // Prevent "ReferenceError: window is not defined" errors when running the