Skip to content

Commit a0f8cba

Browse files
committed
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 68332ec.
1 parent b7a0f01 commit a0f8cba

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

test/integration/viewer_spec.mjs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -395,29 +395,13 @@ describe("PDF viewer", () => {
395395
it("must check that canvas perfectly fits the page whatever the zoom level is", async () => {
396396
await Promise.all(
397397
pages.map(async ([browserName, page]) => {
398-
if (browserName === "chrome") {
399-
// Skip the test for Chrome as `scrollIntoView` below hangs since
400-
// Puppeteer 24.5.0 and higher.
401-
// See https://github.com/mozilla/pdf.js/issues/19811.
402-
// TODO: Remove this check once the issue is fixed.
403-
return;
404-
}
405-
406398
// The pdf has a single page with a red background.
407399
// We set the viewer background to red, because when screenshoting
408400
// some part of the viewer background can be visible.
409401
// But here we don't care about the viewer background: we only
410402
// care about the page background and the canvas default color.
411-
412403
await page.evaluate(() => {
413404
document.body.style.background = "#ff0000";
414-
const toolbar = document.querySelector(".toolbar");
415-
toolbar.style.display = "none";
416-
});
417-
await page.waitForSelector(".toolbar", { visible: false });
418-
await page.evaluate(() => {
419-
const p = document.querySelector(`.page[data-page-number="1"]`);
420-
p.style.border = "none";
421405
});
422406

423407
for (let i = 0; ; i++) {

0 commit comments

Comments
 (0)