Repository navigation
Conversation
The modern pdf.js build requires Map and WeakMap upsert methods (getOrInsert and getOrInsertComputed) that Firefox ships from version 144 on, so the viewer failed to initialize on Firefox ESR 140, the current enterprise ESR release, even though Firefox ESR is part of the browser targets of @nextcloud/browserslist-config. A small polyfill module now defines the four methods when missing. It is loaded as the first module script in the viewer page, so every pdf.js context of the page is covered, and the same source is prepended to the vendored worker file at build time, as the worker runs in its own context. The pdf.sandbox module needs no shim: it only feeds an embedded source string to its own QuickJS engine. The modern pdf.js artifacts themselves stay byte-identical to the upstream release, so nothing changes for engines that ship the methods natively. The test suite covers the shim semantics, the byte-identity of the untouched artifacts, the worker prepend, and fails when the vendored pdf.js calls a new collection builtin that is neither polyfilled nor old enough for the supported browsers. Fixes nextcloud#1616 Assisted-by: opencode (zai/glm-5.3) Signed-off-by: WSHAPER <42714629+WSHAPER@users.noreply.github.com>
WSHAPER
force-pushed
the
fix/esr140-legacy-pdfjs
branch
from
November 5, 2026 13:37
6680907 to
38f516f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1616
The modern pdf.js build calls the Map and WeakMap upsert methods (
getOrInsert,getOrInsertComputed) that Firefox ships from version 144 on, so the viewer failed to initialize on Firefox ESR 140, the current enterprise ESR release, which is part of the browser targets of@nextcloud/browserslist-config.Instead of changing which pdf.js build is shipped, a small module now defines the four methods when the engine lacks them:
The modern pdf.js artifacts themselves stay byte-identical to the upstream release, so the served pdf.js code, its security posture and its printing behavior are unchanged; on engines with native support the polyfill stays completely idle.
The suite covers the shim semantics, asserts the byte-identity of the untouched artifacts and the exact worker prepend, and fails if the vendored pdf.js ever calls a collection builtin that is neither polyfilled nor old enough for the supported browsers.
Testing:
npm run test(39 passed),npm run lint,npm run stylelint,npm run buildall green.This change was prepared with AI assistance (opencode, zai/glm-5.3) and reviewed by the contributor.