From a03b383edb24b146db271f44f470434618889146 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 7 Nov 2020 19:00:33 +0100 Subject: [PATCH] Fail early, in modern `GENERIC` builds, if `globalThis` isn't available (PR 11799 follow-up, issue 12596) It probably doesn't hurt to explicitly check for `globalThis` as well, in addition to the existing checks. --- src/core/worker.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/worker.js b/src/core/worker.js index 7dee0f195d67f..b3b204fe21e75 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -143,13 +143,14 @@ class WorkerMessageHandler { // `ReadableStream` and `Promise.allSettled`). if ( (typeof PDFJSDev === "undefined" || PDFJSDev.test("SKIP_BABEL")) && - (typeof ReadableStream === "undefined" || + (typeof globalThis === "undefined" || + typeof ReadableStream === "undefined" || typeof Promise.allSettled === "undefined") ) { throw new Error( "The browser/environment lacks native support for critical " + - "functionality used by the PDF.js library (e.g. " + - "`ReadableStream` and/or `Promise.allSettled`); " + + "functionality used by the PDF.js library (e.g. `globalThis`, " + + "`ReadableStream`, and/or `Promise.allSettled`); " + "please use an ES5-compatible build instead." ); }