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 43be717
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion test/integration/test_utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ 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(async () => {
const viewer = window.PDFViewerApplication;
viewer.unbindWindowEvents();
viewer.unbindEvents();
await viewer.close();
window.localStorage.clear();
});
await page.close({ runBeforeUnload: false });
})
);
Expand Down
5 changes: 4 additions & 1 deletion web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,10 @@ 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;
}
Expand Down

0 comments on commit 43be717

Please sign in to comment.