22921 Commits

Author SHA1 Message Date
Tim van der Meij
6bfefa53da
Configure Puppeteer to use the stable version of Chrome
We currently use the pinned version of Chrome as hardcoded in the
Puppeteer release, which is based on the version of Chrome that was
deemed stable at the time of the Puppeteer release.

However, this is not ideal because it means that Chrome updates are
strongly tied to Puppeteer releases, so if Puppeteer releases are slow
we could be missing out on e.g. (security) patches being applied on the
stable channel. It's also not consistent with Firefox where we don't
use a hardcoded pinned version either.

This commit therefore configures Puppeteer to use (resolve) the most
recent stable version of Chrome at the time of the installation so that
determining the browser version to use is fully decoupled from the
Puppeteer release we're running.

The effect of this change can be seen in the output of running
`npx puppeteer browsers list`:

Before:

`chrome@149.0.7827.22 (linux) <path>`

After (note the slightly newer version):

`chrome@149.0.7827.115 (linux)` <path>`
2026-06-14 17:12:43 +02:00
Tim van der Meij
66c22b1fc5
Configure Puppeteer to not download Chrome headless shell
Nowadays Chrome has a built-in (new) headless mode in the regular
binary, but before that time there was an old headless mode that was
essentially a separate binary [1]. We don't use the latter, but it turns
out that Puppeteer downloads it automatically if it's not explicitly
skipped, which is wasteful because it costs extra time and resources for
each `npm install` invocation.

This commit therefore skips downloading Chrome headless shell explictly,
which results in the local runtime of `npm install` going from 10.125
seconds to 8.998 seconds (which can't hurt in e.g. GitHub Actions).

[1] https://developer.chrome.com/blog/chrome-headless-shell.
2026-06-14 16:59:13 +02:00
Tim van der Meij
8560125056
Merge pull request #21448 from timvandermeij/comment-intermittent
Fix intermittent failure in the `must check that the comment sidebar is resizable` comment integration test
2026-06-14 16:35:20 +02:00
Tim van der Meij
ed1b2f91be
Merge pull request #21440 from Snuffleupagus/putBinaryImageData-convertRGBToRGBA
Use the `convertRGBToRGBA` helper with RGB images in `putBinaryImageData`
2026-06-14 14:20:11 +02:00
Tim van der Meij
bfcafbc004
Merge pull request #21444 from Snuffleupagus/merge-test-password
Add an integration-test for merging a password-protected PDF
2026-06-14 14:16:35 +02:00
Jonas Jenwald
2dc73ad2a7 Collect coverage data from all workers when closing integration-tests
The "Merge PDF" integration-tests will (indirectly) invoke `PDFViewerApplication.open` as part of loading the new PDF document, which will end up creating a new `PDFWorker` instance.
Currently worker coverage is only collected at the end of each integration-test, which means that in these cases we miss the coverage data from any "previous" workers.
2026-06-14 13:27:06 +02:00
Jonas Jenwald
feec28583d Add an integration-test for merging a password-protected PDF
Looking at the coverage data the password-handling part of the merge functionality wasn't being tested; see e75a7cfd62/blob/src/core/worker.js (L652)
2026-06-14 13:17:33 +02:00
Jonas Jenwald
1373aa4a48
Merge pull request #21452 from Snuffleupagus/merge-test-corrupt
Add an integration-test for merging a corrupt PDF
2026-06-14 13:13:47 +02:00
Jonas Jenwald
e1c930adfe Add an integration-test for merging a corrupt PDF
Currently when opening a PDF document the following code is used, where `checkFirstPage`/`checkLastPage` helps detect XRef corruption; note 86a18bd5fe/src/core/worker.js (L167-L176)

However when merging a PDF into an existing document the parsing is only "partial"; note 86a18bd5fe/src/core/worker.js (L632-L634)

It seems a little strange to not support corrupt PDFs in a consistent manner in the code-base, hence this patch adds a new `BasePdfManager` helper that handles all the relevant parsing/checking and re-uses that when merging PDFs.
2026-06-14 09:49:23 +02:00
Tim van der Meij
d305b542df
Fix intermittent failure in the must check that the comment sidebar is resizable comment integration test
We use the generic `page.mouse.move(x, y, { steps }` API, but that purely
performs the mouse move steps without having knowledge about if/how the
application handles any events caused by it, so it doesn't wait for the
sidebar to render before moving on. This causes intermittent failures if
the sidebar didn't get enough time to render before the next mouse move
is initiated (which can happen in slower environments).

This commit fixes the issue by doing the mouse move steps ourselves and
by waiting for a browser trip between each of them to make sure that the
sidebar got a chance to render.

Fixes #21447.
Relates to #21044 / #21045 / 24e5377.
2026-06-13 21:32:00 +02:00
Tim van der Meij
86a18bd5fe
Merge pull request #21446 from timvandermeij/updates
Update dependencies to the most recent versions
2026-06-13 21:15:55 +02:00
Tim van der Meij
68a5ec1403
Upgrade eslint-plugin-unicorn to version 65.0.1
This is a major version bump, but the changelog at
https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v65.0.0
doesn't indicate any breaking changes that should impact us.

However, there is one false positive, possibly introduced by patch
https://github.com/sindresorhus/eslint-plugin-unicorn/pull/3028:

```
src/core/xfa/factory.js
  104:54  error  Prefer `.some(…)` over `.find(…)`  unicorn/prefer-array-some
```

This is incorrect because on this line we're not dealing with an array
but with a `FontFinder` instance instead (and that doesn't have a
`.some()` method), so we ignore the rule for this line.
2026-06-13 19:33:50 +02:00
Tim van der Meij
827ddf6e09
Update dependencies to the most recent versions 2026-06-13 19:12:35 +02:00
Tim van der Meij
01948aff23
Merge pull request #21443 from Snuffleupagus/finishWorkerTask-finally
Reduce duplication when invoking `finishWorkerTask`
2026-06-13 19:01:04 +02:00
Jonas Jenwald
c88f0bba04 Reduce duplication when invoking finishWorkerTask
By utilizing `Promise.prototype.finally()` more it's possible to avoid a bit of duplication when invoking `finishWorkerTask`.
2026-06-13 16:52:47 +02:00
Jonas Jenwald
55c8516944 Use the convertRGBToRGBA helper with RGB images in putBinaryImageData
This removes a little bit of code duplication, which only exist since the `src/display/canvas.js` code pre-dates the helper function by many years.

Note: Given that `OffscreenCanvas` is enabled by default there's currently not a lot of test coverage for this code-path, hence the added browser-test.
2026-06-13 13:14:50 +02:00
Tim van der Meij
e75a7cfd62
Merge pull request #21441 from Snuffleupagus/JpegImage-isSourcePDF-conditional
Re-factor the `isSourcePDF` handling in the `JpegImage` class
2026-06-13 12:48:00 +02:00
Tim van der Meij
5f8f6b1e40
Merge pull request #21439 from Snuffleupagus/more-getOrInsertComputed
Use `Map.prototype.getOrInsertComputed()` more in the code-base
2026-06-13 12:44:51 +02:00
Jonas Jenwald
ec1e94423b Re-factor the isSourcePDF handling in the JpegImage class
This functionality was added specifically for the standalone image-decoders, and by utilizing the pre-processor we can reduce the amount of "unnecessary" code in the regular builds.

Also, shorten a few loop variables a little bit since less code is always good.
2026-06-13 10:59:02 +02:00
Jonas Jenwald
5873e1cbc0
Merge pull request #21431 from Snuffleupagus/more-isDict
Use the `isDict` helper function in a few more places
2026-06-12 23:32:22 +02:00
Jonas Jenwald
ffa7ac7a91 Use Map.prototype.getOrInsertComputed() more in the code-base 2026-06-12 23:21:16 +02:00
Tim van der Meij
ca34359e1f
Merge pull request #21426 from Snuffleupagus/rm-convertToViewportRectangle
[api-minor] Remove the unused `convertToViewportRectangle` method in the `PageViewport` class
2026-06-12 22:06:19 +02:00
calixteman
35d275d3b1
Merge pull request #18907 from calixteman/bug1802506
Use the checkboxes and radio button appearances as defined in the pdf to render them in the annotation layer (bug 1802506)
2026-06-12 22:04:29 +02:00
Tim van der Meij
4781194b37
Merge pull request #21437 from Snuffleupagus/issue-21436
Handle corrupt PDFs that lack /Kids array and just inline the /Page dictionary (issue 21436)
2026-06-12 20:49:27 +02:00
Calixte Denizet
069b757998 Use the checkboxes and radio button appearances as defined in the pdf to render them in the annotation layer (bug 1802506)
The idea is to generate two operator lists for the Yes/Off states and render them on a separate canvas.
These canvases are then attached the annotation and we modify their display depending on the input state.

It fixes #18021.
2026-06-12 20:10:56 +02:00
Jonas Jenwald
131d6b7d38 Handle corrupt PDFs that lack /Kids array and just inline the /Page dictionary (issue 21436)
This basically extends PR 9549 to the fallback `getAllPageDicts` method, which didn't exist at the time, in order to support more cases of corrupt PDF documents.
2026-06-12 12:04:58 +02:00
calixteman
63db4bb777
Merge pull request #21433 from mozilla/update-locales
l10n: Update locale files
2026-06-12 08:45:22 +02:00
github-actions[bot]
53d0856ee9 l10n: Update locale files 2026-06-12 01:00:11 +00:00
Jonas Jenwald
3b628d59fb Use the isDict helper function in a few more places 2026-06-11 17:24:03 +02:00
Jonas Jenwald
2466a76ba4
Merge pull request #21429 from Snuffleupagus/getAttachmentContent-fix-unit-test
Fix the unit-tests for on-demand password handling of encrypted attachments (issue 21425)
2026-06-11 15:13:46 +02:00
Jonas Jenwald
587abf0ef4 Re-use the getPassword helper function more in the src/core/worker.js file
Currently the same code, for requesting the password from the main-thread, is now duplicated three times.
Let's avoid that by moving the new `getPassword` helper function, added in the previous commit, and re-use that everywhere instead.
2026-06-11 10:07:39 +02:00
Jonas Jenwald
f3f5acc418 Fix the unit-tests for on-demand password handling of encrypted attachments (issue 21425)
These unit-tests used a PDF that prompted for password on document load, which meant that the on-demand password handling wasn't actually being tested as intended.

Updating the unit-tests also caused the "re-prompts for encrypted attachments after incorrect passwords" test to fail, since the `INCORRECT_PASSWORD` password reason was being accidentally "swallowed" in the worker-thread.
2026-06-10 23:08:34 +02:00
Jonas Jenwald
ac64bcfa2b
Merge pull request #21427 from Snuffleupagus/putBinaryImageData-convertBlackAndWhiteToRGBA
Use the `convertBlackAndWhiteToRGBA` helper with grayscale images in `putBinaryImageData`
2026-06-10 21:23:03 +02:00
Jonas Jenwald
d1926fb179 Use the convertBlackAndWhiteToRGBA helper with grayscale images in putBinaryImageData
This removes a little bit of code duplication, which only exist since the `src/display/canvas.js` code pre-dates the helper function by many years.

*Note:* Given that `OffscreenCanvas` is enabled by default there's currently not a lot of test coverage for this code-path, hence the added browser-test.
2026-06-10 18:31:07 +02:00
Jonas Jenwald
a543d0a2e0 [api-minor] Remove the unused convertToViewportRectangle method in the PageViewport class
This method has been completely unused for many years, possibly as far back as PR 8030, hence we can avoid shipping a little bit of dead code.

*Note:* If there's any third-party code depending on it, updating it ought to be as simple as changing
```javascript
const r = viewport.convertToViewportRectangle(rect);
```
into
```javascript
const r = [
  ...viewport.convertToViewportPoint(rect[0], rect[1]),
  ...viewport.convertToViewportPoint(rect[2], rect[3])
];
```
2026-06-10 14:19:20 +02:00
calixteman
ce08a803c4
Merge pull request #21416 from calixteman/drop-css-unsafe-inline
Drop 'unsafe-inline' from the CSP style-src directives
2026-06-09 23:16:38 +02:00
calixteman
a13f2aa793
Merge pull request #21413 from calixteman/improve_comb
Improve rendering of comb text fields
2026-06-09 23:10:49 +02:00
Calixte Denizet
fe5eb0f779
Improve rendering of comb text fields
Center each glyph within its comb cell instead of left-aligning it,
both in the HTML annotation layer and in the printed/saved appearance,
to match Acrobat. Cell width is now the single source of truth via the
--comb-width CSS variable, and field text-alignment (center/right) is
applied as a whole-cell --comb-offset that stays in sync on input,
blur, resetform and updatefromsandbox. The field no longer grows on
focus; trailing letter-spacing is clipped and cell dividers are drawn
on focus.
2026-06-09 22:15:40 +02:00
Calixte Denizet
5ca6026d80
Drop 'unsafe-inline' from the CSP style-src directives
The print service injected the per-PDF `@page { size }` rule as an inline
<style> element, which required 'unsafe-inline' on style-src-elem.

Inject it through a constructable CSSStyleSheet attached to
document.adoptedStyleSheets instead. Constructable stylesheets aren't
subject to style-src's inline restrictions in browsers.
2026-06-09 22:08:08 +02:00
calixteman
cb53dbecb9
Merge pull request #21419 from calixteman/chrome_ext_csp
[CRX] List all viewer-accessible schemes in the connect-src CSP
2026-06-09 21:32:08 +02:00
Tim van der Meij
c541d24ac3
Merge pull request #21407 from calixteman/fix_hidden_updated_field
Fix form fields with their own canvas updated on non-rendered pages
2026-06-09 20:03:20 +02:00
Tim van der Meij
29ad297626
Merge pull request #21409 from Snuffleupagus/PDFViewer-#setPrintingAllowed
Add a `PDFViewer` helper method for setting `#printingAllowed` and dispatching the event
2026-06-09 19:43:26 +02:00
Tim van der Meij
8a80f1b8b7
Merge pull request #21418 from Snuffleupagus/getAttachments-Map
[api-minor] Convert `getAttachments` to return data in a `Map`
2026-06-09 19:42:23 +02:00
Tim van der Meij
7f5b42140d
Merge pull request #21414 from calixteman/issue21406
Handle TR2 with /Default entry
2026-06-09 19:26:57 +02:00
Tim van der Meij
9e5cbcef50
Merge pull request #21421 from mozilla/dependabot/github_actions/github/codeql-action-4.36.1
Bump github/codeql-action from 4.36.0 to 4.36.1
2026-06-09 19:24:13 +02:00
Tim van der Meij
cf8677154b
Merge pull request #21420 from mozilla/dependabot/github_actions/actions/checkout-6.0.3
Bump actions/checkout from 6.0.2 to 6.0.3
2026-06-09 19:23:29 +02:00
calixteman
3602db7456
[CRX] List all viewer-accessible schemes in the connect-src CSP 2026-06-09 16:55:19 +02:00
dependabot[bot]
5140371ebe
Bump github/codeql-action from 4.36.0 to 4.36.1
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.36.0 to 4.36.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](7211b7c807...87557b9c84)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.36.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-09 12:14:30 +00:00
dependabot[bot]
380c4c8139
Bump actions/checkout from 6.0.2 to 6.0.3
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.2 to 6.0.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](de0fac2e45...df4cb1c069)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-09 12:13:07 +00:00
Jonas Jenwald
ea139e7df1 [api-minor] Convert getAttachments to return data in a Map
Compared to regular `Object`s there's a number of advantages to using `Map`s:
 - They support "proper" iteration.
 - They have a simple way to check for the existence of data.
 - They have a simple/efficient way to check the number of elements.

If this functionality was added today, I cannot imagine that we'd choose an `Object` for this sort of data.
Furthermore, in PR 21351 the data returned by `getAttachments` changed slightly and third-party users will need to update their code anyway (hence why `[api-minor]` should be fine here).
2026-06-09 10:17:23 +02:00