33 Commits

Author SHA1 Message Date
Tim van der Meij
4fd3bad67f
Tweak the "scroll into view" viewer integration test
On GitHub Actions this test could fail with `Expected 1.3125 to be less
than 1` due to slight differences in the decimals of the `rect.y` value.
However, for this check we're only really interested in full pixels, so
this commit rounds the value up to the next integer to not be affected
by small decimal differences so the test passes on GitHub Actions too.
2025-10-19 17:33:11 +02:00
Calixte Denizet
91e2f6c400 Increase the rendering quality of the detail view (bug 1991482)
But keep a lower quality when enableOptimizedPartialRendering is true because we need to compensate the time
used to compute the bboxes and since subsequent rendering are faster it's more acceptable to see
a lower quality image for few tenths of seconds.
2025-10-01 16:40:41 +02:00
Tim van der Meij
ffeaa9111a
Replace manual returns with pending in the integration tests
This allows Jasmine to track skipped tests and makes it easier to
discover them using e.g. `grep`.
2025-09-14 18:30:17 +02:00
Tim van der Meij
557eb2c7e1
Merge pull request #20253 from calixteman/scroll_and_center
Add an option in scrollIntoView and goToXY in order to be able to center vertically or horizontally the point XY in the viewer container
2025-09-11 21:20:55 +02:00
Nicolò Ribaudo
4c7bbd0fef
Reduce background canvas resolution
The size of the canvas has significant impact on the rendering
performance. If we are going to render a high-res detail
view on top of the full-page canvas, we can further
reduce the full-page canvas resolution to improve
rendering time without affecting the resolution seen by
the user.

Users will se the lower resolution when quickly scrolling around the
page, but it will then be replaced with the high-res
detail view.
2025-09-10 16:52:57 +02:00
Calixte Denizet
e1bdc34b4a Add an option in scrollIntoView and goToXY in order to be able to center vertically or horizontally the point XY in the viewer container 2025-09-09 13:10:49 +02:00
Tim van der Meij
7f74fbf8fd
Fix block spacing inconsistencies in the integration test code
Most places have a newline before/after `before{Each,All}`,
`after{Each,All}` and `it` to visually separate the blocks for clarity,
but in a handful of places this wasn't done. This commit removes the
inconsistencies so that the test code is formatted consistently.
2025-09-07 14:39:52 +02:00
Tim van der Meij
18d3dc18e0
Use WebDriver BiDi for Chrome 2025-08-24 15:58:52 +02:00
Aditi
9babc144a7 Make horizontal padding relative to device width
The fixed -400px horizontal offset used by
scrollIntoView led to horizontal scroll only moving
part-way right on narrow screens. The highlights near
the right-edge remained party or completely off
screen.

This centres the highlighted match on any viewport width while
clamping the left margin to 20-400px. On very narrow screens
the scrollbar now moves all the way to the right instead of
stopping midway.
2025-08-04 15:29:52 +05:30
Calixte Denizet
806f9c1cee Disable printing when enablePermission is true and the pdf isn't allowed to be printed (bug 1978985) 2025-07-30 19:29:01 +02:00
Tim van der Meij
a0f8cbafcf
Fix the "must check that canvas perfectly fits the page whatever the zoom level" viewer integration test
In order to screenshot the page and assert that it's monochrome,
providing a regression test for #18694, the viewer background is
configured to match the page background because screenshotting the page
always captures a small part of the viewer background as well, and this
way we can easily go over all pixels and check that they are all equal.

However, in addition to configuring the viewer background the test also
hides the toolbar and removes the page border. Especially the latter
makes `scrollIntoView` fail in both Chrome and Firefox with recent
Puppeteer versions, for reasons which remain a bit unclear.

Fortunately both hiding the toolbar and removing the page border is not
actually necessary (anymore) for the test to work, so we can simply
remove those actions to fix the issue and reduce the amount of code. To
make sure that the test still covers the original issue correctly we've
reverted the changes from #18698 and then test still fails as expected.

Fixes #19811.
Fixes 68332ec2.
2025-07-12 21:49:33 +02:00
Calixte Denizet
aaae516894 Don't focus the viewer at startup (bug 1974863)
It's useless and it causes screen readers to not always read the document title.
2025-07-02 17:34:23 +02:00
Calixte Denizet
eafc040734 Allow to have an URL as file parameter when loading the viewer 2025-06-21 14:57:24 +02:00
Calixte Denizet
b97cee2ab5 Correctly handle files with a hash sign in their names (bug 1894166)
It fixes #19990.
2025-06-20 09:21:41 +02:00
Tim van der Meij
f251e600d2
Fix intermittent failure in the "supports specifying a custom origin" viewer integration test
The problem in the original code is that `getTextAt` is called too
early and therefore returns unexpected text content. This can happen
because we call `increaseScale` and then wait for the page's text layer
to be visible, but it can take some time before the zoom actually
occurs/completes in the viewer and in the meantime the old (pre-zoom)
text layer may still be visible, causing us to continue too soon because
we don't validate that we're dealing with the post-zoom text layer.

This commit fixes the issue by simply waiting for the expected text to
show up at the given origin coordinates, which makes the test work
independent of viewer actions/timing.
2025-06-01 19:33:58 +02:00
Calixte Denizet
1225c1e39a Add a pref in order to cap the canvas area to a factor of the window one (bug 1958015)
This way it helps to reduce the overall canvas dimensions and make the rendering faster.
The drawback is that when scrolling, the page can be blurry in waiting for the rendering.

The default value is 200% on desktop and will be 100% for GeckoView.
2025-05-09 13:57:16 +02:00
Tim van der Meij
923753a66b
Skip the "must check that canvas perfectly fits the page whatever the zoom level" integration test in Chrome
This is a temporary measure to reduce noise until #19811 is fixed. Note
that this shouldn't be an issue in terms of coverage because we still
run the test in Firefox.
2025-04-13 19:32:39 +02:00
Tim van der Meij
efe4a3455a
Remove debug code from the integration tests
Doing so simplifies the code a bit, and such code is generally not
checked in because it can easily be added locally if needed.
2025-04-13 19:19:13 +02:00
Tim van der Meij
75b321b000
Isolate the viewer integration tests
To avoid being able to introduce dependencies between tests this commit
makes sure that we close the document between tests so that we can't
accidentally rely on state set by a previous test.
2025-04-13 15:24:15 +02:00
Jonas Jenwald
5b7b94c078 Spell "properly" in viewer integration-test names 2025-03-29 16:35:22 +01:00
Jonas Jenwald
221eba29b9 Don't close the secondaryToolbar when clicking inside it (PR 18385 follow-up)
When the DOM structure of the viewer was updated in PR 18385 it caused the `secondaryToolbar` to accidentally start closing when clicking inside of it, since the `secondaryToolbar` now reside *under* the `toolbar` in the DOM.

**Steps to reproduce:**
 - Open the viewer.
 - Open the `secondaryToolbar`.
 - Try to change document rotation at least *twice*.

**Expected behaviour:**
 The document rotation can be changed an arbitrary number of times.

**Actual results:**
 The `secondaryToolbar` closes after changing rotation just once.
2025-03-11 19:26:23 +01:00
Nicolò Ribaudo
de9b041b5e
Fix flakiness of CSS-only zoom test
Update the test to wait for the `pagerendered`` event of a specific
page (1), so that the `pagerendered`` event of other pages from a
previously running render doesn't resolve the `waitForPageRendered`
promise.
2025-03-01 19:10:28 +01:00
Nicolò Ribaudo
458b2ee402
[api-minor] Render high-res partial page views when falling back to CSS zoom (bug 1492303)
When rendering big PDF pages at high zoom levels, we currently fall back
to CSS zoom to avoid rendering canvases with too many pixels. This
causes zoomed in PDF to look blurry, and the text to be potentially
unreadable.

This commit adds support for rendering _part_ of a page (called
`PDFPageDetailView` in the code), so that we can render portion of a
page in a smaller canvas without hiting the maximun canvas size limit.

Specifically, we render an area of that page that is slightly larger
than the area that is visible on the screen (100% larger in each
direction, unless we have to limit it due to the maximum canvas size).
As the user scrolls around the page, we re-render a new area centered
around what is currently visible.
2025-02-21 10:00:55 -08: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
68332ec236 Avoid to have a white line around the canvas
The canvas must have the same dims as the page in order to avoid to see the page
background.
2024-09-07 20:12:29 +02:00
Calixte Denizet
75e52360ad Enable disabled integration tests for Firefox 2024-08-15 13:11:31 +01: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
Nicolò Ribaudo
de23bb9b82
Respect maxCanvasPixels when computing canvas dimensions
Ensure that we never round the canvas dimensions above `maxCanvasPixels`
by rounding them to the preceeding multiple of the display ratio rather
than the succeeding one.
2024-06-19 15:23:16 +02:00
Nicolò Ribaudo
12692d2e39
Add test for CSS-only zoom above maxCanvasPixels
This commit introduces a test to ensure that:
- When zooming below the maxCanvasPixels limit, the canvas is rendered
  with the correct size (the two sides are multiplied by the zoom factor).
- When zooming above the maxCanvasPixels limit, the canvas size is capped.
2024-06-19 15:22:53 +02:00
Nicolò Ribaudo
b7933d8750
Add origin parameter to updateScale
This parameter allows defining which point should remain
fixed while scaling the document. It can be used, for example,
to implement "zoom around the cursor" or "zoom around
pinch center".

The logic was previously implemented in `web/app.js`, but
moving it to the viewer scaling utilities themselves makes it
easier to implement similar zooming functionalities in
other embedders.
2024-05-28 16:19:47 +02:00
Nicolò Ribaudo
53d866660a
Add test for drawing delay with CSS-only zoom
This commit adds a test for 0603d1ac1843bc4098d74382beda6cc511350ccd.
Before the fix the `pagerendered` events would be fired just 2-3
milliseconds after the call to `increaseScale`/`decreaseScale`.
2024-05-21 17:17:48 +02:00
Calixte Denizet
918b500ca5 Avoid wrong scrolling when calling zoomReset
The goal of this patch is to fix the test:
https://searchfox.org/mozilla-central/source/toolkit/components/pdfjs/test/browser_pdfjs_zoom.js

It's a regression due to #17790.
2024-03-21 16:04:36 +01:00
Calixte Denizet
65d618635c When zooming the scrollbar can disappear and then no scrollend is triggered 2024-03-15 15:37:06 +01:00