Skip to content

Commit

Permalink
Try to shutdown Fluent "more" when closing the viewer during testing
Browse files Browse the repository at this point in the history
Even with PR 18280 fixed, we still *occasionally* see l10n-related errors when closing the integration-tests on the bots.
  • Loading branch information
Snuffleupagus committed Jun 22, 2024
1 parent f9ff613 commit 31e0f22
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
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
18 changes: 18 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,21 @@ class L10n {
}
}

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

// Since `disconnectRoot` still triggers asynchronous operations, without
// any way to actually cancel them, attempt to workaround timing issues
// when closing the integration-tests.
await new Promise(resolve => {
window.requestAnimationFrame(resolve);
});
}

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

0 comments on commit 31e0f22

Please sign in to comment.