Skip to content

Commit

Permalink
Clean up before closing the tab in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Jun 18, 2024
1 parent 06800cd commit c1f7363
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion test/integration/test_utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ function closePages(pages) {
return Promise.all(
pages.map(async ([_, page]) => {
// Avoid to keep something from a previous test.
await page.evaluate(() => window.localStorage.clear());
await page.evaluate(() => {
const viewer = window.PDFViewerApplication;
viewer.unbindWindowEvents();
viewer.unbindEvents();
window.localStorage.clear();
});
await page.close({ runBeforeUnload: false });
})
);
Expand Down
6 changes: 5 additions & 1 deletion web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2098,9 +2098,13 @@ const PDFViewerApplication = {
unbindWindowEvents() {
this._windowAbortController?.abort();
this._windowAbortController = null;
if (AppOptions.get("isInAutomation")) {
if (
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) ||
AppOptions.get("isInAutomation")
) {
this._globalAbortController?.abort();
this._globalAbortController = null;
this.pdfHistory?.reset();
}
},

Expand Down

0 comments on commit c1f7363

Please sign in to comment.