Skip to content

Commit b43c8ea

Browse files
Merge pull request #20725 from calixteman/bug2018162
After cut & paste, the thumbnail must be correctly rendered (bug 2018162)
2 parents 943810a + 97d973c commit b43c8ea

5 files changed

Lines changed: 71 additions & 14 deletions

File tree

src/core/document.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,14 @@ class Page {
128128
};
129129
}
130130

131-
#createPartialEvaluator(handler) {
131+
#createPartialEvaluator(handler, pageIndex = this.pageIndex) {
132+
// The pageIndex is used to identify the page some objects (like images)
133+
// belong to.
134+
132135
return new PartialEvaluator({
133136
xref: this.xref,
134137
handler,
135-
pageIndex: this.pageIndex,
138+
pageIndex,
136139
idFactory: this._localIdFactory,
137140
fontCache: this.fontCache,
138141
builtInCMapCache: this.builtInCMapCache,
@@ -463,15 +466,14 @@ class Page {
463466
task,
464467
intent,
465468
cacheKey,
466-
pageId = this.pageIndex,
467469
pageIndex = this.pageIndex,
468470
annotationStorage = null,
469471
modifiedIds = null,
470472
}) {
471473
const contentStreamPromise = this.getContentStream();
472474
const resourcesPromise = this.loadResources(RESOURCES_KEYS_OPERATOR_LIST);
473475

474-
const partialEvaluator = this.#createPartialEvaluator(handler);
476+
const partialEvaluator = this.#createPartialEvaluator(handler, pageIndex);
475477

476478
const newAnnotsByPage = !this.xfaFactory
477479
? getNewAnnotationsMap(annotationStorage)

test/integration/reorganize_pages_spec.mjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,4 +984,60 @@ describe("Reorganize Pages View", () => {
984984
);
985985
});
986986
});
987+
988+
describe("Thumbnails are not blank after cut/paste (bug 2018162)", () => {
989+
let pages;
990+
991+
beforeEach(async () => {
992+
pages = await loadAndWait(
993+
"two_pages.pdf",
994+
"#viewsManagerToggleButton",
995+
"page-fit",
996+
null,
997+
{ enableSplitMerge: true }
998+
);
999+
});
1000+
1001+
afterEach(async () => {
1002+
await closePages(pages);
1003+
});
1004+
1005+
it("should check that the thumbnail has a blob src after cut and paste", async () => {
1006+
await Promise.all(
1007+
pages.map(async ([browserName, page]) => {
1008+
await waitForThumbnailVisible(page, 1);
1009+
await page.waitForSelector("#viewsManagerStatusActionButton", {
1010+
visible: true,
1011+
});
1012+
await waitAndClick(
1013+
page,
1014+
`.thumbnail:has(${getThumbnailSelector(1)}) input`
1015+
);
1016+
1017+
for (let i = 1; i <= 2; i++) {
1018+
await page.waitForSelector(
1019+
`${getThumbnailSelector(i)} > img[src^="blob:http:"]`,
1020+
{ visible: true }
1021+
);
1022+
}
1023+
1024+
let handlePagesEdited = await waitForPagesEdited(page, "cut");
1025+
await waitAndClick(page, "#viewsManagerStatusActionButton");
1026+
await waitAndClick(page, "#viewsManagerStatusActionCut");
1027+
await awaitPromise(handlePagesEdited);
1028+
1029+
handlePagesEdited = await waitForPagesEdited(page);
1030+
await waitAndClick(page, `${getThumbnailSelector(1)}+button`);
1031+
await awaitPromise(handlePagesEdited);
1032+
1033+
for (let i = 1; i <= 2; i++) {
1034+
await page.waitForSelector(
1035+
`${getThumbnailSelector(i)} > img[src^="blob:http:"]`,
1036+
{ visible: true }
1037+
);
1038+
}
1039+
})
1040+
);
1041+
});
1042+
});
9871043
});

test/integration/thumbnail_view_spec.mjs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ describe("PDF Thumbnail View", () => {
5252

5353
await waitForThumbnailVisible(page, 1);
5454

55-
const src = await page.$eval(thumbSelector, el => el.src);
56-
expect(src)
57-
.withContext(`In ${browserName}`)
58-
.toMatch(/^blob:http:/);
55+
await page.waitForSelector(`${thumbSelector}[src^="blob:http:"]`, {
56+
visible: true,
57+
});
5958
})
6059
);
6160
});
@@ -116,13 +115,12 @@ describe("PDF Thumbnail View", () => {
116115
`.thumbnail ${thumbSelector}[aria-current="page"]`,
117116
{ visible: true }
118117
);
119-
const src = await page.$eval(
120-
`${thumbSelector} > img`,
121-
el => el.src
118+
await page.waitForSelector(
119+
`${thumbSelector} > img[src^="blob:http:"]`,
120+
{
121+
visible: true,
122+
}
122123
);
123-
expect(src)
124-
.withContext(`In ${browserName}`)
125-
.toMatch(/^blob:http:/);
126124
}
127125
})
128126
);

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,3 +873,4 @@
873873
!Brotli-Prototype-FileA.pdf
874874
!bug2013793.pdf
875875
!bug2014080.pdf
876+
!two_pages.pdf

test/pdfs/two_pages.pdf

96.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)