22576 Commits

Author SHA1 Message Date
Jonas Jenwald
8fc56772e8 A couple of small tweaks of the getPdfFilenameFromUrl helper
- Shorten the `getURL` function slightly, by re-factoring the try-catch blocks.
 - Change how the `decode` function looks for a decoded ".pdf" name, to skip the regular expression matching when it's not needed and to allow re-using the already defined `pdfRegex`.
2026-05-05 12:16:57 +02:00
Tim van der Meij
a55cec4a0f
Merge pull request #21216 from Snuffleupagus/CFFCharset-rm-raw
Remove the unused `raw` field from the `CFFCharset` class
2026-05-03 19:31:04 +02:00
Jonas Jenwald
53fd89682c Remove the unused raw field from the CFFCharset class
This was necessary before charset compilation was implemented, however that's been supported for many years and this is just dead code now.
 - PR 9340, back in 2018, stopped using the `raw` field.
 - PR 10591, back in 2019, implemented proper charset compilation.
2026-05-03 18:51:24 +02:00
Tim van der Meij
f54f4b606d
Merge pull request #21215 from Snuffleupagus/compileFDSelect-TypedArray-set
Replace a loop with `TypedArray.prototype.set()` in the `compileFDSelect` method
2026-05-03 18:30:18 +02:00
Jonas Jenwald
027671e6dc Replace a loop with TypedArray.prototype.set() in the compileFDSelect method
Given that the `fdSelect.fdSelect` data is a regular Array, this code can simplified a tiny bit.
2026-05-03 16:32:48 +02:00
Tim van der Meij
c196fa8196
Merge pull request #21214 from Snuffleupagus/CFFFont-improvements
Remove the `CompilerOutput.prototype.finalData` getter, and a few other font improvements (PR 21053 follow-up)
2026-05-03 16:07:22 +02:00
Jonas Jenwald
e5e82b9617 Don't create a DataView for the "CFF " TrueType table in readTableEntry
Given that the "CFF " table may be replaced completely, during font-parsing, it shouldn't make sense to read and/or modify it piecewise.
2026-05-03 13:17:23 +02:00
Jonas Jenwald
b65eedc636 Set the correct data if compilation fails in the CFFFont constructor
The `CFFFont.prototype.data` should contain a `Uint8Array`, however if compilation failed it was being set to a `Stream` instance which will thus fail elsewhere in the font-code.

*Please note:* This was found by code inspection, since I don't have a PDF document that's fixed by this change.
2026-05-03 13:17:18 +02:00
Jonas Jenwald
521f4dc554 Remove the CompilerOutput.prototype.finalData getter (PR 21053 follow-up)
Return the data as-is from the `CFFCompiler.prototype.compile` method, rather than making a copy of it first.
The reason that it was implemented this way in PR 21053 was to avoid keeping a potentially large `ArrayBuffer` alive, see https://github.com/mozilla/pdf.js/pull/21053#discussion_r3045402988

Having traced all the call-sites in the font-code that directly or indirectly invoke that code, I've now managed to conclude that the compiled CFF-data is never stored on the `Font` instance and using the data as-is thus shouldn't increase permanent memory usage.
2026-05-03 13:13:50 +02:00
Tim van der Meij
6d5e8696c4
Merge pull request #21211 from Snuffleupagus/JpxStream-rm-params
Don't provide unused /DecodeParms when initializing `JpxStream`
2026-05-02 14:11:36 +02:00
Tim van der Meij
ccf9e03e18
Merge pull request #21210 from timvandermeij/unit-test-optimize-find
Optimize runtime of the find controller unit tests
2026-05-02 14:10:38 +02:00
Jonas Jenwald
a8715f6f96 Don't provide unused /DecodeParms when initializing JpxStream 2026-05-02 12:20:28 +02:00
Tim van der Meij
038ca33f8e
Optimize runtime of the find controller unit tests
The find controller tests consistently show up in the list of slowest
tests reported by Jasmine. Profiling shows that most of the time is
spent waiting for the find results to arrive, even though the find
command itself is quite fast.

It turns out that the slowdown occurs between receiving the `find` event
and actually triggering the search. The find controller has a hardcoded
delay of 250 milliseconds built in, which was introduced for viewer
performance many years ago because otherwise every keystroke would
trigger a search even though the user's query was not complete yet.

For the unit tests we don't need this delay because, contrary to the
viewer use case, we don't have to account for user interaction and
instead dispatch complete `find` events on the event bus ourselves.
However, since the unit tests were introduced well over a year after
the delay was introduced, due to an oversight it was never made
configurable so we could skip it for the unit tests.

This commit fixes the issue, which locally results in the runtime of
`npx gulp unittest --noChrome` dropping from 39.991 seconds before this
patch to 29.116 seconds afterwards, which is a 27% speedup.
2026-05-01 19:31:13 +02:00
Jonas Jenwald
091b172a22
Merge pull request #21209 from Snuffleupagus/version-6.0
Bump library version to `6.0`
2026-05-01 13:26:22 +02:00
Jonas Jenwald
2c445a2bc1 Bump library version to 6.0
See commit e6e06cf6b5307fe39e0de69c6c884f816b0cb21b
2026-05-01 13:12:29 +02:00
Jonas Jenwald
8142937ac4
Merge pull request #20961 from calixteman/use_image_decoder_chrome
[api-minor] Use the ImageDecoder by default on Chrome
2026-05-01 13:09:43 +02:00
Tim van der Meij
e6e06cf6b5
Merge pull request #21152 from Snuffleupagus/update-supported
[api-major] Update the minimum supported browsers, and remove no longer needed polyfills
2026-05-01 12:07:45 +02:00
Tim van der Meij
330ab4d066
Merge pull request #21208 from mozilla/update-locales
l10n: Update locale files
2026-05-01 12:04:06 +02:00
github-actions[bot]
35429af43e l10n: Update locale files 2026-05-01 00:48:41 +00:00
Jonas Jenwald
270b68feb9 [api-major] Update the minimum supported browsers, and remove no longer needed polyfills
By removing support for older browsers it's possible to simplify both the code and the build-scripts, in addition to removing manually implemented polyfills.
Using the PDF.js library/viewer will now require native support for the following features:
 - The `AbortSignal.any()` static method, see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static#browser_compatibility
 - The `:dir()` CSS pseudo-class, see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:dir#browser_compatibility
 - The `light-dark()` CSS function, see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color_value/light-dark#browser_compatibility
 - The CSS `&` nesting selector, see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Nesting_selector#browser_compatibility

This patch updates the minimum supported browsers as follows:
 - Google Chrome 125, which was released on 2024-05-15; see https://chromereleases.googleblog.com/2024/05/stable-channel-update-for-desktop_15.html
 - Safari 18, which was released on 2024-09-16; see https://developer.apple.com/documentation/safari-release-notes/safari-18-release-notes
   *Note:* This version is the first with experimental support for the `CanvasRenderingContext2D.filter` property, which is a long-standing missing feature in Safari, however it must be *manually enabled*; see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter#browser_compatibility

Note that nowadays we usually try, where feasible and possible, to support browsers that are about two years old. By limiting support to only "recent" browsers we reduce the risk of holding back improvements of the *built-in* Firefox PDF Viewer, and also (significantly) reduce the maintenance/support burden for the PDF.js contributors.

*Please note:* As always, the minimum supported browser version assumes that a `legacy`-build of the PDF.js library is being used; see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
2026-04-30 20:32:08 +02:00
calixteman
7ebf3a4d7c
Merge pull request #21196 from calixteman/bug2035530
Fix free highlight on pages without images (bug 2035530)
2026-04-30 19:34:02 +02:00
calixteman
4d91026178
Merge pull request #21207 from Snuffleupagus/unittest-11878-reduced
Use a reduced test-case for the "caches image resources at the document/page level as expected (issue 11878)" unit-test
2026-04-30 19:33:12 +02:00
Jonas Jenwald
3eef724d15 Use a reduced test-case for the "caches image resources at the document/page level as expected (issue 11878)" unit-test 2026-04-30 18:47:42 +02:00
Tim van der Meij
468d38e17c
Merge pull request #21206 from Snuffleupagus/unittest-11878-hash
Improve performance of the "caches image resources at the document/page level as expected (issue 11878)" unit-test
2026-04-30 16:19:59 +02:00
Jonas Jenwald
c5296986fa Improve performance of the "caches image resources at the document/page level as expected (issue 11878)" unit-test
Compare `Uint32Array`s of the image-data, since that's more efficient than comparing the `Uint8ClampedArray`s directly.
2026-04-30 16:09:56 +02:00
calixteman
1ebaa03b25
Merge pull request #21192 from calixteman/colored_logs
Add some colors in the logs in order to easily see failures and add a summary of the failures at the end
2026-04-30 14:50:20 +02:00
Tim van der Meij
87e5241ed3
Merge pull request #21203 from timvandermeij/unit-test-obsolete-pdfbug
Remove obsolete `pdfBug: true` flag in the image caching unit test
2026-04-30 14:28:39 +02:00
Tim van der Meij
55e0f7e97f
Remove obsolete pdfBug: true flag in the image caching unit test
In a previous commit the time-based checks, which were based on
statistics provided by the `pdfBug: true` flag, got replaced by
test-only property checks that don't use said statistics anymore.

Fixes b01eeaf8.
2026-04-30 14:07:39 +02:00
Calixte Denizet
46fd67a191
Add some colors in the logs in order to easily see failures and add a summary of the failures at the end 2026-04-30 14:00:54 +02:00
Tim van der Meij
8f170307ed
Merge pull request #21195 from timvandermeij/unit-test-optimizations
Optimize memory usage in the unit tests
2026-04-30 12:59:58 +02:00
Jonas Jenwald
adf07ea51c
Merge pull request #21200 from Snuffleupagus/Intersector-grid-push
Shorten how intersectors are added to the grid in the `Intersector` constructor
2026-04-30 12:56:38 +02:00
Tim van der Meij
232506f4e8
Optimize memory usage in the unit tests
This commit fixes a number of missing cleanup steps in the unit tests
that kept state alive for longer than necessary:

- the loading tasks were not all being destroyed;
- the find controllers were not being reset;
- the state set in `beforeAll`/`beforeEach` was not all being nulled in
  the correspoding `afterAll`/`afterEach` blocks.

Combined this resulted in a steady increase in memory usage of the test
process as the tests ran, climbing up to ~1.5 GB. After this patch the
memory usage remains stable at ~800 MB.
2026-04-30 12:35:59 +02:00
Tim van der Meij
b71be8a501
Merge pull request #21198 from Snuffleupagus/DecryptStream-nextChunk
Simplify the `nextChunk` handling in the `DecryptStream` class
2026-04-30 12:23:18 +02:00
Jonas Jenwald
4a5c455c0b Shorten how intersectors are added to the grid in the Intersector constructor
Thanks to modern JavaScript features this code can be simplified a tiny bit.
2026-04-30 12:06:08 +02:00
Jonas Jenwald
f26b98c7c4 Simplify the nextChunk handling in the DecryptStream class
This is old code, that can be simplified a tiny bit with modern JavaScript features.
2026-04-30 11:40:34 +02:00
calixteman
d92db130da
Merge pull request #21186 from timvandermeij/reorganize-pages-intermittents
Wait for the first page to be ready in the reorganize pages integration tests
2026-04-30 09:01:26 +02:00
calixteman
ac63d851b8
Merge pull request #21197 from Snuffleupagus/find-#extractText-more-await
Improve error handling in the `PDFFindController.prototype.#extractText` method
2026-04-30 08:57:29 +02:00
Jonas Jenwald
aa08b02a5b Avoid setting page-content for a previous document in the PDFFindController.prototype.#extractText method
Given that all of the relevant API methods are asynchronous it's possible, although quite unlikely, that the existing "is the document active" check won't catch all situations where the document was closed in the middle of searching.
2026-04-29 22:39:53 +02:00
Jonas Jenwald
a6e2a42df1 Improve error handling in the PDFFindController.prototype.#extractText method
This handles *all* errors correctly, if e.g. the document is closed in the middle of searching.
Also, replacing the "promise chains" with more `await` helps simplify the code a little bit.
2026-04-29 22:39:51 +02:00
Calixte Denizet
e7ec356be0
Fix free highlight on pages without images (bug 2035530) 2026-04-29 19:24:35 +02:00
Tim van der Meij
34c3ee16f8
Merge pull request #21194 from calixteman/improve_codecov
Slighty improve codecov stuff in gh actions
2026-04-29 17:04:14 +02:00
Calixte Denizet
c91fa7e2dd
Slighty improve codecov stuff in gh actions
disable_search == true, will avoid useless search especially because we already provide the path to the info file.
disable_telem == true, disable sending telemetry to codecov.
2026-04-29 16:48:46 +02:00
Tim van der Meij
2979253338
Merge pull request #21193 from calixteman/fix_intermittent_hangul
Fix the intermittent test failure 'performs a search in a text containing some Hangul syllables'
2026-04-29 15:50:49 +02:00
Calixte Denizet
9a247e51b4
Fix the intermittent test failure 'performs a search in a text containing some Hangul syllables'
The patch cb8055f0a changed the worker source so just set it as it was.
2026-04-29 15:36:22 +02:00
Tim van der Meij
eb97e6b2b1
Merge pull request #21191 from timvandermeij/unittestcli-merge
Move `unittestcli` coverage collection to `ci.yml`
2026-04-29 15:02:24 +02:00
Tim van der Meij
3d8a3f09c5
Move unittestcli coverage collection to ci.yml
Originally we introduced a separate `coverage.yml` workflow to
test-drive coverage collection without immediately introducing it inline
in the `ci.yml` workflow. However, now that coverage collection works
nicely and is performant enough we can simplify the workflow definitions
by removing `coverage.yml` entirely in favor of simply inlining coverage
collection into the existing `unittestcli` run in `ci.yml`. Doing so
also avoids having to a full extra `unittestcli` run just to collect
coverage information.

Moreover, this commit aligns coverage collection flags with the ones in
the other workflows to be more explicit and consistent.
2026-04-29 14:43:01 +02:00
Tim van der Meij
4021d57153
Wait for the first page to be ready in the reorganize pages integration tests
The thumbnails are only available if the first page is ready, and not
awaiting that causes the drag-and-drop action to be performed using
incorrect thumbnail viewer state (see the analysis in #21184 for more
details).

Fixes #21184.
Supersedes #20902.
Unblocks #21173.
2026-04-29 14:22:10 +02:00
Jonas Jenwald
e2591b3fbb
Merge pull request #21190 from Snuffleupagus/DecodeStream-abstract-readBlock
Add an abstract `readBlock` method in the `DecodeStream` class
2026-04-29 14:19:10 +02:00
calixteman
0c5eaeeac6
Merge pull request #21189 from calixteman/issue21185
Use Istanbul instrumentation for unittestcli code coverage
2026-04-29 13:48:04 +02:00
Jonas Jenwald
1f6bfa0890 Add an abstract readBlock method in the DecodeStream class
This avoids having to "duplicate" dummy `readBlock` methods in a couple of image-stream classes.
Also, move a few `DecodeStream` field definitions to (ever so slightly) shorten the code.
2026-04-29 13:02:15 +02:00