Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new helper, in the viewer, to close everything during testing #18289

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Snuffleupagus marked this conversation as resolved.
Show resolved Hide resolved

this._globalAbortController?.abort();
this._globalAbortController = null;

await this.close();
},

_accumulateTicks(ticks, prop) {
Expand Down