1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 01:28:06 +02:00
Commit graph

3821 commits

Author SHA1 Message Date
Calixte Denizet
e0b63ecd03 Move the pinch stuff in its own file in order to use for editors 2024-12-11 23:20:01 +01:00
Calixte Denizet
d61b882888 [Editor] Avoid to focus an existing editor when enabling the layer
It fixes #18911.
2024-12-11 15:06:56 +01:00
calixteman
b35999d837
Merge pull request #19198 from calixteman/fix_intermittent_itest_chrome
Fix intermittent failures when moving a freetext annotation in integration tests
2024-12-10 16:56:58 +01:00
Calixte Denizet
74a377f72f Fix intermittent failures when moving a freetext annotation in integration tests
When an editor is moved with the keyboard or in dragging it, it is moved in the DOM in order
to make screen readers happy. But this move is slightly postponed thanks to a setTimeout(..., 0).
The failures were very likely due to the fact that intermittently the DOM move was done in
the middle of the next key sequence which was making the move on screen failing.
2024-12-10 16:14:26 +01:00
Calixte Denizet
99f3e6b4ec [Editor] When resizing a stamp annotation, the opposite corner must stay fixed
It was due the resize observer which is removed thanks to this patch.
In order to reuse the dragAndDrop function in test, this patch slighty refactors it
in order to make it easier to use.
2024-12-09 16:07:43 +01:00
Jonas Jenwald
5dc2d257ad
Merge pull request #19196 from Snuffleupagus/issue-19176
Take the `userUnit` into account in the `PageViewport` class (issue 19176)
2024-12-09 13:38:31 +01:00
calixteman
6177bb5aa8
Merge pull request #19197 from calixteman/test_disableFontFace
Add a ref test for setting disableFontFace to true
2024-12-08 16:17:42 +01:00
Calixte Denizet
f6662d3f7c Add a ref test for setting disableFontFace to true 2024-12-08 16:06:25 +01:00
Jonas Jenwald
c6e3fc4fe6 Take the userUnit into account in the PageViewport class (issue 19176) 2024-12-08 15:51:04 +01:00
Tim van der Meij
e74080915d
Fix intermittent issues in the issue14307.pdf integration tests
The `must check input for US zip format` integration test fails pretty
consistently in Puppeteer 23.4.0+ with `Expected '12341' to equal
'12345'`. This is reproducible with the `pdf.sandbox.external.js` hack
from https://github.com/mozilla/pdf.js/issues/18396#issuecomment-2211273743.
Investigation uncovered two issues at play here:

1. We do two `clearInput` calls, but don't await processing of the two
   sandbox events that are triggered by that action. The three tests that
   use `issue14307.pdf` are in different `describe` blocks and therefore
   reload the PDF file, so we can simply remove those calls because the
   inputs are already empty by default.

2. We don't await processing of the sandbox events that occur after
   switching to another text field. This causes the expectation failure
   because the typing actions will happen too soon and interfere with
   the sandbox event processing. We solve the issue by explicitly
   awaiting the sandbox roundtrip.

Moreover, similar to PR #19001 and #18399 we remove any remaining room
for intermittent issues by directly checking for the expected value,
which also results in shorter code.
2024-12-07 19:28:26 +01:00
Calixte Denizet
6fe6b6d6b7 Get the first codepoint instead of the first char when using the toUnicode map
It fixes #19182.
2024-12-06 18:25:13 +01:00
Jonas Jenwald
c198e0b446
Merge pull request #19148 from nicolo-ribaudo/error-preserve-trace
Do not stringify errors when logging them
2024-12-06 17:11:33 +01:00
Nicolò Ribaudo
202b26487f
Do not stringify errors when logging them
Converting errors to string drops their stack trace, making it more
difficult to debug their actual reason. We can instead pass the error
objects as-is to console.warn/error, so that Firefox/Chrome devtools
will show both the stack trace of the console.warn/error call, and the
original stack trace of the error.

This commit also enables the `unicorn/no-console-spaces` ESLint rule,
which avoids accidental extra spaces when passing multiple parameters to
`console.*` methods.
2024-12-06 14:47:22 +01:00
Jonas Jenwald
2661d0623b Ensure that a missing/invalid "Content-Range" header is handled in PDFNetworkStream (issue 19075)
In the event that the "Content-Range" header is missing/invalid, loading will now be aborted rather than hanging indefinitely.
2024-12-06 12:09:34 +01:00
Calixte Denizet
f3038406b1 When zooming replace the css-zoomed canvas by the new one only when rendering is finished
It fixes #18622.

It avoids to recreate a canvasWrapper element in order minimize the DOM operations.
2024-12-05 23:15:04 +01:00
Calixte Denizet
d1db8d6294 Avoid to display an alert or a confirm dialog if the message is empty
It fixes #19171.
2024-12-05 21:04:07 +01:00
Calixte Denizet
dfa0e79553 [Editor] Correctly update the current drawing when zooming
We were trying to update the drawing on the current page but if the drawing is an another
page then it wasn't updated.
2024-12-05 14:22:02 +01:00
Calixte Denizet
3ac55501e9 Correctly wait for the editor mode when double clicking on an annotation in integration tests 2024-12-04 18:42:49 +01:00
calixteman
9a4b7c2612
Merge pull request #19155 from calixteman/bug1929311
[Editor] Corrrectly get the words from the alt-text when reporting the telemetry (bug 1929311)
2024-12-03 19:27:15 +01:00
Calixte Denizet
e161826a44 [Editor] Corrrectly get the words from the alt-text when reporting the telemetry (bug 1929311) 2024-12-03 19:02:58 +01:00
Aditi
41bf874461 Add tests for annotation delete popup 2024-12-03 11:03:15 +01:00
Jonas Jenwald
f8d11a3a3a
Merge pull request #19074 from Rob--W/issue-12744-test
Add test cases for redirected responses
2024-12-02 19:06:55 +01:00
Rob Wu
f97b4b9a66 Add test cases for redirected responses
Regression tests for issue #12744 and PR #19028
2024-12-02 17:57:49 +01:00
Rob Wu
28b0220bc2 Replace createTemporaryNodeServer with TestPdfsServer
Some tests rely on the presence of a server that serves PDF files.
When tests are run from a web browser, the test files and PDF files are
served by the same server (WebServer), but in Node.js that server is not
around.

Currently, the tests that depend on it start a minimal Node.js server
that re-implements part of the functionality from WebServer.

To avoid code duplication when tests depend on more complex behaviors,
this patch replaces createTemporaryNodeServer with the existing
WebServer, wrapped in a new test utility that has the same interface in
Node.js and non-Node.js environments (=TestPdfsServer).

This patch has been tested by running the refactored tests in the
following three configurations:

1. From the browser:
   - http://localhost:8888/test/unit/unit_test.html?spec=api
   - http://localhost:8888/test/unit/unit_test.html?spec=fetch_stream

2. Run specific tests directly with jasmine without legacy bundling:
   `JASMINE_CONFIG_PATH=test/unit/clitests.json ./node_modules/.bin/jasmine --filter='^api|^fetch_stream'`

3. `gulp unittestcli`
2024-12-02 17:57:49 +01:00
Calixte Denizet
7e02c77250 [Editor] Make ink annotation editable 2024-12-02 17:15:33 +01:00
calixteman
97c7a8eb7a
Merge pull request #19144 from calixteman/no_focus_if_invisible
[Editor] Don't focus a newly added drawing if it isn't visible on screen
2024-12-02 14:02:01 +01:00
Calixte Denizet
673c93e832 [Editor] Don't focus a newly added drawing if it isn't visible on screen 2024-12-02 11:06:13 +01:00
Calixte Denizet
1460a8128a Fix the clickable area for rotated ink annotations 2024-12-02 09:48:22 +01:00
Jonas Jenwald
867aaf01fa
Merge pull request #19117 from Snuffleupagus/bot-forceNoChrome
Disable the browser-tests in Google Chrome on the bots
2024-12-01 18:28:03 +01:00
calixteman
8f08ca2150
Merge pull request #19131 from calixteman/bug1934157
Build date consistently (in term of tz) when executing some embedded JS (bug 1934157)
2024-11-29 21:44:10 +01:00
Calixte Denizet
2a337082c0 Build date consistently (in term of tz) when executing some embedded JS (bug 1934157)
The date was create in UTC+0 and then amended in using set-Month/Date which take into account
the user timezone.
With this patch we build all the date in the user timezone.
2024-11-29 19:50:21 +01:00
calixteman
9ecc613c08
Merge pull request #19066 from jarklee/issue19056
Fix #serializeBoxes function not output correct quadPoints values for deserialize (issue19056)
2024-11-29 18:31:28 +01:00
Calixte Denizet
4acc086292 [Editor] Allow to abort the current drawing
It fixes #19126.
2024-11-29 16:22:49 +01:00
Jonas Jenwald
65f20b0392
Merge pull request #19121 from Snuffleupagus/more-stopEvent
Use the `stopEvent` helper function everywhere possible
2024-11-28 17:21:34 +01:00
calixteman
c784a24d45
Merge pull request #19122 from calixteman/issue19120
Correctly compute the mapping between text and normalized text when it contains a compound word on two lines
2024-11-28 17:13:09 +01:00
Calixte Denizet
aa9503e51f Correctly compute the mapping between text and normalized text when it contains a compound word on two lines
It fixes #19120.

The original text doesn't contain the cr so we must take that into account.
2024-11-28 15:56:04 +01:00
Calixte Denizet
cee65fcd4e [Editor] Add a new base class to allow to add a drawing in the SVG layer.
This patch makes a clear separation between the way to draw and the editing stuff.
It adds a class DrawEditor which should be extended in order to create new drawing tools.
As an example, the ink tool has been rewritten in order to use it.
2024-11-28 15:23:03 +01:00
Jonas Jenwald
e1760aab8d Use the stopEvent helper function everywhere possible 2024-11-28 13:25:56 +01:00
calixteman
22babd722f
Merge pull request #19109 from calixteman/click_when_dragging
[Editor] Disallow to have multiple pointers while dragging an editor
2024-11-27 20:26:45 +01:00
Calixte Denizet
e695d04ca2 [Editor] Disallow to have multiple pointers while dragging an editor
It'll let the user dragging with two fingers.
2024-11-27 19:41:13 +01:00
Jonas Jenwald
fd31e728f7 Disable the browser-tests in Google Chrome on the bots
Given that `browsertest` repeatedly timeout in Google Chrome, and considering that Firefox is the primary development target, we stop running them on the bots to avoid having to repeatedly deal with this.

Note that we already disabled these tests *on Windows* almost three years ago, because of stability issues; see PR 14392.
2024-11-27 17:59:51 +01:00
Calixte Denizet
5d77a64e1f Fix the highlight integration test when highlighting with the keyboard
These tests were failing with Puppeteer 23.9.0.
2024-11-27 15:38:33 +01:00
Jarklee
2200f0523c Fix #serializeBoxes bug inconsistent with deserialize function for highlight editor.
Add test for quadPoints order while serializing.
2024-11-27 14:19:31 +07:00
Rob Wu
131d4650a5 Drop trailing whitespace from test/unit/api_spec.js
test/unit/api_spec.js is the only JS file in the tree with trailing
whitespace. Because `trim_trailing_whitespace = true` in .editorconfig,
any editor supporting EditorConfig would trim whitespace when the file
is changed, which results in test failures.

This commit fixes the issue by trimming the trailing whitespace and
adjusting the test expectations.
2024-11-24 23:37:16 +01:00
Tim van der Meij
8ae5b4e442
Merge pull request #19096 from Rob--W/test-server-hardening
Fix path traversal issue in createTemporaryNodeServer
2024-11-24 15:30:22 +01:00
calixteman
9017e80d5a
Merge pull request #19095 from calixteman/issue17190
Rescale the image data when they're really too large
2024-11-24 14:30:37 +01:00
Jonas Jenwald
6a015588b9 Ensure that the response-origin of range requests match the full request (issue 12744)
The following cases are excluded in the patch:
 - The Firefox PDF Viewer, since it has been fixed on the platform side already; please see https://bugzilla.mozilla.org/show_bug.cgi?id=1683940

 - The `PDFNodeStream`-implementation, used in Node.js environments, since after recent changes that code only supports `file://`-URLs.

Also updates the `PDFNetworkStreamFullRequestReader.read`-method to await the headers before returning any data, similar to the implementation in `src/display/fetch_stream.js`.

*Note:* The relevant unit-tests are updated to await the `headersReady` Promise before dispatching range requests, since that's consistent with the actual usage in the `src/`-folder.
2024-11-24 10:08:29 +01:00
Calixte Denizet
1ef670411a Rescale the image data when they're really too large
It fixes #17190.
2024-11-23 22:42:30 +01:00
Rob Wu
17da8ee8fa Fix path traversal issue in createTemporaryNodeServer
The test-only createTemporaryNodeServer helper featured a path traversal
vulnerability. This enables attackers with network access to the device
to read arbitrary files while unit tests are running that activate this
test server.

This patch fixes the issue by validation of paths.

To test this vulnerability before the patch:

1. Run the test-only server:

```
node -e 'console.log(require("./test/unit/test_utils.js").createTemporaryNodeServer().port)
```

2. From another terminal, send the following request (modify the port to
   the port reported in the previous step):

```
curl --path-as-is http://localhost:45755/../../package.json
```

Before the patch, the second step would traverse the directory, and
return results from the root of the PDF.js repository, instead of files
within test/pdfs/.

With the patch, the server refuses the request with HTTP status 400.
2024-11-23 21:32:24 +01:00
calixteman
5133e6b666
Merge pull request #19085 from calixteman/simplify_drawer
[Editor] Simplify the draw layer code
2024-11-22 09:16:48 +01:00