Prompt the user for saving a merged pdf (bug 2034461)

This commit is contained in:
Calixte Denizet 2026-04-23 18:37:56 +02:00
parent bede5e5bfa
commit 302bc5f4d9
No known key found for this signature in database
GPG Key ID: 0C5442631EE0691F
2 changed files with 32 additions and 1 deletions

View File

@ -3096,5 +3096,32 @@ describe("Reorganize Pages View", () => {
})
);
});
it("must mark document as needing save after merge (bug 2034461)", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await waitForThumbnailVisible(page, 1);
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/three_pages_with_number.pdf")
);
await awaitPromise(handleMerged);
const hasChanges = await page.evaluate(() =>
window.PDFViewerApplication._hasChanges()
);
expect(hasChanges).withContext(`In ${browserName}`).toBeTrue();
})
);
});
});
});

View File

@ -1352,6 +1352,8 @@ const PDFViewerApplication = {
? this.save()
: this.download());
}
delete this._mergedDocumentNeedsSaving;
this.setTitle();
classList.remove("wait");
},
@ -1898,7 +1900,8 @@ const PDFViewerApplication = {
_hasChanges() {
return (
this.pdfDocument?.annotationStorage.size > 0 ||
this.pdfThumbnailViewer?.hasStructuralChanges()
this.pdfThumbnailViewer?.hasStructuralChanges() ||
this._mergedDocumentNeedsSaving === true
);
},
@ -2436,6 +2439,7 @@ const PDFViewerApplication = {
);
return;
}
this._mergedDocumentNeedsSaving = true;
this.open({
data: modifiedPdfBytes,
filename: this._docFilename,