724 Commits

Author SHA1 Message Date
Jonas Jenwald
057507f6ce Use Uint8Array.fromBase64 in the test/integration/highlight_editor_spec.mjs file 2026-05-24 10:56:51 +02:00
Tim van der Meij
52d574c539
Merge pull request #21306 from calixteman/dnd_pdf_merging
Allow merging a PDF by dropping it onto the thumbnail viewer
2026-05-21 21:01:42 +02:00
Tim van der Meij
9b5cd3db64
Merge pull request #21304 from Snuffleupagus/PdfTextExtractor-tests
Add basic integration-tests for the `PdfTextExtractor` class
2026-05-21 20:27:53 +02:00
Tim van der Meij
42db304268
Merge pull request #21305 from Snuffleupagus/integration-test-EventBus-on
Don't use "internal" `EventBus` methods in the integration-tests
2026-05-21 20:17:28 +02:00
Calixte Denizet
0f90987927 Fix 'Select all' after #20981 2026-05-21 16:39:34 +02:00
Calixte Denizet
d79043b3af Allow merging a PDF by dropping it onto the thumbnail viewer
Drop an external PDF anywhere in the views-manager thumbnail
sidebar to merge it at the cursor, rather than always inserting
after the current page via the "Add file" button.

The drop reuses the blue separator from page-move drag so the
user can see exactly where the inserted pages will land, and the
merge path is shared with the existing picker so post-merge
selection/current-page behavior stays consistent.
2026-05-20 18:06:55 +02:00
Jonas Jenwald
429b469ecb Add basic integration-tests for the PdfTextExtractor class 2026-05-20 17:26:50 +02:00
Jonas Jenwald
abe8b564a3 Don't use "internal" EventBus methods in the integration-tests
This way *guarantees* that any and all internal viewer state has been updated first, before any test-specific code runs.
2026-05-20 16:39:21 +02:00
calixteman
5a4d93a238
Merge pull request #20981 from wooorm/wooorm/hcm
Make text selection more visible (bug 1879559)
2026-05-20 15:49:01 +02:00
Titus Wormer
957e004e38
Make text selection more visible (bug 1879559)
References <https://bugzilla.mozilla.org/show_bug.cgi?id=1879559>
(“In HCM, the text selection is barely visible”).

Continues work from @calixteman who had a partial patch.

This PR improves viewer text-selection highlighting by rendering
selection shapes in the draw layer.

* add selection overlay rendering in the draw layer
  * significant code relates to selections spanning multiple text
    layers/pages, and edges/end-of-content boundaries
* clear selection on rotate/scale/scroll/spread changes

My main question is: how should it appear?
I don’t have access to the Figma file linked on bugzilla.

In the CSS (`draw_layer-builder.css`) there are 3 blocks:

* default
* `@supports` for browsers supporting `backdrop-filter`
* `forced-colors` mode

So it’s possible to design for those (or more).
Personally, the `backdrop-filter: invert(1)` is the most contrast,
so perhaps it’s better to use something else as the default,
and to use `invert(1)` if high contrast mode is used (maybe with a
`prefers-contrast` media query instead)?
2026-05-19 21:10:12 +02:00
Tim van der Meij
0d69cc4dcf
Introduce integration tests for the presentation mode functionality
This commit provides coverage for the happy flows of basic operations
like entering/exiting and changing pages.
2026-05-18 20:52:00 +02:00
Tim van der Meij
00af75905f
Merge pull request #21295 from Snuffleupagus/PDFDocumentProperties-more-tests
Add more integration-tests, with multi-page documents, for the `PDFDocumentProperties` dialog
2026-05-18 20:24:41 +02:00
calixteman
abb8e31408
Merge pull request #21261 from calixteman/bug1960363
Add a Content-Security-Policy to pdf.js' viewer.html (bug 1960363)
2026-05-18 18:24:38 +02:00
Jonas Jenwald
1e62f01773 Improve handling of corrupt pages in the PDFDocumentProperties dialog
If the active page is corrupt that currently results in the entire dialog being "blank", thus providing no information, which seems unfortunate and it's easy enough to only skip `pageSizeField` in that rare case.
2026-05-18 17:38:43 +02:00
Jonas Jenwald
e05b6d6f59 Add more integration-tests, with multi-page documents, for the PDFDocumentProperties dialog
Improve test coverage for multi-page documents, to ensure that:
 - Unnecessary re-parsing is avoided where possible.
 - Rotation, in the viewer, is handled correctly.
 - Different page sizes are handled correctly.
2026-05-18 14:24:05 +02:00
Jonas Jenwald
1e9e8fad7e Add helper functions for opening/closing the document properties dialog during testing
This reduces duplication in the various integration-tests.
2026-05-18 13:31:26 +02:00
Tim van der Meij
2fb2bc13e0
Merge pull request #21275 from timvandermeij/integration-tests-optimize
Optimize runtime and memory usage of the integration tests
2026-05-17 20:41:43 +02:00
Tim van der Meij
f2bf57f444
Merge pull request #21288 from timvandermeij/unskip-test
Enable the `must check that an existing highlight is ignored on hovering` integration test on Windows
2026-05-17 20:19:42 +02:00
Jonas Jenwald
2cef900834 Add an integration-test for documents without contentLength available in the PDFDocumentProperties dialog 2026-05-17 16:55:48 +02:00
Tim van der Meij
af65d7f930
Enable the must check that an existing highlight is ignored on hovering integration test on Windows
It looks like this test passes consistently again, most likely after a
combination of browser/Puppeteer/configuration updates and the completed
switch to the WebDriver BiDi protocol.

Fixes #20136.
2026-05-17 14:47:14 +02:00
Jonas Jenwald
afa9b6ef9b Add an integration-test for the page-name fuzzy matching in the PDFDocumentProperties dialog
Also, test that closing the dialog works correctly.
2026-05-17 14:40:09 +02:00
Tim van der Meij
600a4bb1ee
Fix missing page closing for two viewer integration tests
This caused the tab to remain open after the tests ran, which meant
that a total of ~120 MB of memory was not being freed.
2026-05-16 19:30:42 +02:00
Tim van der Meij
62b88aa56e
Use Puppeteer's ElementHandle.boundingBox() API in the integration tests
The custom solution for obtaining the bounding box of a given element
that we have now was necessary during the original introduction of the
integration tests because at the time the `ElementHandle.boundingBox()`
API in Puppeteer didn't work correctly in Chrome.

However, `getRect`, where this is used, is a hot utility function
because most tests call it multiple times, either directly or indirectly
via other utility functions, and it turns out that the approach we use
is slower than the native `ElementHandle.boundingBox()` API.

Fortunately, most likely after a combination of Chrome/Puppeteer updates
and the conversion to the formalized WebDriver BiDi protocol the custom
solution is no longer necessary because all tests pass without it too,
so this commit converts `getRect` to use `ElementHandle.boundingBox()`
instead to speed up the tests.
2026-05-16 19:30:34 +02:00
Calixte Denizet
94de952b65
Add a Content-Security-Policy to pdf.js' viewer.html (bug 1960363) 2026-05-14 12:50:07 +02:00
Tim van der Meij
26dc195a65
Collect coverage information for the integration tests
Note that for the integration tests the coverage information ends up
being processed in the Node.js context where `window` is not available,
so we use `globalThis` instead for the function that merges individual
test's coverage information into the global object because that is
available in all contexts we support. For clarity we also rename said
function since we're not exclusively dealing with `window` nor worker
data anymore.
2026-05-14 12:34:12 +02:00
Calixte Denizet
a6cb30a9e5
Make sure the focus moves on the first page of the added pdf after a merge (bug 2034827) 2026-05-06 13:42:49 +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
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
Calixte Denizet
e7ec356be0
Fix free highlight on pages without images (bug 2035530) 2026-04-29 19:24:35 +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
Calixte Denizet
dc3c07b3e3 Allow free-highlighting on top of image placeholders (bug 2034980)
The `textLayerImagePlaceholder` canvas added in #20626 covers scanned
pages and was not recognized as a valid pointerdown target by
`#textLayerPointerDown`, so free highlights couldn't start.
2026-04-27 20:13:39 +02:00
Calixte Denizet
64b25a8f47
Fix merging a PDF after a page deletion (bug 2034804)
When pages carry explicit pageIndices (e.g. after a delete),
resolve insertAfter against that layout instead of the empty
base sequence. Also reject partial pageIndices combined with
insertAfter, which would race against the extraction's auto-fill.
2026-04-26 22:37:22 +02:00
Jonas Jenwald
1591ddfa8d
Merge pull request #21157 from Snuffleupagus/eslint-radix
Enable the `radix` ESLint rule
2026-04-25 22:27:21 +02:00
Jonas Jenwald
e6dba6ee34 Enable the radix ESLint rule
Many `parseInt` call-sites already provide the `radix` argument, and this rule helps improve consistency in the code-base; see https://eslint.org/docs/latest/rules/radix

*Please note:* The rule is disabled in `src/scripting_api/util.js` for now, since it's not obvious at a glance (at least to me) what the correct `radix` argument should be there.
2026-04-25 12:13:12 +02:00
calixteman
30d060c77a
Merge pull request #21151 from calixteman/bug2034568
Fix clicking on a thumbnail image not navigating to the correct page when using a screen reader (bug 2034568)
2026-04-25 08:20:25 +02:00
Tim van der Meij
7dc4812643
Merge pull request #21138 from calixteman/bug2034111
Fix status label mismatch after merging with a pre-existing selection (bug 2034111)
2026-04-24 20:07:50 +02:00
calixteman
2d896faa1e
Merge pull request #21142 from calixteman/input_color_alpha
[Ink] Replace the opacity slider with an alpha-enabled color input
2026-04-24 15:46:46 +02:00
Calixte Denizet
39eb691252
Fix status label mismatch after merging with a pre-existing selection (bug 2034111) 2026-04-24 14:13:53 +02:00
calixteman
a6382ac97d
Merge pull request #21145 from calixteman/bug2034461
Prompt the user for saving a merged pdf (bug 2034461)
2026-04-24 14:11:36 +02:00
Calixte Denizet
b669fdfc70
Fix clicking on a thumbnail image not navigating to the correct page when using a screen reader (bug 2034568)
Screen readers like NVDA fire synthetic click events on the <img> child of the button rather than on the
thumbnailImageContainer element itself, so the strict classList.contains check silently failed.
2026-04-24 10:10:59 +02:00
Calixte Denizet
987edbb646
Switch to a wasm file for the quickjs sandbox 2026-04-23 22:34:48 +02:00
Calixte Denizet
f266c4d8b8
[Ink] Replace the opacity slider with an alpha-enabled color input
The alpha feature is available in Firefox nightly (with the pref `dom.forms.html_color_picker.enabled` set to `true`).
It's available in Safari but not in Chrome.
2026-04-23 21:37:37 +02:00
Calixte Denizet
302bc5f4d9
Prompt the user for saving a merged pdf (bug 2034461) 2026-04-23 18:37:56 +02:00
Calixte Denizet
733a9b55a6
Fix integration tests failing because the focus isn't on the right element 2026-04-14 21:31:13 +02:00
Calixte Denizet
8c9b819b4e
Add the UI for merging PDFs (bug 2028071) 2026-04-13 19:38:56 +02:00
Calixte Denizet
ea15ac31ef Dont revoke blob URLs while printing but do it after
It fixes #19988.

In Firefox, when printing, the document is cloned and use an image cache
which isn't available when there's a service worker.
2026-04-08 14:04:09 +02:00
calixteman
ca85d73335
Merge pull request #21043 from timvandermeij/integration-test-intermittents-find-count
Fix intermittent integration test failures related to checking the find count results text
2026-04-04 20:21:52 +02:00
Tim van der Meij
24e5377240
Fix intermittent failure in the "must check that the comment sidebar is resizable with the keyboard" comment integration test
In PR #20887 the issue got fixed partly, but two issues remained that
unintendedly left room for intermittent failres:

- in the "Ctrl+ArrowLeft/Right" loop the `waitForBrowserTrip` call was
  placed _before_ the actual keypresses, which means that for the final
  iteration of the loop the last key presses were not properly awaited;

- in the "ArrowLeft/ArrowRight" loop the `waitForBrowserTrip` call was
  absent, which means that we didn't wait for key presses at all.

This commit fixes the issues by consistently waiting to a browser trip
_after_ each key press to make sure the sidebar got a chance to render.
2026-04-04 19:17:54 +02:00
Tim van der Meij
6dccf85a0b
Fix intermittent integration test failures related to checking the find count results text
There is generally a small amount of time between the find call being
reported as finished and the find count results text being updated with
the correct number in the DOM, so the integration tests will fail if we
check the find results count text too soon.

This commit fixes the issue by using the `waitForTextToBe` helper
function to wait until the find count results text is what we expect it
to be. Note that we already use this helper function for this exact
purpose in other integration tests (related to reorganizing pages), and
it's also a little bit shorter/easier to read which cannot hurt.
2026-04-04 16:55:12 +02:00
Calixte Denizet
013a209e77
Use non-breakable spaces in options for the choice widget (bug 2026037)
Usual white spaces are collapsed.
2026-03-26 23:52:46 +01:00