1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Merge pull request #18289 from Snuffleupagus/app-testingClose

Add a new helper, in the viewer, to close everything during testing
This commit is contained in:
Jonas Jenwald 2024-06-19 16:22:12 +02:00 committed by GitHub
commit 94cbe9ec23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 12 deletions

View file

@ -80,10 +80,7 @@ function closePages(pages) {
pages.map(async ([_, page]) => {
// Avoid to keep something from a previous test.
await page.evaluate(async () => {
const viewer = window.PDFViewerApplication;
viewer.unbindWindowEvents();
viewer.unbindEvents();
await viewer.close();
await window.PDFViewerApplication.testingClose();
window.localStorage.clear();
});
await page.close({ runBeforeUnload: false });

View file

@ -2105,14 +2105,21 @@ const PDFViewerApplication = {
unbindWindowEvents() {
this._windowAbortController?.abort();
this._windowAbortController = null;
if (
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) ||
AppOptions.get("isInAutomation")
) {
this._globalAbortController?.abort();
this._globalAbortController = null;
this.l10n?.pause();
}
},
/**
* @ignore
*/
async testingClose() {
this.l10n?.pause();
this.unbindEvents();
this.unbindWindowEvents();
this._globalAbortController?.abort();
this._globalAbortController = null;
await this.close();
},
_accumulateTicks(ticks, prop) {