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

[Editor] Don't try to use an non-existing canvas when rendering an invisible existing stamp editor

It fixes #19239.

When the canvas isn't existing the editor has no image: it's fine because the editor is invisible.
Once it's made visible, the canvas is set when the annotation layer has been rendered.
This commit is contained in:
Calixte Denizet 2025-01-09 18:10:47 +01:00
parent f1166f480f
commit 06f72d5662
7 changed files with 160 additions and 15 deletions

View file

@ -1745,4 +1745,73 @@ describe("Stamp Editor", () => {
);
});
});
describe("Switch to edit mode a pdf with an existing stamp annotation on an invisible and rendered page", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("issue19239.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
await closePages(pages);
});
it("must move on the second page", async () => {
await Promise.all(
pages.map(async ([, page]) => {
const pageOneSelector = `.page[data-page-number = "1"]`;
const pageTwoSelector = `.page[data-page-number = "2"]`;
await scrollIntoView(page, pageTwoSelector);
await page.waitForSelector(pageOneSelector, {
visible: false,
});
await switchToStamp(page);
await scrollIntoView(page, pageOneSelector);
await page.waitForSelector(
`${pageOneSelector} .annotationEditorLayer canvas`,
{ visible: true }
);
})
);
});
});
describe("Switch to edit mode a pdf with an existing stamp annotation on an invisible and unrendered page", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("issue19239.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
await closePages(pages);
});
it("must move on the last page", async () => {
await Promise.all(
pages.map(async ([, page]) => {
const twoToFourteen = Array.from(new Array(13).keys(), n => n + 2);
for (const pageNumber of twoToFourteen) {
const pageSelector = `.page[data-page-number = "${pageNumber}"]`;
await scrollIntoView(page, pageSelector);
}
await switchToStamp(page);
const thirteenToOne = Array.from(new Array(13).keys(), n => 13 - n);
for (const pageNumber of thirteenToOne) {
const pageSelector = `.page[data-page-number = "${pageNumber}"]`;
await scrollIntoView(page, pageSelector);
}
await page.waitForSelector(
`.page[data-page-number = "1"] .annotationEditorLayer canvas`,
{ visible: true }
);
})
);
});
});
});

View file

@ -693,3 +693,4 @@
!issue19182.pdf
!issue18911.pdf
!issue19207.pdf
!issue19239.pdf

BIN
test/pdfs/issue19239.pdf Executable file

Binary file not shown.