Skip to content

Commit

Permalink
Merge pull request #18289 from Snuffleupagus/app-testingClose
Browse files Browse the repository at this point in the history
Add a new helper, in the viewer, to close everything during testing
  • Loading branch information
Snuffleupagus committed Jun 19, 2024
2 parents b7d194f + c771ac8 commit 94cbe9e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
5 changes: 1 addition & 4 deletions test/integration/test_utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
23 changes: 15 additions & 8 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 94cbe9e

Please sign in to comment.