1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 07:08:08 +02:00
Commit graph

19195 commits

Author SHA1 Message Date
calixteman
75129fd61a
Merge pull request #18361 from calixteman/issue18360.pdf
[Editor] Take into account the page translation when computing the quadpoints when saving an highlight
2024-07-02 11:21:06 +02:00
Calixte Denizet
576aaf7cc1 [Editor] Take into account the page translation when computing the quadpoints when saving an highlight
It fixes #18360.
2024-07-02 10:12:26 +02:00
Tim van der Meij
c280c520ee
Merge pull request #18359 from timvandermeij/bump
Bump the stable version in `pdfjs.config`
2024-07-01 20:14:50 +02:00
Tim van der Meij
2f4d5d25a8
Bump the stable version in pdfjs.config 2024-07-01 20:10:35 +02:00
Tim van der Meij
19fbc89985
Merge pull request #18358 from timvandermeij/npm-url
Fix the repository URL in the `package.json` file for `pdfjs-dist`
2024-07-01 19:55:07 +02:00
Tim van der Meij
bf5dd7ea10
Fix the repository URL in the package.json file for pdfjs-dist
For provenance, enabled in PR #18352, to work the repository URL in
`package.json` is required to match the repository URL of the GitHub
Actions invocation. This should fix the following error we encountered
publishing a new release today:

```
npm error 422 Unprocessable Entity - PUT https://registry.npmjs.org/pdfjs-dist - Error verifying sigstore provenance bundle: Failed to validate repository information: package.json: "repository.url" is "git+https://github.com/mozilla/pdfjs-dist.git", expected to match "https://github.com/mozilla/pdf.js" from provenance
```
2024-07-01 19:32:03 +02:00
Tim van der Meij
7114796430
Merge pull request #18352 from wojtekmaj/provenance
Generate provenance statements on npm publish
2024-07-01 17:42:16 +02:00
Tim van der Meij
067ec20092
Merge pull request #18356 from calixteman/no_newtabpage
Disable new tab page stuff in Firefox when running tests
2024-07-01 16:47:39 +02:00
Calixte Denizet
efb45a705e Disable new tab page stuff in Firefox when running tests
It should help to have such a garbage in the logs:
```
console.warn: TopSitesFeed: Failed to fetch data from Contile server: NetworkError when attempting to fetch resource.
JavaScript error: , line 0: TypeError: NetworkError when attempting to fetch resource.
```
2024-07-01 16:20:07 +02:00
Wojciech Maj
aaa65bf3fc
Generate provenance statements on npm publish
This PR adds [Provenance statements](https://docs.npmjs.com/generating-provenance-statements) on `npm publish`, increasing supply-chain security.
2024-07-01 15:37:25 +02:00
Tim van der Meij
8556a26390
Merge pull request #18353 from wojtekmaj/npm-ci
Use `npm ci`, not `npm install`, on CI
2024-07-01 15:25:02 +02:00
Wojciech Maj
6b449d8884
Use npm ci, not npm install, on CI
This PR switches from `npm install` to `npm ci` on CI. This enables some additional checks to ensure repo integrity when using CI/CD.

Read more: https://docs.npmjs.com/cli/v10/commands/npm-ci
2024-07-01 13:46:23 +02:00
calixteman
b5d554e1b4
Merge pull request #18350 from timvandermeij/github-actions-release
Introduce a GitHub Actions workflow for publishing a release and fix `npm publish` warnings about the `package.json` format
2024-07-01 10:02:41 +02:00
Tim van der Meij
dddb74d5e4
Fix npm publish warnings about the package.json format
This commit removes the following warnings from the `npm publish` output:

```
npm warn publish npm auto-corrected some errors in your package.json when publishing.  Please run "npm pkg fix" to address these errors.
npm warn publish errors corrected:
npm warn publish Removed invalid "scripts"
npm warn publish "repository.url" was normalized to "git+https://github.com/mozilla/pdfjs-dist.git"
```

For the "scripts" section it turns out that if the package doesn't have
any scripts it's expected to explicitly set it to an empty object; refer
to https://github.com/npm/cli/issues/6918 and
https://github.com/denoland/dnt/pull/414.
2024-06-30 16:03:52 +02:00
Tim van der Meij
a5f2b9faeb
Introduce a GitHub Actions workflow for publishing a release
This commit migrates this functionality away from the bots. Note that
the NPM token must be configured as a repository secret before this
workflow can execute.

The following resources are relevant for this patch:

- Publishing packages to the NPM registry:
  https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
- Creating secrets for a repository:
  https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository
2024-06-30 16:03:52 +02:00
Tim van der Meij
40b0c848ee
Merge pull request #18346 from Snuffleupagus/webserver-dev-note
Add a comment about `test/webserver.mjs` being development-only code
2024-06-30 13:45:30 +02:00
Jonas Jenwald
046e281e20 Add a comment about test/webserver.mjs being development-only code 2024-06-29 12:05:28 +02:00
calixteman
fb3a4e4f5c
Merge pull request #18345 from calixteman/issue18305
Take into account PageOpen and PageClose actions which are present in some fields
2024-06-28 22:43:23 +02:00
Calixte Denizet
dacf8bb0d1 Take into account PageOpen and PageClose actions which are present in some fields 2024-06-28 22:21:03 +02:00
calixteman
8709202021
Merge pull request #18341 from calixteman/issue17779_not_in_talos
Ignore test issue17779.pdf in talos because it times out
2024-06-28 18:58:08 +02:00
Calixte Denizet
4d91ae3cde Ignore test issue17779.pdf in talos because it times out 2024-06-28 17:38:58 +02:00
calixteman
a609bd89b3
Merge pull request #18338 from calixteman/fix_stamp_test
Fix intermittent failures with freetext and stamp tests
2024-06-27 20:03:04 +02:00
calixteman
abdc3fa7cf
Merge pull request #18339 from calixteman/add_port_option
Add a port option to gulp server
2024-06-27 20:01:46 +02:00
Tim van der Meij
53aca5fab1
Merge pull request #18336 from Snuffleupagus/InternalRenderTask-cancel-cancelAnimationFrame
Cancel the `requestAnimationFrame` in the API when cancelling rendering
2024-06-27 19:40:16 +02:00
Calixte Denizet
f006aa36d1 Add a port option to gulp server 2024-06-27 18:57:00 +02:00
Calixte Denizet
0e94f2bd00 Fix intermittent failures with freetext and stamp tests
They're potentially due to some concurrent access to the system clipboard.
So this patch makes them sequential.
2024-06-27 18:23:41 +02:00
Jonas Jenwald
a4f1a9a41b Cancel the requestAnimationFrame in the API when cancelling rendering
Errors related to this `requestAnimationFrame` show up intermittently when running the integration-tests on the bots, however I've been unable to reproduce it locally.
Hence I cannot guarantee that it's enough to fix the timing issues, however this should be generally safe since the `requestAnimationFrame` invokes the `_next`-method and the first thing that one does is check that rendering hasn't been cancelled.
2024-06-26 17:26:02 +02:00
Tim van der Meij
af16aa62ad
Merge pull request #18335 from Snuffleupagus/watchScroll-cancelAnimationFrame
Cancel the `requestAnimationFrame` in the `watchScroll` helper (PR 18193 follow-up)
2024-06-26 16:57:02 +02:00
Jonas Jenwald
4dad1e34b9 Cancel the requestAnimationFrame in the watchScroll helper (PR 18193 follow-up)
While the event listener is removed during testing, the `requestAnimationFrame` isn't cancelled and that occasionally shows up when the integration-tests are run on the bots.
2024-06-26 16:31:07 +02:00
Tim van der Meij
6d579081c4
Merge pull request #18331 from timvandermeij/integration-test-copy-pasting
Refactor the copy/paste logic in the integration tests and fix a race condition involving the `waitForEvent` integration test helper function
2024-06-26 16:20:57 +02:00
Tim van der Meij
7128b95d29
Fix a race condition involving the waitForEvent integration test helper function
Debugging #17931 uncovered a race condition in the way we use the
`waitForEvent` function. Currently the following happens:

1. We call `waitForEvent`, which starts execution of the function body
   and immediately returns a promise.
2. We do the action that triggers the event.
3. We await the promise, which resolves if the event is triggered or
   the timeout is reached.

The problem is in step 1: function body execution has started, but not
necessarily completed. Given that we don't await the promise, we
immediately trigger step 2 and it's not unlikely that the event we
trigger arrives before the event listener is actually registered in the
function body of `waitForEvent` (which is slower because it needs to be
evaluated in the page context and there is some other logic before the
actual `addEventListener` call).

This commit fixes the issue by passing the action to `waitForEvent` as
a callback so `waitForEvent` itself can call it once it's safe to do so.
This should make sure that we always register the event listener before
triggering the event, and because we shouldn't miss events anymore we
can also remove the retry logic for pasting.
2024-06-26 15:25:33 +02:00
Tim van der Meij
55ba4aa66a
Refactor the copy/paste logic in the integration tests
The integration tests are currently not consistent in how they do
copy/pasting: some tests use the `kbCopy`/`kbPaste` functions with
waiting for the event inline, some have their own helper function to
combine those actions and some even call `kbCopy`/`kbPaste` without
waiting for the event at all (which can cause intermittent failures).

This commit fixes the issues by providing a set of four helper functions
that all tests use and that abstract e.g. waiting for the event away
from the caller. This makes the invididual tests simpler and consistent,
reduces code duplication and fixes possible intermittent failures
due to not waiting for events to trigger.
2024-06-26 14:48:42 +02:00
calixteman
2fbd61944b
Merge pull request #18332 from calixteman/bug1904585
Add the possibility to dispatch some pdf.js events at the chrome level (bug 1904585)
2024-06-25 21:15:15 +02:00
Calixte Denizet
35474f8ef4 Add the possibility to dispatch some pdf.js events at the chrome level (bug 1904585) 2024-06-25 21:03:34 +02:00
Jonas Jenwald
7f586182ba
Merge pull request #18333 from Snuffleupagus/l10n-destroy-rm-requestAnimationFrame
Remove the `requestAnimationFrame` work-around in `L10n.prototype.destroy` (PR 18313 follow-up)
2024-06-25 18:34:42 +02:00
Jonas Jenwald
f676ce5760 Remove the requestAnimationFrame work-around in L10n.prototype.destroy (PR 18313 follow-up)
With `@fluent/dom 0.10.0` just published this work-around is no longer necessary.
2024-06-25 17:23:57 +02:00
Tim van der Meij
11cb3a8e11
Merge pull request #18283 from nicolo-ribaudo/ignore-browser-min-font-size
Override the minimum font size when rendering the text layer
2024-06-25 15:57:15 +02:00
Nicolò Ribaudo
5b29e935e1
Overrride the minimum font size when rendering the text layer
Browsers have an accessibility option that allows user to enforce
a minimum font size for all text rendered in the page, regardless
of what the font-size CSS property says. For example, it can be
found in Firefox under `font.minimum-size.x-western`.

When rendering the <span>s in the text layer, this causes the
text layer to not be aligned anymore with the underlying canvas.
While normally accessibility features should not be worked around,
in this case it is *not* improving accessibility:
- the text is transparent, so making it bigger doesn't make it more
  readable
- the selection UX for users with that accessibility option enabled
  is worse than for other users (it's basically unusable).

While there is tecnically no way to ignore that minimum font size,
this commit does it by multiplying all the `font-size`s in the text
layer by minFontSize, and then scaling all the `<span>`s down by
1/minFontSize.
2024-06-25 14:58:08 +02:00
Tim van der Meij
5885874953
Merge pull request #18326 from timvandermeij/integration-test-pastefromclipboard
Use `waitForEvent` in the `pasteFromClipboard` integration test helper function
2024-06-25 13:48:53 +02:00
Tim van der Meij
f974b75d69
Use waitForEvent in the pasteFromClipboard integration test helper function
This code contains the same bug that the previous commit fixed in
`waitForEvent`, namely that we don't clear the timeout if the event
is triggered. By using the now fixed `waitForEvent` function we not
only deduplicate this code but we also fix this issue so that no
incorrect timeout logs show up anymore.
2024-06-25 13:46:08 +02:00
Tim van der Meij
4b95d689de
Merge pull request #18325 from timvandermeij/integration-test-timeouts
Fix the timeout logic in the `waitForEvent` integration test helper function
2024-06-25 13:44:20 +02:00
calixteman
4899b2ea07
Merge pull request #18324 from calixteman/bug1539074_1
Fix the computation of unitsPerEm when the fontMatrix has some negative coefficients
2024-06-25 11:12:32 +02:00
Tim van der Meij
51dcd6a1ba
Fix the timeout logic in the waitForEvent integration test helper function
Debugging #17931, by printing all parts of the event lifecycle including
timestamps, uncovered that some events for which a timeout was logged
actually did get triggered correctly in the browser. Going over the code
and discovering https://stackoverflow.com/questions/47107465/puppeteer-how-to-listen-to-object-events#comment117661238_65534026
showed what went wrong: if the event we wait for is triggered then
`Promise.race` resolves, but that doesn't automatically cancel the
timeout. The tests didn't fail on this because `Promise.race` resolved
correctly, but slightly later once the timeout was reached we would see
spurious log lines about timeouts for the already-triggered events.

This commit fixes the issue by canceling the timeout if the event we're
waiting for has triggered.
2024-06-24 18:22:24 +02:00
Calixte Denizet
42bb2b0737 Fix the computation of unitsPerEm when the fontMatrix has some negative coefficients
It's a follow-up of #18253.
2024-06-24 16:40:07 +02:00
Tim van der Meij
e16707d6e2
Merge pull request #18323 from timvandermeij/security-followup
Improve the security policy
2024-06-24 16:08:31 +02:00
Tim van der Meij
4033913acc
Improve the security policy
This commit fixes two issues that have been found after commit 2beae7a
landed, namely:

- The security checkbox image is not rendering at
  https://github.com/mozilla/pdf.js/security/policy because the
  `SECURITY.md` file is apparently served differently there (because it
  does work as expected at
  https://github.com/mozilla/pdf.js/blob/master/.github/SECURITY.md),
  which causes the relative link not to work. We switch to an absolute
  link to fix the issue.
- If a security policy is defined it turns out that GitHub automatically
  adds a row to the "New issue" page; see
  https://docs.github.com/en/code-security/getting-started/adding-a-security-policy-to-your-repository
  where it states "When someone creates an issue in your repository, they
  will see a link to your project's security policy". Since we now have
  two rows at https://github.com/mozilla/pdf.js/issues/new/choose about
  the security policy, we remove our own version in favor of the
  standard GitHub-provided one.
2024-06-24 15:54:06 +02:00
Tim van der Meij
8123719709
Merge pull request #18311 from timvandermeij/security-policy
Include a security policy for PDF.js
2024-06-24 15:27:58 +02:00
Tim van der Meij
8923f9a4af
Merge pull request #18321 from timvandermeij/integration-test-ignored-errors
Don't ignore errors in the Jasmine suite start/end stages
2024-06-24 15:24:40 +02:00
Tim van der Meij
2beae7aad6
Include a security policy for PDF.js
This makes sure that security researchers can find the required
information for reporting security vulnerabilities in a standardized
manner across GitHub repositories. Please refer to
https://docs.github.com/en/code-security/getting-started/adding-a-security-policy-to-your-repository
for more information.
2024-06-23 21:35:33 +02:00
Tim van der Meij
2f3bf6f07e
Don't ignore errors in the Jasmine suite start/end stages
Currently errors in `afterAll` are logged, but don't fail the tests.
This could cause new errors during test teardown to go by unnoticed.

Moreover, the integration test use a different reporting mechanism which
also handled errors differently (this is extra reason to do #12730).

This patch fixes the issues by consistently handling errors in
`suiteStarted` and `suiteDone` in both reporting mechanisms.

Fixes #18319.
2024-06-23 20:59:48 +02:00