1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #18271 from calixteman/clean_before_closing

Clean up before closing the tab in integration tests
This commit is contained in:
calixteman 2024-06-18 16:55:53 +02:00 committed by GitHub
commit 4c041586fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -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 });
})
);

View file

@ -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;
}