Skip to content

Commit

Permalink
Bug 1873987 - Ensure translations are complete before test cleanup r=…
Browse files Browse the repository at this point in the history
…translations-reviewers,gregtatum

Ensures that there are no pending translations before
test cleanup by returning to a blank page at the start
of the cleanup() function.

Depends on D199146

Differential Revision: https://phabricator.services.mozilla.com/D199381
  • Loading branch information
nordzilla committed Jan 23, 2024
1 parent ac146a6 commit 3b70244
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions toolkit/components/translations/tests/browser/shared-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ async function openAboutTranslations({
runInPage
);

await loadBlankPage();
BrowserTestUtils.removeTab(tab);

await removeMocks();
Expand Down Expand Up @@ -441,6 +442,7 @@ async function setupActorTest({
actor,
remoteClients,
async cleanup() {
await loadBlankPage();
await TranslationsParent.destroyEngineProcess();
await closeTranslationsPanelIfOpen();
await closeContextMenuIfOpen();
Expand Down Expand Up @@ -583,6 +585,7 @@ async function loadTestPage({
* @returns {Promise<void>}
*/
async cleanup() {
await loadBlankPage();
await TranslationsParent.destroyEngineProcess();
await closeTranslationsPanelIfOpen();
await closeContextMenuIfOpen();
Expand Down Expand Up @@ -1063,6 +1066,7 @@ async function setupAboutPreferences(
const elements = await selectAboutPreferencesElements();

async function cleanup() {
await loadBlankPage();
await TranslationsParent.destroyEngineProcess();
await closeTranslationsPanelIfOpen();
await closeContextMenuIfOpen();
Expand Down Expand Up @@ -1424,3 +1428,15 @@ function promiseLoadSubDialog(aURL) {
);
});
}

/**
* Loads the blank-page URL.
*
* This is useful for resetting the state during cleanup, and also
* before starting a test, to further help ensure that there is no
* unintentional state left over from test case.
*/
async function loadBlankPage() {
BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, BLANK_PAGE);
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
}

0 comments on commit 3b70244

Please sign in to comment.