Skip to content

Commit

Permalink
Merge pull request #18271 from calixteman/clean_before_closing
Browse files Browse the repository at this point in the history
Clean up before closing the tab in integration tests
  • Loading branch information
calixteman authored Jun 18, 2024
2 parents 4c82438 + 43be717 commit 4c04158
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 4c04158

Please sign in to comment.