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

19718 commits

Author SHA1 Message Date
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
Tim van der Meij
6784124a74
Merge pull request #18320 from timvandermeij/integration-test-tabs
Fix the "copy/paste from a tab to an other" stamp editor integration test
2024-06-23 20:56:59 +02:00
Tim van der Meij
287fd6afd4
Fix the "copy/paste from a tab to an other" stamp editor integration test
This integration test contains three issues:

- The `page.bringToFront()` call is not awaited, even though it returns
  a promise (see https://pptr.dev/api/puppeteer.page.bringtofront). Note
  that in other tests we do this correctly already.
- The `page.waitForSelector()` call at the end is unnecessary because
  that exact condition is already checked at the end of the
  `waitForImage` function we call just before this line; see
  https://github.com/mozilla/pdf.js/blob/master/test/integration/stamp_editor_spec.mjs#L74.
- The pages should be closed in reversed order; please refer to the
  description in #18318 for more details.

Fixes #18318.
2024-06-23 19:08:58 +02:00
Tim van der Meij
b4393a7e79
Merge pull request #18317 from timvandermeij/integration-test-separate-browser-cleanup
Close the page in the text layer caret selection integration test
2024-06-23 16:13:00 +02:00
Tim van der Meij
7057142c7a
Merge pull request #18316 from timvandermeij/integration-test-addons-xpi
Disable system addon updates for Firefox in testing mode
2024-06-23 16:12:07 +02:00
Tim van der Meij
f4053c2b3e
Close the page in the text layer caret selection integration test
This integration test is currently the only one that spawns a separate
browser instance. However, while it closes the browser once it's done,
it doesn't close the page (and therefore doesn't call the `testingClose`
method) like the other integration tests do.

This commit fixes this difference by closing the page before closing the
browser, thereby ensuring all regular cleanup logic gets called and we
avoid (intermittent) shutdown tracebacks in the logs. This allows
upcoming integration tests that spawn a separate browser instance to
reuse this pattern to cleanly end the test.

Given that we integrate the `closeSinglePage` code from #17962 for this
patch, @calixteman is credited as the co-author.

Co-authored-by: Calixte Denizet <calixte.denizet@gmail.com>
2024-06-23 12:46:18 +02:00
Tim van der Meij
327738d02a
Disable system addon updates for Firefox in testing mode
This commit fixes the following log line that currently shows up for
every type of tests that involve a browser:

`System addon update list error SyntaxError: XMLHttpRequest.open:
'http://%(server)s/dummy-system-addons.xml' is not a valid URL.`

If Firefox is in testing mode, the system addons update URL is
configured to a dummy URL so that it can't actually update (see for
example the same value in Marionette at
https://searchfox.org/mozilla-central/source/testing/marionette/client/marionette_driver/geckoinstance.py#109),
but this doesn't stop Firefox from trying to update, and when it does
it logs this line because the URL is obviously invalid.

Hence this patch which disables system addon updates altogether so
Firefox doesn't attempt to use the dummy URL anymore. The browser
updates are all managed by Puppeteer, and regular updates have already
been disabled too (see
6937a76f0a/packages/browsers/src/browser-data/firefox.ts (L302-L303)).
2024-06-23 11:58:55 +02:00
Tim van der Meij
c18a987f4e
Merge pull request #18313 from Snuffleupagus/l10n-destroy
Try to shutdown Fluent "more" when closing the viewer during testing
2024-06-22 19:45:24 +02:00
Tim van der Meij
658b5fab5d
Merge pull request #18312 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2024-06-22 19:32:25 +02:00
Jonas Jenwald
6492587066 Try to shutdown Fluent "more" when closing the viewer during testing
Even with PR 18280 fixed, we still *occasionally* see l10n-related errors when closing the integration-tests on the bots.
2024-06-22 16:40:12 +02:00
Tim van der Meij
a89c700607
Update translations to the most recent versions 2024-06-21 17:11:30 +02:00
Tim van der Meij
3b9208b8b6
Update dependencies to the most recent versions 2024-06-21 17:09:21 +02:00
Tim van der Meij
f9ff613e56
Merge pull request #18303 from bootleq/findbar-state-entire-word
Expose entireWord in updateFindControlState
2024-06-21 16:13:54 +02:00
Tim van der Meij
ba0e732e32
Merge pull request #18308 from nicolo-ribaudo/patch-1
Use the new formatted issue templates
2024-06-21 16:00:59 +02:00
Nicolò Ribaudo
1480e6778b
Use the new formatted issue templates 2024-06-21 15:42:31 +02:00
bootleq
890c567eca Expose entireWord in updateFindControlState
Allow apps with supportsIntegratedFind to better monitor the find state.

A recognized use case is the Firefox findbar, its "not found" sound must
consider `entireWord` and only make noise when it is off.

See related implementation in
https://hg.mozilla.org/mozilla-central/rev/16b902cbcf26

This change can help if we have to move the implementation from cpp to jsm.
2024-06-21 13:12:59 +08:00
calixteman
a081dd25eb
Merge pull request #18306 from calixteman/bug1903731
Always use DW if it's a number for the font default width (bug 1903731)
2024-06-20 16:52:29 +02:00
Tim van der Meij
1cf19e907d
Merge pull request #18302 from Snuffleupagus/testingClose-findbar-close
Close `PDFFindBar` when closing the viewer during testing
2024-06-20 15:55:36 +02:00
calixteman
d09aed87d0
Merge pull request #18296 from calixteman/bug1903589
[Editor] Correctly set the accessibility data when copying & pasting a stamp with an alt text (bug 1903589)
2024-06-20 15:35:22 +02:00
Calixte Denizet
8c9a665728 Always use DW if it's a number for the font default width (bug 1903731) 2024-06-20 15:33:34 +02:00
Jonas Jenwald
e76242d4ea
Merge pull request #18304 from Snuffleupagus/issue-18298
Don't throw if there's not enough data to get the header in `FlateStream` (issue 18298)
2024-06-20 13:53:26 +02:00
Calixte Denizet
67f9756fce [Editor] Correctly set the accessibility data when copying & pasting a stamp with an alt text (bug 1903589) 2024-06-20 13:52:58 +02:00
calixteman
9afd3a5b2f
Merge pull request #18301 from calixteman/no_signal
[Editor] Don't create an observer for the stamp annotation after the viewer has been closed
2024-06-20 13:42:54 +02:00
Jonas Jenwald
3fae2d71f6 Don't throw if there's not enough data to get the header in FlateStream (issue 18298)
Following in the footsteps of PR 17340.
2024-06-20 13:03:17 +02:00
Jonas Jenwald
02c03154b3 Close PDFFindBar when closing the viewer during testing
By closing `PDFFindBar` we also disconnect the `ResizeObserver`, since we've seen at least one case where that's running during shutdown: http://54.193.163.58:8877/91c40554d1b07c0/output.txt
2024-06-20 11:51:21 +02:00
Calixte Denizet
7d7ae34e34 [Editor] Don't create an observer for the stamp annotation after the viewer has been closed 2024-06-20 10:52:28 +02:00
Tim van der Meij
3e1d779859
Merge pull request #18218 from nicolo-ribaudo/test-maxCanvasPixels
Respect `maxCanvasPixels` when computing canvas dimensions
2024-06-19 16:47:09 +02:00
Jonas Jenwald
94cbe9ec23
Merge pull request #18289 from Snuffleupagus/app-testingClose
Add a new helper, in the viewer, to close everything during testing
2024-06-19 16:22:12 +02:00