mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-23 00:15:51 +02:00
Add an integration-test for merging a password-protected PDF
Looking at the coverage data the password-handling part of the merge functionality wasn't being tested; see e75a7cfd62/blob/src/core/worker.js (L652)
This commit is contained in:
parent
1373aa4a48
commit
feec28583d
@ -3399,6 +3399,67 @@ describe("Reorganize Pages View", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("should merge a password-protected PDF after the current page", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await waitForThumbnailVisible(page, 1);
|
||||
|
||||
// Navigate to page 2 so the merged PDF is inserted after it.
|
||||
await page.evaluate(() => {
|
||||
window.PDFViewerApplication.page = 2;
|
||||
});
|
||||
await page.waitForFunction(
|
||||
() => window.PDFViewerApplication.page === 2
|
||||
);
|
||||
await waitAndClick(page, getThumbnailSelector(2));
|
||||
|
||||
const handleMerged = await createPromise(page, resolve => {
|
||||
window.PDFViewerApplication.eventBus.on(
|
||||
"thumbnailsloaded",
|
||||
resolve,
|
||||
{ once: true }
|
||||
);
|
||||
});
|
||||
|
||||
const picker = await page.$("#viewsManagerAddFilePicker");
|
||||
await picker.uploadFile(
|
||||
path.join(__dirname, "../pdfs/issue6010_1.pdf")
|
||||
);
|
||||
|
||||
// Test with an incorrect password first,
|
||||
// to ensure that re-prompting works correctly.
|
||||
for (const password of ["Incorrect password", "abc"]) {
|
||||
await page.waitForSelector("#passwordDialog", { visible: true });
|
||||
await page.type("#password", password);
|
||||
await page.keyboard.press("Enter");
|
||||
}
|
||||
|
||||
await awaitPromise(handleMerged);
|
||||
|
||||
// Original 3 pages + 1 merged page = 4 pages total.
|
||||
await page.waitForFunction(
|
||||
() => parseInt(document.getElementById("pageNumber").max, 10) === 4
|
||||
);
|
||||
|
||||
// Focus must move to the first newly inserted page (page 3, since
|
||||
// we merged after page 2).
|
||||
await page.waitForFunction(
|
||||
() => window.PDFViewerApplication.page === 3
|
||||
);
|
||||
|
||||
// Pages 1–2 come from the original document, then the page of
|
||||
// the merged PDF, then page 3 of the original shifted to the end.
|
||||
await waitForHavingContents(page, [1, 2, "Issue 6010", 3]);
|
||||
|
||||
await waitForTextToBe(
|
||||
page,
|
||||
"#viewsManagerStatusActionLabel",
|
||||
`${FSI}1${PDI} selected`
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("should merge a corrupt PDF (with invalid pages /Count) after the current page", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user