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

Try to shutdown Fluent "more" when closing the viewer during testing #18313

Merged
merged 1 commit into from
Jun 22, 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
7 changes: 3 additions & 4 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2111,16 +2111,15 @@ const PDFViewerApplication = {
* @ignore
*/
async testingClose() {
this.l10n?.pause();
this.findBar?.close();

this.unbindEvents();
this.unbindWindowEvents();

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

await this.close();
this.findBar?.close();

await Promise.all([this.l10n?.destroy(), this.close()]);
},

_accumulateTicks(ticks, prop) {
Expand Down
19 changes: 19 additions & 0 deletions web/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
class L10n {
#dir;

#elements = new Set();

#lang;

#l10n;
Expand Down Expand Up @@ -69,6 +71,7 @@ class L10n {

/** @inheritdoc */
async translate(element) {
this.#elements.add(element);
try {
this.#l10n.connectRoot(element);
await this.#l10n.translateRoots();
Expand All @@ -77,6 +80,22 @@ class L10n {
}
}

/** @inheritdoc */
async destroy() {
for (const element of this.#elements) {
this.#l10n.disconnectRoot(element);
}
this.#elements.clear();
this.#l10n.pauseObserving();

// Since `disconnectRoot`/`pauseObserving` can still trigger asynchronous
// operations, without any way to actually cancel them, attempt to
// workaround timing issues when closing the integration-tests.
await new Promise(resolve => {
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved
window.requestAnimationFrame(resolve);
});
}

/** @inheritdoc */
pause() {
this.#l10n.pauseObserving();
Expand Down