After cut & paste, the thumbnail must be correctly rendered (bug 2018162)

This commit is contained in:
Calixte Denizet 2026-02-23 18:36:55 +01:00
parent 909a700afa
commit 97d973ce09
No known key found for this signature in database
GPG Key ID: 0C5442631EE0691F
5 changed files with 71 additions and 14 deletions

View File

@ -128,11 +128,14 @@ class Page {
};
}
#createPartialEvaluator(handler) {
#createPartialEvaluator(handler, pageIndex = this.pageIndex) {
// The pageIndex is used to identify the page some objects (like images)
// belong to.
return new PartialEvaluator({
xref: this.xref,
handler,
pageIndex: this.pageIndex,
pageIndex,
idFactory: this._localIdFactory,
fontCache: this.fontCache,
builtInCMapCache: this.builtInCMapCache,
@ -463,7 +466,6 @@ class Page {
task,
intent,
cacheKey,
pageId = this.pageIndex,
pageIndex = this.pageIndex,
annotationStorage = null,
modifiedIds = null,
@ -471,7 +473,7 @@ class Page {
const contentStreamPromise = this.getContentStream();
const resourcesPromise = this.loadResources(RESOURCES_KEYS_OPERATOR_LIST);
const partialEvaluator = this.#createPartialEvaluator(handler);
const partialEvaluator = this.#createPartialEvaluator(handler, pageIndex);
const newAnnotsByPage = !this.xfaFactory
? getNewAnnotationsMap(annotationStorage)

View File

@ -984,4 +984,60 @@ describe("Reorganize Pages View", () => {
);
});
});
describe("Thumbnails are not blank after cut/paste (bug 2018162)", () => {
let pages;
beforeEach(async () => {
pages = await loadAndWait(
"two_pages.pdf",
"#viewsManagerToggleButton",
"page-fit",
null,
{ enableSplitMerge: true }
);
});
afterEach(async () => {
await closePages(pages);
});
it("should check that the thumbnail has a blob src after cut and paste", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await waitForThumbnailVisible(page, 1);
await page.waitForSelector("#viewsManagerStatusActionButton", {
visible: true,
});
await waitAndClick(
page,
`.thumbnail:has(${getThumbnailSelector(1)}) input`
);
for (let i = 1; i <= 2; i++) {
await page.waitForSelector(
`${getThumbnailSelector(i)} > img[src^="blob:http:"]`,
{ visible: true }
);
}
let handlePagesEdited = await waitForPagesEdited(page, "cut");
await waitAndClick(page, "#viewsManagerStatusActionButton");
await waitAndClick(page, "#viewsManagerStatusActionCut");
await awaitPromise(handlePagesEdited);
handlePagesEdited = await waitForPagesEdited(page);
await waitAndClick(page, `${getThumbnailSelector(1)}+button`);
await awaitPromise(handlePagesEdited);
for (let i = 1; i <= 2; i++) {
await page.waitForSelector(
`${getThumbnailSelector(i)} > img[src^="blob:http:"]`,
{ visible: true }
);
}
})
);
});
});
});

View File

@ -52,10 +52,9 @@ describe("PDF Thumbnail View", () => {
await waitForThumbnailVisible(page, 1);
const src = await page.$eval(thumbSelector, el => el.src);
expect(src)
.withContext(`In ${browserName}`)
.toMatch(/^blob:http:/);
await page.waitForSelector(`${thumbSelector}[src^="blob:http:"]`, {
visible: true,
});
})
);
});
@ -116,13 +115,12 @@ describe("PDF Thumbnail View", () => {
`.thumbnail ${thumbSelector}[aria-current="page"]`,
{ visible: true }
);
const src = await page.$eval(
`${thumbSelector} > img`,
el => el.src
await page.waitForSelector(
`${thumbSelector} > img[src^="blob:http:"]`,
{
visible: true,
}
);
expect(src)
.withContext(`In ${browserName}`)
.toMatch(/^blob:http:/);
}
})
);

View File

@ -873,3 +873,4 @@
!Brotli-Prototype-FileA.pdf
!bug2013793.pdf
!bug2014080.pdf
!two_pages.pdf

BIN
test/pdfs/two_pages.pdf Executable file

Binary file not shown.