mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-10 17:15:51 +02:00
After cut & paste, the thumbnail must be correctly rendered (bug 2018162)
This commit is contained in:
parent
909a700afa
commit
97d973ce09
@ -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({
|
return new PartialEvaluator({
|
||||||
xref: this.xref,
|
xref: this.xref,
|
||||||
handler,
|
handler,
|
||||||
pageIndex: this.pageIndex,
|
pageIndex,
|
||||||
idFactory: this._localIdFactory,
|
idFactory: this._localIdFactory,
|
||||||
fontCache: this.fontCache,
|
fontCache: this.fontCache,
|
||||||
builtInCMapCache: this.builtInCMapCache,
|
builtInCMapCache: this.builtInCMapCache,
|
||||||
@ -463,7 +466,6 @@ class Page {
|
|||||||
task,
|
task,
|
||||||
intent,
|
intent,
|
||||||
cacheKey,
|
cacheKey,
|
||||||
pageId = this.pageIndex,
|
|
||||||
pageIndex = this.pageIndex,
|
pageIndex = this.pageIndex,
|
||||||
annotationStorage = null,
|
annotationStorage = null,
|
||||||
modifiedIds = null,
|
modifiedIds = null,
|
||||||
@ -471,7 +473,7 @@ class Page {
|
|||||||
const contentStreamPromise = this.getContentStream();
|
const contentStreamPromise = this.getContentStream();
|
||||||
const resourcesPromise = this.loadResources(RESOURCES_KEYS_OPERATOR_LIST);
|
const resourcesPromise = this.loadResources(RESOURCES_KEYS_OPERATOR_LIST);
|
||||||
|
|
||||||
const partialEvaluator = this.#createPartialEvaluator(handler);
|
const partialEvaluator = this.#createPartialEvaluator(handler, pageIndex);
|
||||||
|
|
||||||
const newAnnotsByPage = !this.xfaFactory
|
const newAnnotsByPage = !this.xfaFactory
|
||||||
? getNewAnnotationsMap(annotationStorage)
|
? getNewAnnotationsMap(annotationStorage)
|
||||||
|
|||||||
@ -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 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -52,10 +52,9 @@ describe("PDF Thumbnail View", () => {
|
|||||||
|
|
||||||
await waitForThumbnailVisible(page, 1);
|
await waitForThumbnailVisible(page, 1);
|
||||||
|
|
||||||
const src = await page.$eval(thumbSelector, el => el.src);
|
await page.waitForSelector(`${thumbSelector}[src^="blob:http:"]`, {
|
||||||
expect(src)
|
visible: true,
|
||||||
.withContext(`In ${browserName}`)
|
});
|
||||||
.toMatch(/^blob:http:/);
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -116,13 +115,12 @@ describe("PDF Thumbnail View", () => {
|
|||||||
`.thumbnail ${thumbSelector}[aria-current="page"]`,
|
`.thumbnail ${thumbSelector}[aria-current="page"]`,
|
||||||
{ visible: true }
|
{ visible: true }
|
||||||
);
|
);
|
||||||
const src = await page.$eval(
|
await page.waitForSelector(
|
||||||
`${thumbSelector} > img`,
|
`${thumbSelector} > img[src^="blob:http:"]`,
|
||||||
el => el.src
|
{
|
||||||
|
visible: true,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
expect(src)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toMatch(/^blob:http:/);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -873,3 +873,4 @@
|
|||||||
!Brotli-Prototype-FileA.pdf
|
!Brotli-Prototype-FileA.pdf
|
||||||
!bug2013793.pdf
|
!bug2013793.pdf
|
||||||
!bug2014080.pdf
|
!bug2014080.pdf
|
||||||
|
!two_pages.pdf
|
||||||
|
|||||||
BIN
test/pdfs/two_pages.pdf
Executable file
BIN
test/pdfs/two_pages.pdf
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user