summaryrefslogtreecommitdiffstats
path: root/browser/components/translations
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/translations')
-rw-r--r--browser/components/translations/content/TranslationsPanelShared.sys.mjs122
-rw-r--r--browser/components/translations/content/fullPageTranslationsPanel.inc.xhtml (renamed from browser/components/translations/content/translationsPanel.inc.xhtml)85
-rw-r--r--browser/components/translations/content/fullPageTranslationsPanel.js (renamed from browser/components/translations/content/translationsPanel.js)194
-rw-r--r--browser/components/translations/content/selectTranslationsPanel.inc.xhtml102
-rw-r--r--browser/components/translations/content/selectTranslationsPanel.js220
-rw-r--r--browser/components/translations/jar.mn4
-rw-r--r--browser/components/translations/tests/browser/browser.toml96
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_a11y_focus.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_a11y_focus.js)2
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_bad_data.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_bad_data.js)5
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_basic.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_basic.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_manual.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_manual.js)6
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_restore.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_restore.js)6
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_app_menu_never_translate_language.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_app_menu_never_translate_language.js)2
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_app_menu_never_translate_site.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_app_menu_never_translate_site.js)8
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_auto_translate_error_view.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_auto_translate_error_view.js)6
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_auto_translate_revisit_view.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_auto_translate_revisit_view.js)6
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_basics.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_basics.js)8
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_button.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_button.js)0
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_cancel.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_cancel.js)2
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_close_panel_never_translate_language_with_translations_active.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_close_panel_never_translate_language_with_translations_active.js)14
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_close_panel_never_translate_language_with_translations_inactive.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_close_panel_never_translate_language_with_translations_inactive.js)10
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_close_panel_never_translate_site.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_close_panel_never_translate_site.js)16
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_destroy.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_engine_destroy.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_destroy_pending.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_engine_destroy_pending.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_unsupported.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_engine_unsupported.js)0
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_unsupported_lang.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_engine_unsupported_lang.js)2
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_firstrun.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_firstrun.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_firstrun_revisit.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_firstrun_revisit.js)8
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_fuzzing.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_fuzzing.js)6
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_gear.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_gear.js)2
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_language.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_never_translate_language.js)10
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_never_translate_site.js)10
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site_auto.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_never_translate_site_auto.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site_basic.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_never_translate_site_basic.js)2
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site_manual.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_never_translate_site_manual.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_retry.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_retry.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_settings_unsupported_lang.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_settings_unsupported_lang.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_panel_switch_languages.js (renamed from browser/components/translations/tests/browser/browser_translations_panel_switch_languages.js)8
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_reader_mode.js (renamed from browser/components/translations/tests/browser/browser_translations_reader_mode.js)2
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_auto_translate.js (renamed from browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_auto_translate.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_basics.js (renamed from browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_basics.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_translation_failure.js (renamed from browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_translation_failure.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_unsupported_lang.js (renamed from browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_unsupported_lang.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_telemetry_open_panel.js (renamed from browser/components/translations/tests/browser/browser_translations_telemetry_open_panel.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_telemetry_panel_auto_offer.js (renamed from browser/components/translations/tests/browser/browser_translations_telemetry_panel_auto_offer.js)0
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_telemetry_panel_auto_offer_settings.js (renamed from browser/components/translations/tests/browser/browser_translations_telemetry_panel_auto_offer_settings.js)4
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_telemetry_switch_languages.js (renamed from browser/components/translations/tests/browser/browser_translations_telemetry_switch_languages.js)8
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_telemetry_translation_failure.js (renamed from browser/components/translations/tests/browser/browser_translations_telemetry_translation_failure.js)2
-rw-r--r--browser/components/translations/tests/browser/browser_translations_full_page_telemetry_translation_request.js (renamed from browser/components/translations/tests/browser/browser_translations_telemetry_translation_request.js)2
-rw-r--r--browser/components/translations/tests/browser/browser_translations_select_context_menu_with_full_page_translations_active.js8
-rw-r--r--browser/components/translations/tests/browser/browser_translations_select_panel_language_selectors.js54
-rw-r--r--browser/components/translations/tests/browser/browser_translations_select_panel_mainview_ui.js36
-rw-r--r--browser/components/translations/tests/browser/head.js604
53 files changed, 1260 insertions, 474 deletions
diff --git a/browser/components/translations/content/TranslationsPanelShared.sys.mjs b/browser/components/translations/content/TranslationsPanelShared.sys.mjs
new file mode 100644
index 0000000000..570528df3f
--- /dev/null
+++ b/browser/components/translations/content/TranslationsPanelShared.sys.mjs
@@ -0,0 +1,122 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const lazy = {};
+
+ChromeUtils.defineESModuleGetters(lazy, {
+ TranslationsParent: "resource://gre/actors/TranslationsParent.sys.mjs",
+});
+
+/**
+ * A class containing static functionality that is shared by both
+ * the FullPageTranslationsPanel and SelectTranslationsPanel classes.
+ */
+export class TranslationsPanelShared {
+ static #langListsInitState = new Map();
+
+ /**
+ * Defines lazy getters for accessing elements in the document based on provided entries.
+ *
+ * @param {Document} document - The document object.
+ * @param {object} lazyElements - An object where lazy getters will be defined.
+ * @param {object} entries - An object of key/value pairs for which to define lazy getters.
+ */
+ static defineLazyElements(document, lazyElements, entries) {
+ for (const [name, discriminator] of Object.entries(entries)) {
+ let element;
+ Object.defineProperty(lazyElements, name, {
+ get: () => {
+ if (!element) {
+ if (discriminator[0] === ".") {
+ // Lookup by class
+ element = document.querySelector(discriminator);
+ } else {
+ // Lookup by id
+ element = document.getElementById(discriminator);
+ }
+ }
+ if (!element) {
+ throw new Error(`Could not find "${name}" at "#${discriminator}".`);
+ }
+ return element;
+ },
+ });
+ }
+ }
+
+ /**
+ * Retrieves the initialization state of language lists for the specified panel.
+ *
+ * @param {FullPageTranslationsPanel | SelectTranslationsPanel} panel
+ * - The panel for which to look up the state.
+ */
+ static getLangListsInitState(panel) {
+ return TranslationsPanelShared.#langListsInitState.get(panel.id);
+ }
+
+ /**
+ * Builds the <menulist> of languages for both the "from" and "to". This can be
+ * called every time the popup is shown, as it will retry when there is an error
+ * (such as a network error) or be a noop if it's already initialized.
+ *
+ * @param {Document} document - The document object.
+ * @param {FullPageTranslationsPanel | SelectTranslationsPanel} panel
+ * - The panel for which to ensure language lists are built.
+ */
+ static async ensureLangListsBuilt(document, panel, innerWindowId) {
+ const { id } = panel;
+ switch (
+ TranslationsPanelShared.#langListsInitState.get(`${id}-${innerWindowId}`)
+ ) {
+ case "initialized":
+ // This has already been initialized.
+ return;
+ case "error":
+ case undefined:
+ // attempt to initialize
+ break;
+ default:
+ throw new Error(
+ `Unknown langList phase ${
+ TranslationsPanelShared.#langListsInitState
+ }`
+ );
+ }
+ /** @type {SupportedLanguages} */
+ const { languagePairs, fromLanguages, toLanguages } =
+ await lazy.TranslationsParent.getSupportedLanguages();
+
+ // Verify that we are in a proper state.
+ if (languagePairs.length === 0) {
+ throw new Error("No translation languages were retrieved.");
+ }
+
+ const fromPopups = panel.querySelectorAll(
+ ".translations-panel-language-menupopup-from"
+ );
+ const toPopups = panel.querySelectorAll(
+ ".translations-panel-language-menupopup-to"
+ );
+
+ for (const popup of fromPopups) {
+ for (const { langTag, displayName } of fromLanguages) {
+ const fromMenuItem = document.createXULElement("menuitem");
+ fromMenuItem.setAttribute("value", langTag);
+ fromMenuItem.setAttribute("label", displayName);
+ popup.appendChild(fromMenuItem);
+ }
+ }
+
+ for (const popup of toPopups) {
+ for (const { langTag, displayName } of toLanguages) {
+ const toMenuItem = document.createXULElement("menuitem");
+ toMenuItem.setAttribute("value", langTag);
+ toMenuItem.setAttribute("label", displayName);
+ popup.appendChild(toMenuItem);
+ }
+ }
+
+ TranslationsPanelShared.#langListsInitState.set(id, "initialized");
+ }
+}
diff --git a/browser/components/translations/content/translationsPanel.inc.xhtml b/browser/components/translations/content/fullPageTranslationsPanel.inc.xhtml
index 18769eec83..bc0c5b319f 100644
--- a/browser/components/translations/content/translationsPanel.inc.xhtml
+++ b/browser/components/translations/content/fullPageTranslationsPanel.inc.xhtml
@@ -3,68 +3,69 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html:template id="template-translations-panel">
-<panel id="translations-panel"
+<panel id="full-page-translations-panel"
class="panel-no-padding translations-panel"
type="arrow"
role="alertdialog"
noautofocus="true"
- aria-labelledby="translations-panel-header"
+ aria-labelledby="full-page-translations-panel-header"
orient="vertical"
- onclick="TranslationsPanel.handlePanelButtonEvent(event)"
- onpopupshown="TranslationsPanel.handlePanelPopupShownEvent(event)"
- onpopuphidden="TranslationsPanel.handlePanelPopupHiddenEvent(event)">
- <panelmultiview id="translations-panel-multiview"
- mainViewId="translations-panel-view-default">
- <panelview id="translations-panel-view-default"
+ onclick="FullPageTranslationsPanel.handlePanelButtonEvent(event)"
+ onpopupshown="FullPageTranslationsPanel.handlePanelPopupShownEvent(event)"
+ onpopuphidden="FullPageTranslationsPanel.handlePanelPopupHiddenEvent(event)">
+ <panelmultiview id="full-page-translations-panel-multiview"
+ mainViewId="full-page-translations-panel-view-default">
+ <panelview id="full-page-translations-panel-view-default"
class="PanelUI-subView translations-panel-view"
role="document"
mainview-with-header="true"
has-custom-header="true">
<hbox class="panel-header translations-panel-header">
<html:h1 class="translations-panel-header-wrapper">
- <html:span id="translations-panel-header"></html:span>
+ <html:span id="full-page-translations-panel-header"></html:span>
</html:h1>
<hbox class="translations-panel-beta">
<image class="translations-panel-beta-icon"></image>
</hbox>
- <toolbarbutton id="translations-panel-settings" class="panel-info-button"
+ <toolbarbutton id="translations-panel-settings"
+ class="panel-info-button translations-panel-settings-gear-icon"
data-l10n-id="translations-panel-settings-button"
closemenu="none"
- oncommand="TranslationsPanel.openSettingsPopup(this)"/>
+ oncommand="FullPageTranslationsPanel.openSettingsPopup(this)"/>
</hbox>
<vbox class="translations-panel-content">
- <html:div id="translations-panel-intro">
+ <html:div id="full-page-translations-panel-intro">
<html:span data-l10n-id="translations-panel-intro-description"></html:span>
- <html:a id="translations-panel-intro-learn-more-link"
+ <html:a id="full-page-translations-panel-intro-learn-more-link"
is="moz-support-link"
data-l10n-id="translations-panel-learn-more-link"
support-page="website-translation"
- onclick="TranslationsPanel.onLearnMoreLink()" />
+ onclick="FullPageTranslationsPanel.onLearnMoreLink()" />
</html:div>
- <vbox id="translations-panel-lang-selection">
- <label data-l10n-id="translations-panel-from-label" id="translations-panel-from-label"></label>
- <menulist id="translations-panel-from"
+ <vbox id="full-page-translations-panel-lang-selection">
+ <label data-l10n-id="translations-panel-from-label" id="full-page-translations-panel-from-label"></label>
+ <menulist id="full-page-translations-panel-from"
flex="1"
value="detect"
size="large"
aria-labelledby="translations-panel-from-label"
- oncommand="TranslationsPanel.onChangeFromLanguage(event)">
- <menupopup id="translations-panel-from-menupopup"
+ oncommand="FullPageTranslationsPanel.onChangeFromLanguage(event)">
+ <menupopup id="full-page-translations-panel-from-menupopup"
class="translations-panel-language-menupopup-from">
<menuitem data-l10n-id="translations-panel-choose-language" value=""></menuitem>
<!-- The list of <menuitem> will be dynamically inserted. -->
</menupopup>
</menulist>
- <label data-l10n-id="translations-panel-to-label" id="translations-panel-to-label"></label>
- <menulist id="translations-panel-to"
+ <label data-l10n-id="translations-panel-to-label" id="full-page-translations-panel-to-label"></label>
+ <menulist id="full-page-translations-panel-to"
flex="1"
value="detect"
size="large"
aria-labelledby="translations-panel-to-label"
- oncommand="TranslationsPanel.onChangeToLanguage(event)">
- <menupopup id="translations-panel-to-menupopup"
+ oncommand="FullPageTranslationsPanel.onChangeToLanguage(event)">
+ <menupopup id="full-page-translations-panel-to-menupopup"
class="translations-panel-language-menupopup-to">
<menuitem data-l10n-id="translations-panel-choose-language" value=""></menuitem>
<!-- The list of <menuitem> will be dynamically inserted. -->
@@ -72,69 +73,69 @@
</menulist>
</vbox>
- <vbox id="translations-panel-error" hidden="true">
+ <vbox id="full-page-translations-panel-error" hidden="true">
<hbox class="translations-panel-error-header">
<image class="translations-panel-error-icon translations-panel-error-header-icon" />
- <description id="translations-panel-error-message"></description>
+ <description id="full-page-translations-panel-error-message"></description>
</hbox>
- <hbox id="translations-panel-error-message-hint"></hbox>
+ <hbox id="full-page-translations-panel-error-message-hint"></hbox>
<hbox pack="end">
- <button id="translations-panel-translate-hint-action" />
+ <button id="full-page-translations-panel-translate-hint-action" />
</hbox>
</vbox>
</vbox>
<html:moz-button-group class="panel-footer translations-panel-footer">
- <button id="translations-panel-restore-button"
+ <button id="full-page-translations-panel-restore-button"
class="footer-button"
- oncommand="TranslationsPanel.onRestore(event);"
+ oncommand="FullPageTranslationsPanel.onRestore(event);"
data-l10n-id="translations-panel-restore-button">
</button>
- <button id="translations-panel-cancel"
+ <button id="full-page-translations-panel-cancel"
class="footer-button"
- oncommand="TranslationsPanel.onCancel(event);"
+ oncommand="FullPageTranslationsPanel.onCancel(event);"
data-l10n-id="translations-panel-translate-cancel">
</button>
- <button id="translations-panel-translate"
+ <button id="full-page-translations-panel-translate"
class="footer-button"
- oncommand="TranslationsPanel.onTranslate(event);"
+ oncommand="FullPageTranslationsPanel.onTranslate(event);"
data-l10n-id="translations-panel-translate-button"
default="true">
</button>
</html:moz-button-group>
</panelview>
- <panelview id="translations-panel-view-unsupported-language"
+ <panelview id="full-page-translations-panel-view-unsupported-language"
class="PanelUI-subView translations-panel-view"
role="document"
has-custom-header="true">
<hbox class="panel-header translations-panel-header">
<image class="translations-panel-error-icon" />
- <html:h1 id="translations-panel-unsupported-language-header">
+ <html:h1 id="full-page-translations-panel-unsupported-language-header">
<html:span data-l10n-id="translations-panel-error-unsupported"></html:span>
</html:h1>
</hbox>
<vbox class="translations-panel-content">
<html:div>
- <html:span id="translations-panel-error-unsupported-hint"></html:span>
- <html:a id="translations-panel-unsupported-learn-more-link"
+ <html:span id="full-page-translations-panel-error-unsupported-hint"></html:span>
+ <html:a id="full-page-translations-panel-unsupported-learn-more-link"
is="moz-support-link"
data-l10n-id="translations-panel-learn-more-link"
support-page="website-translation"
- onclick="TranslationsPanel.onLearnMoreLink()" />
+ onclick="FullPageTranslationsPanel.onLearnMoreLink()" />
</html:div>
</vbox>
<html:moz-button-group class="panel-footer translations-panel-footer">
- <button id="translations-panel-change-source-language"
+ <button id="full-page-translations-panel-change-source-language"
class="footer-button"
- oncommand="TranslationsPanel.onChangeSourceLanguage(event);"
+ oncommand="FullPageTranslationsPanel.onChangeSourceLanguage(event);"
data-l10n-id="translations-panel-error-change-button">
</button>
- <button id="translations-panel-dismiss-error"
+ <button id="full-page-translations-panel-dismiss-error"
class="footer-button"
- oncommand="TranslationsPanel.onCancel(event);"
+ oncommand="FullPageTranslationsPanel.onCancel(event);"
data-l10n-id="translations-panel-error-dismiss-button"
default="true">
</button>
diff --git a/browser/components/translations/content/translationsPanel.js b/browser/components/translations/content/fullPageTranslationsPanel.js
index 71aaacac4f..2e35440160 100644
--- a/browser/components/translations/content/translationsPanel.js
+++ b/browser/components/translations/content/fullPageTranslationsPanel.js
@@ -14,6 +14,8 @@ ChromeUtils.defineESModuleGetters(this, {
PageActions: "resource:///modules/PageActions.sys.mjs",
TranslationsTelemetry:
"chrome://browser/content/translations/TranslationsTelemetry.sys.mjs",
+ TranslationsPanelShared:
+ "chrome://browser/content/translations/TranslationsPanelShared.sys.mjs",
});
/**
@@ -193,7 +195,7 @@ class CheckboxPageAction {
* (the Translations actor). This class reacts to state changes coming from the
* Translations actor.
*/
-var TranslationsPanel = new (class {
+var FullPageTranslationsPanel = new (class {
/** @type {Console?} */
#console;
@@ -272,77 +274,38 @@ var TranslationsPanel = new (class {
// The rest of the elements are set by the getter below.
};
- /**
- * Define a getter on #lazyElements that gets the element by an id
- * or class name.
- */
- const getter = (name, discriminator) => {
- let element;
- Object.defineProperty(this.#lazyElements, name, {
- get: () => {
- if (!element) {
- if (discriminator[0] === ".") {
- // Lookup by class
- element = document.querySelector(discriminator);
- } else {
- // Lookup by id
- element = document.getElementById(discriminator);
- }
- }
- if (!element) {
- throw new Error(
- `Could not find "${name}" at "#${discriminator}".`
- );
- }
- return element;
- },
- });
- };
-
- // Getters by id
- getter("appMenuButton", "PanelUI-menu-button");
- getter("cancelButton", "translations-panel-cancel");
- getter(
- "changeSourceLanguageButton",
- "translations-panel-change-source-language"
- );
- getter("dismissErrorButton", "translations-panel-dismiss-error");
- getter("error", "translations-panel-error");
- getter("errorMessage", "translations-panel-error-message");
- getter("errorMessageHint", "translations-panel-error-message-hint");
- getter("errorHintAction", "translations-panel-translate-hint-action");
- getter("fromMenuList", "translations-panel-from");
- getter("fromLabel", "translations-panel-from-label");
- getter("header", "translations-panel-header");
- getter("intro", "translations-panel-intro");
- getter("introLearnMoreLink", "translations-panel-intro-learn-more-link");
- getter("langSelection", "translations-panel-lang-selection");
- getter("multiview", "translations-panel-multiview");
- getter("restoreButton", "translations-panel-restore-button");
- getter("toLabel", "translations-panel-to-label");
- getter("toMenuList", "translations-panel-to");
- getter("translateButton", "translations-panel-translate");
- getter(
- "unsupportedHeader",
- "translations-panel-unsupported-language-header"
- );
- getter("unsupportedHint", "translations-panel-error-unsupported-hint");
- getter(
- "unsupportedLearnMoreLink",
- "translations-panel-unsupported-learn-more-link"
- );
-
- // Getters by class
- getter(
- "alwaysTranslateLanguageMenuItem",
- ".always-translate-language-menuitem"
- );
- getter("manageLanguagesMenuItem", ".manage-languages-menuitem");
- getter(
- "neverTranslateLanguageMenuItem",
- ".never-translate-language-menuitem"
- );
- getter("neverTranslateSiteMenuItem", ".never-translate-site-menuitem");
+ TranslationsPanelShared.defineLazyElements(document, this.#lazyElements, {
+ alwaysTranslateLanguageMenuItem: ".always-translate-language-menuitem",
+ appMenuButton: "PanelUI-menu-button",
+ cancelButton: "full-page-translations-panel-cancel",
+ changeSourceLanguageButton:
+ "full-page-translations-panel-change-source-language",
+ dismissErrorButton: "full-page-translations-panel-dismiss-error",
+ error: "full-page-translations-panel-error",
+ errorMessage: "full-page-translations-panel-error-message",
+ errorMessageHint: "full-page-translations-panel-error-message-hint",
+ errorHintAction: "full-page-translations-panel-translate-hint-action",
+ fromMenuList: "full-page-translations-panel-from",
+ fromLabel: "full-page-translations-panel-from-label",
+ header: "full-page-translations-panel-header",
+ intro: "full-page-translations-panel-intro",
+ introLearnMoreLink:
+ "full-page-translations-panel-intro-learn-more-link",
+ langSelection: "full-page-translations-panel-lang-selection",
+ manageLanguagesMenuItem: ".manage-languages-menuitem",
+ multiview: "full-page-translations-panel-multiview",
+ neverTranslateLanguageMenuItem: ".never-translate-language-menuitem",
+ neverTranslateSiteMenuItem: ".never-translate-site-menuitem",
+ restoreButton: "full-page-translations-panel-restore-button",
+ toLabel: "full-page-translations-panel-to-label",
+ toMenuList: "full-page-translations-panel-to",
+ translateButton: "full-page-translations-panel-translate",
+ unsupportedHeader:
+ "full-page-translations-panel-unsupported-language-header",
+ unsupportedHint: "full-page-translations-panel-error-unsupported-hint",
+ unsupportedLearnMoreLink:
+ "full-page-translations-panel-unsupported-learn-more-link",
+ });
}
return this.#lazyElements;
@@ -452,74 +415,19 @@ var TranslationsPanel = new (class {
}
/**
- * @type {"initialized" | "error" | "uninitialized"}
- */
- #langListsPhase = "uninitialized";
-
- /**
* Builds the <menulist> of languages for both the "from" and "to". This can be
* called every time the popup is shown, as it will retry when there is an error
* (such as a network error) or be a noop if it's already initialized.
- *
- * TODO(Bug 1813796) This needs to be updated when the supported languages change
- * via RemoteSettings.
*/
async #ensureLangListsBuilt() {
- switch (this.#langListsPhase) {
- case "initialized":
- // This has already been initialized.
- return;
- case "error":
- // Attempt to re-initialize.
- this.#langListsPhase = "uninitialized";
- break;
- case "uninitialized":
- // Ready to initialize.
- break;
- default:
- this.console?.error("Unknown langList phase", this.#langListsPhase);
- }
-
try {
- /** @type {SupportedLanguages} */
- const { languagePairs, fromLanguages, toLanguages } =
- await TranslationsParent.getSupportedLanguages();
-
- // Verify that we are in a proper state.
- if (languagePairs.length === 0) {
- throw new Error("No translation languages were retrieved.");
- }
-
- const { panel } = this.elements;
- const fromPopups = panel.querySelectorAll(
- ".translations-panel-language-menupopup-from"
- );
- const toPopups = panel.querySelectorAll(
- ".translations-panel-language-menupopup-to"
+ await TranslationsPanelShared.ensureLangListsBuilt(
+ document,
+ this.elements.panel,
+ gBrowser.selectedBrowser.innerWindowID
);
-
- for (const popup of fromPopups) {
- for (const { langTag, displayName } of fromLanguages) {
- const fromMenuItem = document.createXULElement("menuitem");
- fromMenuItem.setAttribute("value", langTag);
- fromMenuItem.setAttribute("label", displayName);
- popup.appendChild(fromMenuItem);
- }
- }
-
- for (const popup of toPopups) {
- for (const { langTag, displayName } of toLanguages) {
- const toMenuItem = document.createXULElement("menuitem");
- toMenuItem.setAttribute("value", langTag);
- toMenuItem.setAttribute("label", displayName);
- popup.appendChild(toMenuItem);
- }
- }
-
- this.#langListsPhase = "initialized";
} catch (error) {
this.console?.error(error);
- this.#langListsPhase = "error";
}
}
@@ -616,7 +524,8 @@ var TranslationsPanel = new (class {
}
const { multiview } = this.elements;
return (
- multiview.getAttribute("mainViewId") === "translations-panel-view-default"
+ multiview.getAttribute("mainViewId") ===
+ "full-page-translations-panel-view-default"
);
}
@@ -644,7 +553,7 @@ var TranslationsPanel = new (class {
// Unconditionally hide the intro text in case the panel is re-shown.
intro.hidden = true;
- if (this.#langListsPhase === "error") {
+ if (TranslationsPanelShared.getLangListsInitState(panel) === "error") {
// There was an error, display it in the view rather than the language
// dropdowns.
const { cancelButton, errorHintAction } = this.elements;
@@ -686,7 +595,10 @@ var TranslationsPanel = new (class {
this.updateUIForReTranslation(false /* isReTranslation */);
cancelButton.hidden = false;
- multiview.setAttribute("mainViewId", "translations-panel-view-default");
+ multiview.setAttribute(
+ "mainViewId",
+ "full-page-translations-panel-view-default"
+ );
if (!this._hasShownPanel) {
actor.firstShowUriSpec = gBrowser.currentURI.spec;
@@ -709,7 +621,7 @@ var TranslationsPanel = new (class {
const { unsupportedHint } = this.elements;
multiview.setAttribute(
"mainViewId",
- "translations-panel-view-unsupported-language"
+ "full-page-translations-panel-view-unsupported-language"
);
let language;
if (langTags?.docLangTag) {
@@ -952,7 +864,7 @@ var TranslationsPanel = new (class {
*/
onLearnMoreLink() {
TranslationsParent.telemetry().panel().onLearnMoreLink();
- TranslationsPanel.close();
+ FullPageTranslationsPanel.close();
}
/*
@@ -1166,7 +1078,7 @@ var TranslationsPanel = new (class {
#openPromise = null;
/**
- * Opens the TranslationsPanel.
+ * Opens the FullPageTranslationsPanel.
*
* @param {Event} event
* @param {boolean} reportAsAutoShow
@@ -1185,7 +1097,7 @@ var TranslationsPanel = new (class {
}
/**
- * Implementation function for opening the panel. Prefer TranslationsPanel.open.
+ * Implementation function for opening the panel. Prefer FullPageTranslationsPanel.open.
*
* @param {Event} event
*/
@@ -1441,7 +1353,7 @@ var TranslationsPanel = new (class {
}
/**
- * An event handler that allows the TranslationsPanel object
+ * An event handler that allows the FullPageTranslationsPanel object
* to be compatible with the addTabsProgressListener function.
*
* @param {tabbrowser} browser
@@ -1513,7 +1425,7 @@ var TranslationsPanel = new (class {
if (detectedLanguages) {
// Ensure the cached detected languages are up to date, for instance whenever
// the user switches tabs.
- TranslationsPanel.detectedLanguages = detectedLanguages;
+ FullPageTranslationsPanel.detectedLanguages = detectedLanguages;
}
if (this.#isPopupOpen) {
@@ -1623,7 +1535,7 @@ var TranslationsPanel = new (class {
})();
XPCOMUtils.defineLazyPreferenceGetter(
- TranslationsPanel,
+ FullPageTranslationsPanel,
"_hasShownPanel",
"browser.translations.panelShown",
false
diff --git a/browser/components/translations/content/selectTranslationsPanel.inc.xhtml b/browser/components/translations/content/selectTranslationsPanel.inc.xhtml
new file mode 100644
index 0000000000..72e2bd7095
--- /dev/null
+++ b/browser/components/translations/content/selectTranslationsPanel.inc.xhtml
@@ -0,0 +1,102 @@
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<html:template id="template-select-translations-panel">
+ <panel id="select-translations-panel"
+ class="panel-no-padding translations-panel"
+ type="arrow"
+ role="alertdialog"
+ noautofocus="true"
+ aria-labelledby="translations-panel-header"
+ orient="vertical">
+ <panelmultiview id="select-translations-panel-multiview" mainViewId="select-translations-panel-view-default">
+ <panelview id="select-translations-panel-view-default"
+ class="PanelUI-subView translations-panel-view"
+ role="document"
+ mainview-with-header="true"
+ has-custom-header="true">
+ <hbox class="panel-header select-translations-panel-header">
+ <html:h1 class="translations-panel-header-wrapper">
+ <html:span id="select-translations-panel-header" data-l10n-id="select-translations-panel-header">
+ </html:span>
+ </html:h1>
+ <hbox class="translations-panel-beta">
+ <image id="select-translations-panel-beta-icon"
+ class="translations-panel-beta-icon">
+ </image>
+ </hbox>
+ <toolbarbutton id="select-translations-panel-settings"
+ class="panel-info-button translations-panel-settings-gear-icon"
+ data-l10n-id="translations-panel-settings-button"
+ closemenu="none" />
+ </hbox>
+ <vbox class="select-translations-panel-content">
+ <hbox id="select-translations-panel-lang-selection">
+ <vbox flex="1">
+ <label id="select-translations-panel-from-label"
+ class="select-translations-panel-label"
+ data-l10n-id="select-translations-panel-from-label">
+ </label>
+ <menulist id="select-translations-panel-from"
+ flex="1"
+ value="detect"
+ size="large"
+ data-l10n-id="translations-panel-choose-language"
+ aria-labelledby="translations-panel-from-label">
+ <menupopup id="select-translations-panel-from-menupopup"
+ class="translations-panel-language-menupopup-from">
+ <!-- The list of <menuitem> will be dynamically inserted. -->
+ </menupopup>
+ </menulist>
+ </vbox>
+ <vbox flex="1">
+ <label id="select-translations-panel-to-label"
+ class="select-translations-panel-label"
+ data-l10n-id="select-translations-panel-to-label">
+ </label>
+ <menulist id="select-translations-panel-to"
+ flex="1"
+ value="detect"
+ size="large"
+ data-l10n-id="translations-panel-choose-language"
+ aria-labelledby="translations-panel-to-label">
+ <menupopup id="select-translations-panel-to-menupopup"
+ class="translations-panel-language-menupopup-to">
+ <!-- The list of <menuitem> will be dynamically inserted. -->
+ </menupopup>
+ </menulist>
+ </vbox>
+ </hbox>
+ </vbox>
+ <vbox class="select-translations-panel-content">
+ <html:textarea id="select-translations-panel-translation-area"
+ data-l10n-id="select-translations-panel-placeholder-text"
+ readonly="true"
+ tabindex="0">
+ </html:textarea>
+ </vbox>
+
+ <hbox class="select-translations-panel-content">
+ <button id="select-translations-panel-copy-button"
+ class="footer-button select-translations-panel-button select-translations-panel-copy-button"
+ data-l10n-id="select-translations-panel-copy-button">
+ </button>
+ </hbox>
+
+ <html:moz-button-group class="panel-footer translations-panel-footer">
+ <button id="select-translations-panel-translate-full-page-button"
+ class="footer-button select-translations-panel-button"
+ data-l10n-id="select-translations-panel-translate-full-page-button">
+ </button>
+ <button id="select-translations-panel-done-button"
+ class="footer-button select-translations-panel-button"
+ data-l10n-id="select-translations-panel-done-button"
+ default="true"
+ oncommand = "SelectTranslationsPanel.close()">
+ </button>
+ </html:moz-button-group>
+ </panelview>
+ </panelmultiview>
+ </panel>
+</html:template>
diff --git a/browser/components/translations/content/selectTranslationsPanel.js b/browser/components/translations/content/selectTranslationsPanel.js
new file mode 100644
index 0000000000..b4fe3e9735
--- /dev/null
+++ b/browser/components/translations/content/selectTranslationsPanel.js
@@ -0,0 +1,220 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* eslint-env mozilla/browser-window */
+
+ChromeUtils.defineESModuleGetters(this, {
+ LanguageDetector:
+ "resource://gre/modules/translation/LanguageDetector.sys.mjs",
+ TranslationsPanelShared:
+ "chrome://browser/content/translations/TranslationsPanelShared.sys.mjs",
+});
+
+/**
+ * This singleton class controls the Translations popup panel.
+ */
+var SelectTranslationsPanel = new (class {
+ /** @type {Console?} */
+ #console;
+
+ /**
+ * Lazily get a console instance. Note that this script is loaded in very early to
+ * the browser loading process, and may run before the console is available. In
+ * this case the console will return as `undefined`.
+ *
+ * @returns {Console | void}
+ */
+ get console() {
+ if (!this.#console) {
+ try {
+ this.#console = console.createInstance({
+ maxLogLevelPref: "browser.translations.logLevel",
+ prefix: "Translations",
+ });
+ } catch {
+ // The console may not be initialized yet.
+ }
+ }
+ return this.#console;
+ }
+
+ /**
+ * Where the lazy elements are stored.
+ *
+ * @type {Record<string, Element>?}
+ */
+ #lazyElements;
+
+ /**
+ * Lazily creates the dom elements, and lazily selects them.
+ *
+ * @returns {Record<string, Element>}
+ */
+ get elements() {
+ if (!this.#lazyElements) {
+ // Lazily turn the template into a DOM element.
+ /** @type {HTMLTemplateElement} */
+ const wrapper = document.getElementById(
+ "template-select-translations-panel"
+ );
+
+ const panel = wrapper.content.firstElementChild;
+ const settingsButton = document.getElementById(
+ "translations-panel-settings"
+ );
+ wrapper.replaceWith(wrapper.content);
+
+ // Lazily select the elements.
+ this.#lazyElements = {
+ panel,
+ settingsButton,
+ };
+
+ TranslationsPanelShared.defineLazyElements(document, this.#lazyElements, {
+ betaIcon: "select-translations-panel-beta-icon",
+ copyButton: "select-translations-panel-copy-button",
+ doneButton: "select-translations-panel-done-button",
+ fromLabel: "select-translations-panel-from-label",
+ fromMenuList: "select-translations-panel-from",
+ header: "select-translations-panel-header",
+ multiview: "select-translations-panel-multiview",
+ textArea: "select-translations-panel-translation-area",
+ toLabel: "select-translations-panel-to-label",
+ toMenuList: "select-translations-panel-to",
+ translateFullPageButton:
+ "select-translations-panel-translate-full-page-button",
+ });
+ }
+
+ return this.#lazyElements;
+ }
+
+ /**
+ * Detects the language of the provided text and retrieves a language pair for translation
+ * based on user settings.
+ *
+ * @param {string} textToTranslate - The text for which the language detection and target language retrieval are performed.
+ * @returns {Promise<{fromLang?: string, toLang?: string}>} - An object containing the language pair for the translation.
+ * The `fromLang` property is omitted if it is a language that is not currently supported by Firefox Translations.
+ * The `toLang` property is omitted if it is the same as `fromLang`.
+ */
+ async getLangPairPromise(textToTranslate) {
+ const [fromLang, toLang] = await Promise.all([
+ LanguageDetector.detectLanguage(textToTranslate).then(
+ ({ language }) => language
+ ),
+ TranslationsParent.getTopPreferredSupportedToLang(),
+ ]);
+
+ return {
+ fromLang,
+ // If the fromLang and toLang are the same, discard the toLang.
+ toLang: fromLang === toLang ? undefined : toLang,
+ };
+ }
+
+ /**
+ * Close the Select Translations Panel.
+ */
+ close() {
+ PanelMultiView.hidePopup(this.elements.panel);
+ }
+
+ /**
+ * Builds the <menulist> of languages for both the "from" and "to". This can be
+ * called every time the popup is shown, as it will retry when there is an error
+ * (such as a network error) or be a noop if it's already initialized.
+ */
+ async #ensureLangListsBuilt() {
+ try {
+ await TranslationsPanelShared.ensureLangListsBuilt(
+ document,
+ this.elements.panel
+ );
+ } catch (error) {
+ this.console?.error(error);
+ }
+ }
+
+ /**
+ * Updates the language dropdown based on the provided language tag.
+ *
+ * @param {string} langTag - A BCP-47 language tag.
+ * @param {Element} menuList - The dropdown menu element that will be updated based on language support.
+ * @returns {Promise<void>}
+ */
+ async #updateLanguageDropdown(langTag, menuList) {
+ const langTagIsSupported =
+ menuList.id === this.elements.fromMenuList.id
+ ? await TranslationsParent.isSupportedAsFromLang(langTag)
+ : await TranslationsParent.isSupportedAsToLang(langTag);
+
+ if (langTagIsSupported) {
+ // Remove the data-l10n-id because the menulist label will
+ // be populated from the supported language's display name.
+ menuList.value = langTag;
+ menuList.removeAttribute("data-l10n-id");
+ } else {
+ // Set the data-l10n-id placeholder because no valid
+ // language will be selected when the panel opens.
+ menuList.value = undefined;
+ document.l10n.setAttributes(
+ menuList,
+ "translations-panel-choose-language"
+ );
+ await document.l10n.translateElements([menuList]);
+ }
+ }
+
+ /**
+ * Updates the language selection dropdowns based on the given langPairPromise.
+ *
+ * @param {Promise<{fromLang?: string, toLang?: string}>} langPairPromise
+ * @returns {Promise<void>}
+ */
+ async #updateLanguageDropdowns(langPairPromise) {
+ const { fromLang, toLang } = await langPairPromise;
+
+ this.console?.debug(`fromLang(${fromLang})`);
+ this.console?.debug(`toLang(${toLang})`);
+
+ const { fromMenuList, toMenuList } = this.elements;
+
+ await Promise.all([
+ this.#updateLanguageDropdown(fromLang, fromMenuList),
+ this.#updateLanguageDropdown(toLang, toMenuList),
+ ]);
+ }
+
+ /**
+ * Opens the panel and populates the currently selected fromLang and toLang based
+ * on the result of the langPairPromise.
+ *
+ * @param {Event} event - The triggering event for opening the panel.
+ * @param {Promise} langPairPromise - Promise resolving to language pair data for initializing dropdowns.
+ * @returns {Promise<void>}
+ */
+ async open(event, langPairPromise) {
+ this.console?.log("Showing a translation panel.");
+
+ await this.#ensureLangListsBuilt();
+ await this.#updateLanguageDropdowns(langPairPromise);
+
+ // TODO(Bug 1878721) Rework the logic of where to open the panel.
+ //
+ // For the moment, the Select Translations panel opens at the
+ // AppMenu Button, but it will eventually need to open near
+ // to the selected content.
+ const appMenuButton = document.getElementById("PanelUI-menu-button");
+ const { panel, textArea } = this.elements;
+
+ panel.addEventListener("popupshown", () => textArea.focus(), {
+ once: true,
+ });
+ await PanelMultiView.openPopup(panel, appMenuButton, {
+ position: "bottomright topright",
+ triggerEvent: event,
+ }).catch(error => this.console?.error(error));
+ }
+})();
diff --git a/browser/components/translations/jar.mn b/browser/components/translations/jar.mn
index 5f30e6f73f..fe552d2c9a 100644
--- a/browser/components/translations/jar.mn
+++ b/browser/components/translations/jar.mn
@@ -3,4 +3,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
browser.jar:
- content/browser/translations/translationsPanel.js (content/translationsPanel.js)
+ content/browser/translations/selectTranslationsPanel.js (content/selectTranslationsPanel.js)
+ content/browser/translations/fullPageTranslationsPanel.js (content/fullPageTranslationsPanel.js)
+ content/browser/translations/TranslationsPanelShared.sys.mjs (content/TranslationsPanelShared.sys.mjs)
diff --git a/browser/components/translations/tests/browser/browser.toml b/browser/components/translations/tests/browser/browser.toml
index bc617bf2fd..a9d36363da 100644
--- a/browser/components/translations/tests/browser/browser.toml
+++ b/browser/components/translations/tests/browser/browser.toml
@@ -15,96 +15,100 @@ support-files = [
["browser_translations_about_preferences_settings_ui.js"]
-["browser_translations_panel_a11y_focus.js"]
+["browser_translations_full_page_panel_a11y_focus.js"]
-["browser_translations_panel_always_translate_language_bad_data.js"]
+["browser_translations_full_page_panel_always_translate_language_bad_data.js"]
-["browser_translations_panel_always_translate_language_basic.js"]
+["browser_translations_full_page_panel_always_translate_language_basic.js"]
-["browser_translations_panel_always_translate_language_manual.js"]
+["browser_translations_full_page_panel_always_translate_language_manual.js"]
-["browser_translations_panel_always_translate_language_restore.js"]
+["browser_translations_full_page_panel_always_translate_language_restore.js"]
-["browser_translations_panel_app_menu_never_translate_language.js"]
+["browser_translations_full_page_panel_app_menu_never_translate_language.js"]
-["browser_translations_panel_app_menu_never_translate_site.js"]
+["browser_translations_full_page_panel_app_menu_never_translate_site.js"]
-["browser_translations_panel_auto_translate_error_view.js"]
+["browser_translations_full_page_panel_auto_translate_error_view.js"]
-["browser_translations_panel_auto_translate_revisit_view.js"]
+["browser_translations_full_page_panel_auto_translate_revisit_view.js"]
-["browser_translations_panel_basics.js"]
+["browser_translations_full_page_panel_basics.js"]
-["browser_translations_panel_button.js"]
+["browser_translations_full_page_panel_button.js"]
-["browser_translations_panel_cancel.js"]
+["browser_translations_full_page_panel_cancel.js"]
-["browser_translations_panel_close_panel_never_translate_language_with_translations_active.js"]
+["browser_translations_full_page_panel_close_panel_never_translate_language_with_translations_active.js"]
-["browser_translations_panel_close_panel_never_translate_language_with_translations_inactive.js"]
+["browser_translations_full_page_panel_close_panel_never_translate_language_with_translations_inactive.js"]
-["browser_translations_panel_close_panel_never_translate_site.js"]
+["browser_translations_full_page_panel_close_panel_never_translate_site.js"]
-["browser_translations_panel_engine_destroy.js"]
+["browser_translations_full_page_panel_engine_destroy.js"]
-["browser_translations_panel_engine_destroy_pending.js"]
+["browser_translations_full_page_panel_engine_destroy_pending.js"]
-["browser_translations_panel_engine_unsupported.js"]
+["browser_translations_full_page_panel_engine_unsupported.js"]
-["browser_translations_panel_engine_unsupported_lang.js"]
+["browser_translations_full_page_panel_engine_unsupported_lang.js"]
-["browser_translations_panel_firstrun.js"]
+["browser_translations_full_page_panel_firstrun.js"]
-["browser_translations_panel_firstrun_revisit.js"]
+["browser_translations_full_page_panel_firstrun_revisit.js"]
-["browser_translations_panel_fuzzing.js"]
+["browser_translations_full_page_panel_fuzzing.js"]
skip-if = ["true"]
-["browser_translations_panel_gear.js"]
+["browser_translations_full_page_panel_gear.js"]
-["browser_translations_panel_never_translate_language.js"]
+["browser_translations_full_page_panel_never_translate_language.js"]
-["browser_translations_panel_never_translate_site_auto.js"]
+["browser_translations_full_page_panel_never_translate_site_auto.js"]
-["browser_translations_panel_never_translate_site_basic.js"]
+["browser_translations_full_page_panel_never_translate_site_basic.js"]
-["browser_translations_panel_never_translate_site_manual.js"]
+["browser_translations_full_page_panel_never_translate_site_manual.js"]
-["browser_translations_panel_retry.js"]
+["browser_translations_full_page_panel_retry.js"]
skip-if = ["os == 'linux' && !debug"] # Bug 1863227
-["browser_translations_panel_settings_unsupported_lang.js"]
+["browser_translations_full_page_panel_settings_unsupported_lang.js"]
-["browser_translations_panel_switch_languages.js"]
+["browser_translations_full_page_panel_switch_languages.js"]
-["browser_translations_reader_mode.js"]
+["browser_translations_full_page_reader_mode.js"]
-["browser_translations_select_context_menu_feature_disabled.js"]
+["browser_translations_full_page_telemetry_firstrun_auto_translate.js"]
-["browser_translations_select_context_menu_with_full_page_translations_active.js"]
+["browser_translations_full_page_telemetry_firstrun_basics.js"]
-["browser_translations_select_context_menu_with_hyperlink.js"]
+["browser_translations_full_page_telemetry_firstrun_translation_failure.js"]
-["browser_translations_select_context_menu_with_no_text_selected.js"]
+["browser_translations_full_page_telemetry_firstrun_unsupported_lang.js"]
-["browser_translations_select_context_menu_with_text_selected.js"]
+["browser_translations_full_page_telemetry_open_panel.js"]
+
+["browser_translations_full_page_telemetry_panel_auto_offer.js"]
-["browser_translations_telemetry_firstrun_auto_translate.js"]
+["browser_translations_full_page_telemetry_panel_auto_offer_settings.js"]
-["browser_translations_telemetry_firstrun_basics.js"]
+["browser_translations_full_page_telemetry_switch_languages.js"]
-["browser_translations_telemetry_firstrun_translation_failure.js"]
+["browser_translations_full_page_telemetry_translation_failure.js"]
-["browser_translations_telemetry_firstrun_unsupported_lang.js"]
+["browser_translations_full_page_telemetry_translation_request.js"]
-["browser_translations_telemetry_open_panel.js"]
+["browser_translations_select_context_menu_feature_disabled.js"]
+
+["browser_translations_select_context_menu_with_full_page_translations_active.js"]
-["browser_translations_telemetry_panel_auto_offer.js"]
+["browser_translations_select_context_menu_with_hyperlink.js"]
-["browser_translations_telemetry_panel_auto_offer_settings.js"]
+["browser_translations_select_context_menu_with_no_text_selected.js"]
-["browser_translations_telemetry_switch_languages.js"]
+["browser_translations_select_context_menu_with_text_selected.js"]
-["browser_translations_telemetry_translation_failure.js"]
+["browser_translations_select_panel_language_selectors.js"]
-["browser_translations_telemetry_translation_request.js"]
+["browser_translations_select_panel_mainview_ui.js"]
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_a11y_focus.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_a11y_focus.js
index e2e8663f6d..433861c05a 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_a11y_focus.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_a11y_focus.js
@@ -17,7 +17,7 @@ add_task(async function test_translations_panel_a11y_focus() {
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openWithKeyboard: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_bad_data.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_bad_data.js
index ac026fb78f..144488ac7b 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_bad_data.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_bad_data.js
@@ -13,7 +13,7 @@ add_task(async function test_always_translate_with_bad_data() {
prefs: [["browser.translations.alwaysTranslateLanguages", "en,fr"]],
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
openFromAppMenu: true,
});
@@ -23,8 +23,7 @@ add_task(async function test_always_translate_with_bad_data() {
checked: false,
disabled: true,
});
- await closeSettingsMenuIfOpen();
- await closeTranslationsPanelIfOpen();
+ await closeAllOpenPanelsAndMenus();
info("Checking that the page is untranslated");
await runInPage(async TranslationsTest => {
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_basic.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_basic.js
index 2644d78f33..bd9a8a7756 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_basic.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_basic.js
@@ -21,7 +21,7 @@ add_task(async function test_toggle_always_translate_language_menuitem() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -55,7 +55,7 @@ add_task(async function test_toggle_always_translate_language_menuitem() {
"The page should be automatically translated."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_manual.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_manual.js
index 8456b4cc08..d47732aa5c 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_manual.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_manual.js
@@ -22,7 +22,7 @@ add_task(
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -36,7 +36,7 @@ add_task(
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -55,7 +55,7 @@ add_task(
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_restore.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_restore.js
index 6cf89d2a03..cd3fe76c58 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_always_translate_language_restore.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_always_translate_language_restore.js
@@ -22,7 +22,7 @@ add_task(
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -56,7 +56,7 @@ add_task(
"The page should be automatically translated."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
@@ -69,7 +69,7 @@ add_task(
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_app_menu_never_translate_language.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_app_menu_never_translate_language.js
index ee2905ab99..14eb88f71f 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_app_menu_never_translate_language.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_app_menu_never_translate_language.js
@@ -22,7 +22,7 @@ add_task(async function test_uncheck_never_translate_language_shows_button() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_app_menu_never_translate_site.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_app_menu_never_translate_site.js
index 50fff4dff8..3670bb7ba1 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_app_menu_never_translate_site.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_app_menu_never_translate_site.js
@@ -21,7 +21,7 @@ add_task(async function test_uncheck_never_translate_site_shows_button() {
"The translations button is visible."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -36,7 +36,7 @@ add_task(async function test_uncheck_never_translate_site_shows_button() {
{ checked: true }
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -80,7 +80,7 @@ add_task(
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -105,7 +105,7 @@ add_task(
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_auto_translate_error_view.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_auto_translate_error_view.js
index e71ee1392b..9470133dd0 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_auto_translate_error_view.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_auto_translate_error_view.js
@@ -34,7 +34,7 @@ add_task(
"The translations button is visible."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -64,14 +64,14 @@ add_task(
"The translations button should be unavailable."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel:
FullPageTranslationsTestUtils.assertPanelViewUnsupportedLanguage,
});
info("Destroy the engine process so that an error will happen.");
- await TranslationsParent.destroyEngineProcess();
+ await EngineProcess.destroyTranslationsEngine();
await navigate("Navigate back to a Spanish page.", {
url: SPANISH_PAGE_URL_DOT_ORG,
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_auto_translate_revisit_view.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_auto_translate_revisit_view.js
index dd4ffcecfd..f898300038 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_auto_translate_revisit_view.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_auto_translate_revisit_view.js
@@ -29,7 +29,7 @@ add_task(
"The translations button is visible."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -59,7 +59,7 @@ add_task(
"The translations button should be unavailable."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel:
FullPageTranslationsTestUtils.assertPanelViewUnsupportedLanguage,
@@ -76,7 +76,7 @@ add_task(
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_basics.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_basics.js
index ef2e2c4708..30880553f0 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_basics.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_basics.js
@@ -22,11 +22,11 @@ add_task(async function test_translations_panel_basics() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
- const panel = document.getElementById("translations-panel");
+ const panel = document.getElementById("full-page-translations-panel");
const label = document.getElementById(panel.getAttribute("aria-labelledby"));
ok(label, "The a11y label for the panel can be found.");
assertVisibility({ visible: { label } });
@@ -38,7 +38,7 @@ add_task(async function test_translations_panel_basics() {
"The icon presents the loading indicator."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewLoading,
});
@@ -52,7 +52,7 @@ add_task(async function test_translations_panel_basics() {
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_button.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_button.js
index 209cfc18a6..209cfc18a6 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_button.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_button.js
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_cancel.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_cancel.js
index 17e680dd87..9a0a3ebccb 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_cancel.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_cancel.js
@@ -17,7 +17,7 @@ add_task(async function test_translations_panel_cancel() {
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_close_panel_never_translate_language_with_translations_active.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_close_panel_never_translate_language_with_translations_active.js
index 0fbffd891a..e76c771ed9 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_close_panel_never_translate_language_with_translations_active.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_close_panel_never_translate_language_with_translations_active.js
@@ -17,7 +17,7 @@ add_task(
"The translations button is available"
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -39,7 +39,7 @@ add_task(
"The page should be automatically translated."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -49,7 +49,7 @@ add_task(
await FullPageTranslationsTestUtils.assertIsNeverTranslateLanguage("es", {
checked: false,
});
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
async () => {
await FullPageTranslationsTestUtils.clickNeverTranslateLanguage();
@@ -79,7 +79,7 @@ add_task(
"The translations button is available"
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -101,7 +101,7 @@ add_task(
"The page should be automatically translated."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -119,7 +119,7 @@ add_task(
);
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -136,7 +136,7 @@ add_task(
await FullPageTranslationsTestUtils.assertIsNeverTranslateLanguage("es", {
checked: false,
});
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
async () => {
await FullPageTranslationsTestUtils.clickNeverTranslateLanguage();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_close_panel_never_translate_language_with_translations_inactive.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_close_panel_never_translate_language_with_translations_inactive.js
index 5df2468646..95ff86ba7f 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_close_panel_never_translate_language_with_translations_inactive.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_close_panel_never_translate_language_with_translations_inactive.js
@@ -16,7 +16,7 @@ add_task(async function test_panel_closes_on_toggle_never_translate_language() {
"The translations button is available"
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -26,7 +26,7 @@ add_task(async function test_panel_closes_on_toggle_never_translate_language() {
await FullPageTranslationsTestUtils.assertIsNeverTranslateLanguage("es", {
checked: false,
});
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
async () => {
await FullPageTranslationsTestUtils.clickNeverTranslateLanguage();
@@ -52,7 +52,7 @@ add_task(
"The translations button is available"
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -69,7 +69,7 @@ add_task(
{ checked: true }
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -82,7 +82,7 @@ add_task(
await FullPageTranslationsTestUtils.assertIsNeverTranslateLanguage("es", {
checked: false,
});
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
async () => {
await FullPageTranslationsTestUtils.clickNeverTranslateLanguage();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_close_panel_never_translate_site.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_close_panel_never_translate_site.js
index 78679a046a..c3d1458525 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_close_panel_never_translate_site.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_close_panel_never_translate_site.js
@@ -16,7 +16,7 @@ add_task(async function test_panel_closes_on_toggle_never_translate_site() {
"The translations button is available"
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -27,7 +27,7 @@ add_task(async function test_panel_closes_on_toggle_never_translate_site() {
SPANISH_PAGE_URL,
{ checked: false }
);
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
async () => {
await FullPageTranslationsTestUtils.clickNeverTranslateSite();
@@ -54,7 +54,7 @@ add_task(
"The translations button is available"
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -78,7 +78,7 @@ add_task(
"The page should be automatically translated."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -91,7 +91,7 @@ add_task(
{ checked: false }
);
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
async () => {
await FullPageTranslationsTestUtils.clickNeverTranslateSite();
@@ -119,7 +119,7 @@ add_task(
"The translations button is available"
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -134,7 +134,7 @@ add_task(
checked: true,
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -147,7 +147,7 @@ add_task(
SPANISH_PAGE_URL,
{ checked: false }
);
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
async () => {
await FullPageTranslationsTestUtils.clickNeverTranslateSite();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_engine_destroy.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_destroy.js
index 0a58dd7fa6..1b498f9b07 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_engine_destroy.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_destroy.js
@@ -16,7 +16,7 @@ add_task(async function test_translations_engine_destroy() {
{ button: true },
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -31,7 +31,7 @@ add_task(async function test_translations_engine_destroy() {
);
info("Destroy the engine process");
- await TranslationsParent.destroyEngineProcess();
+ await EngineProcess.destroyTranslationsEngine();
info("Mutate the page's content to re-trigger a translation.");
await runInPage(async TranslationsTest => {
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_engine_destroy_pending.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_destroy_pending.js
index ace1a845df..cfe1997093 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_engine_destroy_pending.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_destroy_pending.js
@@ -22,7 +22,7 @@ add_task(async function test_translations_engine_destroy_pending() {
{ button: true },
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -42,7 +42,7 @@ add_task(async function test_translations_engine_destroy_pending() {
);
info("Destroy the engine process");
- await TranslationsParent.destroyEngineProcess();
+ await EngineProcess.destroyTranslationsEngine();
info("Mutate the page's content to re-trigger a translation.");
await runInPage(async TranslationsTest => {
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_engine_unsupported.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_unsupported.js
index f0804f35aa..f0804f35aa 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_engine_unsupported.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_unsupported.js
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_engine_unsupported_lang.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_unsupported_lang.js
index 79e5c6b119..21f7e8fdb7 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_engine_unsupported_lang.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_engine_unsupported_lang.js
@@ -16,7 +16,7 @@ add_task(async function test_unsupported_lang() {
],
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel:
FullPageTranslationsTestUtils.assertPanelViewUnsupportedLanguage,
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_firstrun.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_firstrun.js
index 0c248a7837..ef807b9ac6 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_firstrun.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_firstrun.js
@@ -13,7 +13,7 @@ add_task(async function test_translations_panel_firstrun() {
prefs: [["browser.translations.panelShown", false]],
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewFirstShow,
});
@@ -23,7 +23,7 @@ add_task(async function test_translations_panel_firstrun() {
url: SPANISH_PAGE_URL_2,
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_firstrun_revisit.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_firstrun_revisit.js
index 02c2d94db9..998a7653c8 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_firstrun_revisit.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_firstrun_revisit.js
@@ -21,13 +21,13 @@ add_task(async function test_translations_panel_firstrun() {
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewFirstShow,
});
await FullPageTranslationsTestUtils.clickCancelButton();
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewFirstShow,
});
@@ -37,7 +37,7 @@ add_task(async function test_translations_panel_firstrun() {
url: SPANISH_PAGE_URL_DOT_ORG,
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -47,7 +47,7 @@ add_task(async function test_translations_panel_firstrun() {
url: SPANISH_PAGE_URL,
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_fuzzing.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_fuzzing.js
index 2f5285ac46..0accc3db60 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_fuzzing.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_fuzzing.js
@@ -96,7 +96,7 @@ add_task(async function test_translations_panel_fuzzing() {
{ button: true },
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -131,7 +131,7 @@ add_task(async function test_translations_panel_fuzzing() {
hasVerifiedMutation
) {
reportOperation("destroyEngineProcess");
- await TranslationsParent.destroyEngineProcess();
+ await EngineProcess.destroyTranslationsEngine();
isEngineMaybeDestroyed = true;
}
return true;
@@ -195,7 +195,7 @@ add_task(async function test_translations_panel_fuzzing() {
async restoreSpanishPage() {
if (activeTab === "spanish" && isSpanishPageTranslated) {
reportOperation("restoreSpanishPage");
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_gear.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_gear.js
index c24fc61e3d..0b9ce3ad3b 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_gear.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_gear.js
@@ -12,7 +12,7 @@ add_task(async function test_translations_panel_manage_languages() {
languagePairs: LANGUAGE_PAIRS,
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_never_translate_language.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_language.js
index 6c1fea7754..52cab172e7 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_never_translate_language.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_language.js
@@ -21,7 +21,7 @@ add_task(async function test_toggle_never_translate_language_menuitem() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -69,7 +69,7 @@ add_task(
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -83,7 +83,7 @@ add_task(
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -125,7 +125,7 @@ add_task(
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -154,7 +154,7 @@ add_task(
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_never_translate_site.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site.js
index 858aa297df..9d64da5b38 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_never_translate_site.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site.js
@@ -22,7 +22,7 @@ add_task(async function test_toggle_never_translate_site_menuitem() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -82,7 +82,7 @@ add_task(
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -96,7 +96,7 @@ add_task(
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -161,7 +161,7 @@ add_task(
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -192,7 +192,7 @@ add_task(
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_never_translate_site_auto.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site_auto.js
index 28f3b570c3..faa425c403 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_never_translate_site_auto.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site_auto.js
@@ -23,7 +23,7 @@ add_task(
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -54,7 +54,7 @@ add_task(
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_never_translate_site_basic.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site_basic.js
index 098ff54d6e..048e002f45 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_never_translate_site_basic.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site_basic.js
@@ -22,7 +22,7 @@ add_task(async function test_toggle_never_translate_site_menuitem() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_never_translate_site_manual.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site_manual.js
index d916342c33..425e202546 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_never_translate_site_manual.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_never_translate_site_manual.js
@@ -24,7 +24,7 @@ add_task(
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -38,7 +38,7 @@ add_task(
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_retry.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_retry.js
index 76a6bd9429..74d92381b9 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_retry.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_retry.js
@@ -19,7 +19,7 @@ add_task(async function test_translations_panel_retry() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -33,7 +33,7 @@ add_task(async function test_translations_panel_retry() {
runInPage
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_settings_unsupported_lang.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_settings_unsupported_lang.js
index 18fcf484dd..d371e9ed22 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_settings_unsupported_lang.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_settings_unsupported_lang.js
@@ -26,7 +26,7 @@ add_task(async function test_unsupported_language_settings_menu_checkboxes() {
"The translations button is visible."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -56,7 +56,7 @@ add_task(async function test_unsupported_language_settings_menu_checkboxes() {
"The translations button should be unavailable."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel:
FullPageTranslationsTestUtils.assertPanelViewUnsupportedLanguage,
diff --git a/browser/components/translations/tests/browser/browser_translations_panel_switch_languages.js b/browser/components/translations/tests/browser/browser_translations_full_page_panel_switch_languages.js
index 3652c61d83..0c5db67b20 100644
--- a/browser/components/translations/tests/browser/browser_translations_panel_switch_languages.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_panel_switch_languages.js
@@ -19,16 +19,16 @@ add_task(async function test_translations_panel_switch_language() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
- const { translateButton } = TranslationsPanel.elements;
+ const { translateButton } = FullPageTranslationsPanel.elements;
ok(!translateButton.disabled, "The translate button starts as enabled");
- FullPageTranslationsTestUtils.assertSelectedFromLanguage("es");
- FullPageTranslationsTestUtils.assertSelectedToLanguage("en");
+ FullPageTranslationsTestUtils.assertSelectedFromLanguage({ langTag: "es" });
+ FullPageTranslationsTestUtils.assertSelectedToLanguage({ langTag: "en" });
FullPageTranslationsTestUtils.switchSelectedFromLanguage("en");
diff --git a/browser/components/translations/tests/browser/browser_translations_reader_mode.js b/browser/components/translations/tests/browser/browser_translations_full_page_reader_mode.js
index d066257998..1a6ea9d2ec 100644
--- a/browser/components/translations/tests/browser/browser_translations_reader_mode.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_reader_mode.js
@@ -72,7 +72,7 @@ add_task(async function test_translations_persist_in_reader_mode() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_auto_translate.js b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_auto_translate.js
index abfc3dc32e..d26bcad77b 100644
--- a/browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_auto_translate.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_auto_translate.js
@@ -21,7 +21,7 @@ add_task(async function test_translations_telemetry_firstrun_auto_translate() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewFirstShow,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -74,7 +74,7 @@ add_task(async function test_translations_telemetry_firstrun_auto_translate() {
}
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_basics.js b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_basics.js
index 200e06b9ce..db6d2e3b6c 100644
--- a/browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_basics.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_basics.js
@@ -23,7 +23,7 @@ add_task(async function test_translations_telemetry_firstrun_basics() {
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewFirstShow,
});
@@ -56,7 +56,7 @@ add_task(async function test_translations_telemetry_firstrun_basics() {
expectFirstInteraction: true,
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewFirstShow,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_translation_failure.js b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_translation_failure.js
index 5397175039..75f58ab229 100644
--- a/browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_translation_failure.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_translation_failure.js
@@ -25,7 +25,7 @@ add_task(async function test_translations_telemetry_firstrun_failure() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewFirstShow,
});
@@ -113,7 +113,7 @@ add_task(async function test_translations_telemetry_firstrun_failure() {
expectFirstInteraction: true,
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewFirstShow,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_unsupported_lang.js b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_unsupported_lang.js
index fa9c67ee37..86ae21e9ed 100644
--- a/browser/components/translations/tests/browser/browser_translations_telemetry_firstrun_unsupported_lang.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_firstrun_unsupported_lang.js
@@ -19,7 +19,7 @@ add_task(
prefs: [["browser.translations.panelShown", false]],
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel:
FullPageTranslationsTestUtils.assertPanelViewUnsupportedLanguage,
@@ -83,7 +83,7 @@ add_task(
expectFirstInteraction: true,
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
openFromAppMenu: true,
onOpenPanel:
FullPageTranslationsTestUtils.assertPanelViewUnsupportedLanguage,
diff --git a/browser/components/translations/tests/browser/browser_translations_telemetry_open_panel.js b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_open_panel.js
index 64a02287e8..a49059f78f 100644
--- a/browser/components/translations/tests/browser/browser_translations_telemetry_open_panel.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_open_panel.js
@@ -21,7 +21,7 @@ add_task(async function test_translations_telemetry_open_panel() {
"The button is available."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -51,7 +51,7 @@ add_task(async function test_translations_telemetry_open_panel() {
expectNewFlowId: false,
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_telemetry_panel_auto_offer.js b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_panel_auto_offer.js
index 93ff473851..93ff473851 100644
--- a/browser/components/translations/tests/browser/browser_translations_telemetry_panel_auto_offer.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_panel_auto_offer.js
diff --git a/browser/components/translations/tests/browser/browser_translations_telemetry_panel_auto_offer_settings.js b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_panel_auto_offer_settings.js
index 9eae81904d..4a2959f58e 100644
--- a/browser/components/translations/tests/browser/browser_translations_telemetry_panel_auto_offer_settings.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_panel_auto_offer_settings.js
@@ -24,7 +24,7 @@ add_task(async function test_translations_panel_auto_offer_settings() {
expectedEventCount: 0,
});
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.openTranslationsSettingsMenu();
@@ -54,7 +54,7 @@ add_task(async function test_translations_panel_auto_offer_settings() {
}
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
await FullPageTranslationsTestUtils.assertIsAlwaysOfferTranslationsEnabled(
diff --git a/browser/components/translations/tests/browser/browser_translations_telemetry_switch_languages.js b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_switch_languages.js
index 6c06abab95..ef13940b3f 100644
--- a/browser/components/translations/tests/browser/browser_translations_telemetry_switch_languages.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_switch_languages.js
@@ -19,11 +19,11 @@ add_task(async function test_translations_telemetry_switch_from_language() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
- FullPageTranslationsTestUtils.assertSelectedFromLanguage("es");
+ FullPageTranslationsTestUtils.assertSelectedFromLanguage({ langTag: "es" });
FullPageTranslationsTestUtils.switchSelectedFromLanguage("en");
await TestTranslationsTelemetry.assertEvent(Glean.translationsPanel.open, {
@@ -95,11 +95,11 @@ add_task(async function test_translations_telemetry_switch_to_language() {
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
- FullPageTranslationsTestUtils.assertSelectedToLanguage("en");
+ FullPageTranslationsTestUtils.assertSelectedToLanguage({ langTag: "en" });
FullPageTranslationsTestUtils.switchSelectedToLanguage("fr");
await TestTranslationsTelemetry.assertEvent(Glean.translationsPanel.open, {
diff --git a/browser/components/translations/tests/browser/browser_translations_telemetry_translation_failure.js b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_translation_failure.js
index e7d0cfb4f4..7a9f58970a 100644
--- a/browser/components/translations/tests/browser/browser_translations_telemetry_translation_failure.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_translation_failure.js
@@ -44,7 +44,7 @@ add_task(
}
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_telemetry_translation_request.js b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_translation_request.js
index 90bd81a8ed..e671f5e0da 100644
--- a/browser/components/translations/tests/browser/browser_translations_telemetry_translation_request.js
+++ b/browser/components/translations/tests/browser/browser_translations_full_page_telemetry_translation_request.js
@@ -39,7 +39,7 @@ add_task(async function test_translations_telemetry_manual_translation() {
}
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_select_context_menu_with_full_page_translations_active.js b/browser/components/translations/tests/browser/browser_translations_select_context_menu_with_full_page_translations_active.js
index 58cb655e38..99cff2b4ec 100644
--- a/browser/components/translations/tests/browser/browser_translations_select_context_menu_with_full_page_translations_active.js
+++ b/browser/components/translations/tests/browser/browser_translations_select_context_menu_with_full_page_translations_active.js
@@ -35,7 +35,7 @@ add_task(
"The translate-selection context menu item should be available while full-page translations is inactive."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -59,7 +59,7 @@ add_task(
"The translate-selection context menu item should be unavailable while full-page translations is active."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
@@ -114,7 +114,7 @@ add_task(
"The translate-selection context menu item should be available while full-page translations is inactive."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewDefault,
});
@@ -138,7 +138,7 @@ add_task(
"The translate-selection context menu item should be unavailable while full-page translations is active."
);
- await FullPageTranslationsTestUtils.openTranslationsPanel({
+ await FullPageTranslationsTestUtils.openPanel({
onOpenPanel: FullPageTranslationsTestUtils.assertPanelViewRevisit,
});
diff --git a/browser/components/translations/tests/browser/browser_translations_select_panel_language_selectors.js b/browser/components/translations/tests/browser/browser_translations_select_panel_language_selectors.js
new file mode 100644
index 0000000000..1dcc76450f
--- /dev/null
+++ b/browser/components/translations/tests/browser/browser_translations_select_panel_language_selectors.js
@@ -0,0 +1,54 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(
+ async function test_select_translations_panel_open_spanish_language_selectors() {
+ const { cleanup, runInPage } = await loadTestPage({
+ page: SPANISH_PAGE_URL,
+ languagePairs: LANGUAGE_PAIRS,
+ prefs: [["browser.translations.select.enable", true]],
+ });
+
+ await SelectTranslationsTestUtils.openPanel(runInPage, {
+ selectSpanishParagraph: true,
+ openAtSpanishParagraph: true,
+ expectedTargetLanguage: "en",
+ onOpenPanel: SelectTranslationsTestUtils.assertPanelViewDefault,
+ });
+
+ SelectTranslationsTestUtils.assertSelectedFromLanguage({ langTag: "es" });
+ SelectTranslationsTestUtils.assertSelectedToLanguage({ langTag: "en" });
+
+ await SelectTranslationsTestUtils.clickDoneButton();
+
+ await cleanup();
+ }
+);
+
+add_task(
+ async function test_select_translations_panel_open_english_language_selectors() {
+ const { cleanup, runInPage } = await loadTestPage({
+ page: ENGLISH_PAGE_URL,
+ languagePairs: LANGUAGE_PAIRS,
+ prefs: [["browser.translations.select.enable", true]],
+ });
+
+ await SelectTranslationsTestUtils.openPanel(runInPage, {
+ selectFirstParagraph: true,
+ openAtFirstParagraph: true,
+ expectedTargetLanguage: "en",
+ onOpenPanel: SelectTranslationsTestUtils.assertPanelViewDefault,
+ });
+
+ SelectTranslationsTestUtils.assertSelectedFromLanguage({ langTag: "en" });
+ SelectTranslationsTestUtils.assertSelectedToLanguage({
+ l10nId: "translations-panel-choose-language",
+ });
+
+ await SelectTranslationsTestUtils.clickDoneButton();
+
+ await cleanup();
+ }
+);
diff --git a/browser/components/translations/tests/browser/browser_translations_select_panel_mainview_ui.js b/browser/components/translations/tests/browser/browser_translations_select_panel_mainview_ui.js
new file mode 100644
index 0000000000..79d21e57d0
--- /dev/null
+++ b/browser/components/translations/tests/browser/browser_translations_select_panel_mainview_ui.js
@@ -0,0 +1,36 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * This test case verifies the visibility and initial state of UI elements within the
+ * Select Translations Panel's main-view UI.
+ */
+add_task(
+ async function test_select_translations_panel_mainview_ui_element_visibility() {
+ const { cleanup, runInPage } = await loadTestPage({
+ page: SPANISH_PAGE_URL,
+ languagePairs: LANGUAGE_PAIRS,
+ prefs: [["browser.translations.select.enable", true]],
+ });
+
+ await FullPageTranslationsTestUtils.assertTranslationsButton(
+ { button: true, circleArrows: false, locale: false, icon: true },
+ "The button is available."
+ );
+
+ await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
+
+ await SelectTranslationsTestUtils.openPanel(runInPage, {
+ selectSpanishParagraph: true,
+ openAtSpanishParagraph: true,
+ expectedTargetLanguage: "es",
+ onOpenPanel: SelectTranslationsTestUtils.assertPanelViewDefault,
+ });
+
+ await SelectTranslationsTestUtils.clickDoneButton();
+
+ await cleanup();
+ }
+);
diff --git a/browser/components/translations/tests/browser/head.js b/browser/components/translations/tests/browser/head.js
index bc9968308c..200ed08719 100644
--- a/browser/components/translations/tests/browser/head.js
+++ b/browser/components/translations/tests/browser/head.js
@@ -206,7 +206,7 @@ async function navigate(
// it doesn't close on navigate the way that it does when it's
// open from the translations button, so ensure that we always
// close it when we navigate to a new page.
- await closeTranslationsPanelIfOpen();
+ await closeAllOpenPanelsAndMenus();
info(message);
@@ -230,7 +230,7 @@ async function navigate(
info(`Loading url: "${url}"`);
if (onOpenPanel) {
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popupshown",
loadTargetPage,
onOpenPanel
@@ -277,6 +277,146 @@ async function toggleReaderMode() {
}
/**
+ * A collection of shared functionality utilized by
+ * FullPageTranslationsTestUtils and SelectTranslationsTestUtils.
+ *
+ * Using functions from the aforementioned classes is preferred over
+ * using functions from this class directly.
+ */
+class SharedTranslationsTestUtils {
+ /**
+ * Asserts that the mainViewId of the panel matches the given string.
+ *
+ * @param {FullPageTranslationsPanel | SelectTranslationsPanel} panel
+ * @param {string} expectedId - The expected id that mainViewId is set to.
+ */
+ static _assertPanelMainViewId(panel, expectedId) {
+ const mainViewId = panel.elements.multiview.getAttribute("mainViewId");
+ is(
+ mainViewId,
+ expectedId,
+ "The mainViewId should match its expected value"
+ );
+ }
+
+ /**
+ * Asserts that the selected from-language matches the provided arguments.
+ *
+ * @param {FullPageTranslationsPanel | SelectTranslationsPanel} panel
+ * - The UI component or panel whose selected from-language is being asserted.
+ * @param {object} options - An object containing assertion parameters.
+ * @param {string} [options.langTag] - A BCP-47 language tag.
+ * @param {string} [options.l10nId] - A localization identifier.
+ */
+ static _assertSelectedFromLanguage(panel, { langTag, l10nId }) {
+ const { fromMenuList } = panel.elements;
+ is(
+ fromMenuList.value,
+ langTag,
+ "Expected selected from-language to match the given language tag"
+ );
+ if (l10nId) {
+ is(
+ fromMenuList.getAttribute("data-l10n-id"),
+ l10nId,
+ "Expected selected from-language to match the given l10n id"
+ );
+ }
+ }
+
+ /**
+ * Asserts that the selected to-language matches the provided arguments.
+ *
+ * @param {FullPageTranslationsPanel | SelectTranslationsPanel} panel
+ * - The UI component or panel whose selected from-language is being asserted.
+ * @param {object} options - An object containing assertion parameters.
+ * @param {string} [options.langTag] - A BCP-47 language tag.
+ * @param {string} [options.l10nId] - A localization identifier.
+ */
+ static _assertSelectedToLanguage(panel, { langTag, l10nId }) {
+ const { toMenuList } = panel.elements;
+ if (langTag) {
+ is(
+ toMenuList.value,
+ langTag,
+ "Expected selected to-language to match the given language tag"
+ );
+ }
+ if (l10nId) {
+ is(
+ toMenuList.getAttribute("data-l10n-id"),
+ l10nId,
+ "Expected selected to-language to match the given l10n id"
+ );
+ }
+ }
+
+ /**
+ * Asserts the visibility of the given elements based on the given expectations.
+ *
+ * @param {object} elements - An object containing the elements to be checked for visibility.
+ * @param {object} expectations - An object where each property corresponds to a property in elements,
+ * and its value is a boolean indicating whether the element should
+ * be visible (true) or hidden (false).
+ * @throws Throws if elements does not contain a property for each property in expectations.
+ */
+ static _assertPanelElementVisibility(elements, expectations) {
+ const hidden = {};
+ const visible = {};
+
+ for (const propertyName in expectations) {
+ ok(
+ elements.hasOwnProperty(propertyName),
+ `Expected panel elements to have property ${propertyName}`
+ );
+ if (expectations[propertyName]) {
+ visible[propertyName] = elements[propertyName];
+ } else {
+ hidden[propertyName] = elements[propertyName];
+ }
+ }
+
+ assertVisibility({ hidden, visible });
+ }
+
+ /**
+ * Executes the provided callback before waiting for the event and then waits for the given event
+ * to be fired for the element corresponding to the provided elementId.
+ *
+ * Optionally executes a postEventAssertion function once the event occurs.
+ *
+ * @param {string} elementId - The Id of the element to wait for the event on.
+ * @param {string} eventName - The name of the event to wait for.
+ * @param {Function} callback - A callback function to execute immediately before waiting for the event.
+ * This is often used to trigger the event on the expected element.
+ * @param {Function|null} [postEventAssertion=null] - An optional callback function to execute after
+ * the event has occurred.
+ * @throws Throws if the element with the specified `elementId` does not exist.
+ * @returns {Promise<void>}
+ */
+ static async _waitForPopupEvent(
+ elementId,
+ eventName,
+ callback,
+ postEventAssertion = null
+ ) {
+ const element = document.getElementById(elementId);
+ if (!element) {
+ throw new Error("Unable to find the translations panel element.");
+ }
+ const promise = BrowserTestUtils.waitForEvent(element, eventName);
+ await callback();
+ info("Waiting for the translations panel popup to be shown");
+ await promise;
+ if (postEventAssertion) {
+ postEventAssertion();
+ }
+ // Wait a single tick on the event loop.
+ await new Promise(resolve => setTimeout(resolve, 0));
+ }
+}
+
+/**
* A class containing test utility functions specific to testing full-page translations.
*/
class FullPageTranslationsTestUtils {
@@ -515,61 +655,45 @@ class FullPageTranslationsTestUtils {
/**
* Asserts that for each provided expectation, the visible state of the corresponding
- * element in TranslationsPanel.elements both exists and matches the visibility expectation.
+ * element in FullPageTranslationsPanel.elements both exists and matches the visibility expectation.
*
* @param {object} expectations
- * A list of expectations for the visibility of any subset of TranslationsPanel.elements
+ * A list of expectations for the visibility of any subset of FullPageTranslationsPanel.elements
*/
static #assertPanelElementVisibility(expectations = {}) {
- // Assume nothing is visible by default, and overwrite them
- // with any specific expectations provided in the argument.
- const finalExpectations = {
- cancelButton: false,
- changeSourceLanguageButton: false,
- dismissErrorButton: false,
- error: false,
- fromMenuList: false,
- fromLabel: false,
- header: false,
- intro: false,
- introLearnMoreLink: false,
- langSelection: false,
- restoreButton: false,
- toLabel: false,
- toMenuList: false,
- translateButton: false,
- unsupportedHeader: false,
- unsupportedHint: false,
- unsupportedLearnMoreLink: false,
- ...expectations,
- };
-
- const elements = TranslationsPanel.elements;
- const hidden = {};
- const visible = {};
-
- for (const propertyName in finalExpectations) {
- ok(
- elements.hasOwnProperty(propertyName),
- `Expected translations panel elements to have property ${propertyName}`
- );
- if (finalExpectations[propertyName]) {
- visible[propertyName] = elements[propertyName];
- } else {
- hidden[propertyName] = elements[propertyName];
+ SharedTranslationsTestUtils._assertPanelElementVisibility(
+ FullPageTranslationsPanel.elements,
+ {
+ cancelButton: false,
+ changeSourceLanguageButton: false,
+ dismissErrorButton: false,
+ error: false,
+ fromMenuList: false,
+ fromLabel: false,
+ header: false,
+ intro: false,
+ introLearnMoreLink: false,
+ langSelection: false,
+ restoreButton: false,
+ toLabel: false,
+ toMenuList: false,
+ translateButton: false,
+ unsupportedHeader: false,
+ unsupportedHint: false,
+ unsupportedLearnMoreLink: false,
+ // Overwrite any of the above defaults with the passed in expectations.
+ ...expectations,
}
- }
-
- assertVisibility({ hidden, visible });
+ );
}
/**
- * Asserts that the TranslationsPanel header has the expected l10nId.
+ * Asserts that the FullPageTranslationsPanel header has the expected l10nId.
*
* @param {string} l10nId - The expected data-l10n-id of the header.
*/
static #assertPanelHeaderL10nId(l10nId) {
- const { header } = TranslationsPanel.elements;
+ const { header } = FullPageTranslationsPanel.elements;
is(
header.getAttribute("data-l10n-id"),
l10nId,
@@ -578,17 +702,28 @@ class FullPageTranslationsTestUtils {
}
/**
+ * Asserts that the FullPageTranslationsPanel error has the expected l10nId.
+ *
+ * @param {string} l10nId - The expected data-l10n-id of the error.
+ */
+ static #assertPanelErrorL10nId(l10nId) {
+ const { errorMessage } = FullPageTranslationsPanel.elements;
+ is(
+ errorMessage.getAttribute("data-l10n-id"),
+ l10nId,
+ "The translations panel error message should match the expected data-l10n-id"
+ );
+ }
+
+ /**
* Asserts that the mainViewId of the panel matches the given string.
*
* @param {string} expectedId
*/
static #assertPanelMainViewId(expectedId) {
- const mainViewId =
- TranslationsPanel.elements.multiview.getAttribute("mainViewId");
- is(
- mainViewId,
- expectedId,
- "The full-page Translations panel mainViewId should match its expected value"
+ SharedTranslationsTestUtils._assertPanelMainViewId(
+ FullPageTranslationsPanel,
+ expectedId
);
}
@@ -598,7 +733,7 @@ class FullPageTranslationsTestUtils {
static assertPanelViewDefault() {
info("Checking that the panel shows the default view");
FullPageTranslationsTestUtils.#assertPanelMainViewId(
- "translations-panel-view-default"
+ "full-page-translations-panel-view-default"
);
FullPageTranslationsTestUtils.#assertPanelElementVisibility({
...FullPageTranslationsTestUtils.#defaultViewVisibilityExpectations,
@@ -614,7 +749,7 @@ class FullPageTranslationsTestUtils {
static assertPanelViewError() {
info("Checking that the panel shows the error view");
FullPageTranslationsTestUtils.#assertPanelMainViewId(
- "translations-panel-view-default"
+ "full-page-translations-panel-view-default"
);
FullPageTranslationsTestUtils.#assertPanelElementVisibility({
error: true,
@@ -623,6 +758,9 @@ class FullPageTranslationsTestUtils {
FullPageTranslationsTestUtils.#assertPanelHeaderL10nId(
"translations-panel-header"
);
+ FullPageTranslationsTestUtils.#assertPanelErrorL10nId(
+ "translations-panel-error-translating"
+ );
}
/**
@@ -644,7 +782,7 @@ class FullPageTranslationsTestUtils {
static assertPanelViewFirstShow() {
info("Checking that the panel shows the first-show view");
FullPageTranslationsTestUtils.#assertPanelMainViewId(
- "translations-panel-view-default"
+ "full-page-translations-panel-view-default"
);
FullPageTranslationsTestUtils.#assertPanelElementVisibility({
intro: true,
@@ -662,7 +800,7 @@ class FullPageTranslationsTestUtils {
static assertPanelViewFirstShowError() {
info("Checking that the panel shows the first-show error view");
FullPageTranslationsTestUtils.#assertPanelMainViewId(
- "translations-panel-view-default"
+ "full-page-translations-panel-view-default"
);
FullPageTranslationsTestUtils.#assertPanelElementVisibility({
error: true,
@@ -681,7 +819,7 @@ class FullPageTranslationsTestUtils {
static assertPanelViewRevisit() {
info("Checking that the panel shows the revisit view");
FullPageTranslationsTestUtils.#assertPanelMainViewId(
- "translations-panel-view-default"
+ "full-page-translations-panel-view-default"
);
FullPageTranslationsTestUtils.#assertPanelElementVisibility({
header: true,
@@ -702,7 +840,7 @@ class FullPageTranslationsTestUtils {
static assertPanelViewUnsupportedLanguage() {
info("Checking that the panel shows the unsupported-language view");
FullPageTranslationsTestUtils.#assertPanelMainViewId(
- "translations-panel-view-unsupported-language"
+ "full-page-translations-panel-view-unsupported-language"
);
FullPageTranslationsTestUtils.#assertPanelElementVisibility({
changeSourceLanguageButton: true,
@@ -718,13 +856,10 @@ class FullPageTranslationsTestUtils {
*
* @param {string} langTag - A BCP-47 language tag.
*/
- static assertSelectedFromLanguage(langTag) {
- info(`Checking that the selected from-language matches ${langTag}`);
- const { fromMenuList } = TranslationsPanel.elements;
- is(
- fromMenuList.value,
- langTag,
- "Expected selected from-language to match the given language tag"
+ static assertSelectedFromLanguage({ langTag, l10nId }) {
+ SharedTranslationsTestUtils._assertSelectedFromLanguage(
+ FullPageTranslationsPanel,
+ { langTag, l10nId }
);
}
@@ -733,13 +868,10 @@ class FullPageTranslationsTestUtils {
*
* @param {string} langTag - A BCP-47 language tag.
*/
- static assertSelectedToLanguage(langTag) {
- info(`Checking that the selected to-language matches ${langTag}`);
- const { toMenuList } = TranslationsPanel.elements;
- is(
- toMenuList.value,
- langTag,
- "Expected selected to-language to match the given language tag"
+ static assertSelectedToLanguage({ langTag, l10nId }) {
+ SharedTranslationsTestUtils._assertSelectedToLanguage(
+ FullPageTranslationsPanel,
+ { langTag, l10nId }
);
}
@@ -827,9 +959,9 @@ class FullPageTranslationsTestUtils {
*/
static async clickCancelButton() {
logAction();
- const { cancelButton } = TranslationsPanel.elements;
+ const { cancelButton } = FullPageTranslationsPanel.elements;
assertVisibility({ visible: { cancelButton } });
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
() => {
click(cancelButton, "Clicking the cancel button");
@@ -847,9 +979,9 @@ class FullPageTranslationsTestUtils {
*/
static async clickChangeSourceLanguageButton({ firstShow = false } = {}) {
logAction();
- const { changeSourceLanguageButton } = TranslationsPanel.elements;
+ const { changeSourceLanguageButton } = FullPageTranslationsPanel.elements;
assertVisibility({ visible: { changeSourceLanguageButton } });
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popupshown",
() => {
click(
@@ -868,9 +1000,9 @@ class FullPageTranslationsTestUtils {
*/
static async clickDismissErrorButton() {
logAction();
- const { dismissErrorButton } = TranslationsPanel.elements;
+ const { dismissErrorButton } = FullPageTranslationsPanel.elements;
assertVisibility({ visible: { dismissErrorButton } });
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
() => {
click(dismissErrorButton, "Click the dismiss-error button");
@@ -919,9 +1051,9 @@ class FullPageTranslationsTestUtils {
*/
static async clickRestoreButton() {
logAction();
- const { restoreButton } = TranslationsPanel.elements;
+ const { restoreButton } = FullPageTranslationsPanel.elements;
assertVisibility({ visible: { restoreButton } });
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
() => {
click(restoreButton, "Click the restore-page button");
@@ -957,9 +1089,9 @@ class FullPageTranslationsTestUtils {
pivotTranslation = false,
} = {}) {
logAction();
- const { translateButton } = TranslationsPanel.elements;
+ const { translateButton } = FullPageTranslationsPanel.elements;
assertVisibility({ visible: { translateButton } });
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popuphidden",
() => {
click(translateButton);
@@ -986,25 +1118,23 @@ class FullPageTranslationsTestUtils {
* @param {boolean} config.openWithKeyboard
* - Open the panel by synthesizing the keyboard. If false, synthesizes the mouse.
*/
- static async openTranslationsPanel({
+ static async openPanel({
onOpenPanel = null,
openFromAppMenu = false,
openWithKeyboard = false,
}) {
logAction();
- await closeTranslationsPanelIfOpen();
+ await closeAllOpenPanelsAndMenus();
if (openFromAppMenu) {
- await FullPageTranslationsTestUtils.#openTranslationsPanelViaAppMenu({
+ await FullPageTranslationsTestUtils.#openPanelViaAppMenu({
onOpenPanel,
openWithKeyboard,
});
} else {
- await FullPageTranslationsTestUtils.#openTranslationsPanelViaTranslationsButton(
- {
- onOpenPanel,
- openWithKeyboard,
- }
- );
+ await FullPageTranslationsTestUtils.#openPanelViaTranslationsButton({
+ onOpenPanel,
+ openWithKeyboard,
+ });
}
}
@@ -1017,7 +1147,7 @@ class FullPageTranslationsTestUtils {
* @param {boolean} config.openWithKeyboard
* - Open the panel by synthesizing the keyboard. If false, synthesizes the mouse.
*/
- static async #openTranslationsPanelViaAppMenu({
+ static async #openPanelViaAppMenu({
onOpenPanel = null,
openWithKeyboard = false,
}) {
@@ -1038,7 +1168,7 @@ class FullPageTranslationsTestUtils {
"The app-menu translate button should be enabled"
);
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popupshown",
() => {
if (openWithKeyboard) {
@@ -1060,7 +1190,7 @@ class FullPageTranslationsTestUtils {
* @param {boolean} config.openWithKeyboard
* - Open the panel by synthesizing the keyboard. If false, synthesizes the mouse.
*/
- static async #openTranslationsPanelViaTranslationsButton({
+ static async #openPanelViaTranslationsButton({
onOpenPanel = null,
openWithKeyboard = false,
}) {
@@ -1070,7 +1200,7 @@ class FullPageTranslationsTestUtils {
{ button: true },
"The translations button is visible."
);
- await FullPageTranslationsTestUtils.waitForTranslationsPopupEvent(
+ await FullPageTranslationsTestUtils.waitForPanelPopupEvent(
"popupshown",
() => {
if (openWithKeyboard) {
@@ -1091,7 +1221,7 @@ class FullPageTranslationsTestUtils {
logAction();
const gearIcons = getAllByL10nId("translations-panel-settings-button");
for (const gearIcon of gearIcons) {
- if (gearIcon.hidden) {
+ if (BrowserTestUtils.isHidden(gearIcon)) {
continue;
}
click(gearIcon, "Open the settings menu");
@@ -1114,7 +1244,7 @@ class FullPageTranslationsTestUtils {
*/
static switchSelectedFromLanguage(langTag) {
logAction(langTag);
- const { fromMenuList } = TranslationsPanel.elements;
+ const { fromMenuList } = FullPageTranslationsPanel.elements;
fromMenuList.value = langTag;
fromMenuList.dispatchEvent(new Event("command"));
}
@@ -1126,7 +1256,7 @@ class FullPageTranslationsTestUtils {
*/
static switchSelectedToLanguage(langTag) {
logAction(langTag);
- const { toMenuList } = TranslationsPanel.elements;
+ const { toMenuList } = FullPageTranslationsPanel.elements;
toMenuList.value = langTag;
toMenuList.dispatchEvent(new Event("command"));
}
@@ -1142,26 +1272,19 @@ class FullPageTranslationsTestUtils {
* An optional assertion to be made immediately after the event occurs.
* @returns {Promise<void>}
*/
- static async waitForTranslationsPopupEvent(
+ static async waitForPanelPopupEvent(
eventName,
callback,
postEventAssertion = null
) {
// De-lazify the panel elements.
- TranslationsPanel.elements;
- const panel = document.getElementById("translations-panel");
- if (!panel) {
- throw new Error("Unable to find the translations panel element.");
- }
- const promise = BrowserTestUtils.waitForEvent(panel, eventName);
- await callback();
- info("Waiting for the translations panel popup to be shown");
- await promise;
- if (postEventAssertion) {
- postEventAssertion();
- }
- // Wait a single tick on the event loop.
- await new Promise(resolve => setTimeout(resolve, 0));
+ FullPageTranslationsPanel.elements;
+ await SharedTranslationsTestUtils._waitForPopupEvent(
+ "full-page-translations-panel",
+ eventName,
+ callback,
+ postEventAssertion
+ );
}
}
@@ -1210,8 +1333,7 @@ class SelectTranslationsTestUtils {
info(message);
}
- await closeTranslationsPanelIfOpen();
- await closeContextMenuIfOpen();
+ await closeAllOpenPanelsAndMenus();
await SelectTranslationsTestUtils.openContextMenu(runInPage, {
selectFirstParagraph,
@@ -1274,8 +1396,106 @@ class SelectTranslationsTestUtils {
);
}
}
+ }
+
+ /**
+ * Asserts that for each provided expectation, the visible state of the corresponding
+ * element in FullPageTranslationsPanel.elements both exists and matches the visibility expectation.
+ *
+ * @param {object} expectations
+ * A list of expectations for the visibility of any subset of SelectTranslationsPanel.elements
+ */
+ static #assertPanelElementVisibility(expectations = {}) {
+ SharedTranslationsTestUtils._assertPanelElementVisibility(
+ SelectTranslationsPanel.elements,
+ {
+ betaIcon: false,
+ copyButton: false,
+ doneButton: false,
+ fromLabel: false,
+ fromMenuList: false,
+ header: false,
+ textArea: false,
+ toLabel: false,
+ toMenuList: false,
+ translateFullPageButton: false,
+ // Overwrite any of the above defaults with the passed in expectations.
+ ...expectations,
+ }
+ );
+ }
- await closeContextMenuIfOpen();
+ /**
+ * Asserts that the mainViewId of the panel matches the given string.
+ *
+ * @param {string} expectedId
+ */
+ static #assertPanelMainViewId(expectedId) {
+ SharedTranslationsTestUtils._assertPanelMainViewId(
+ SelectTranslationsPanel,
+ expectedId
+ );
+ }
+
+ /**
+ * Asserts that panel element visibility matches the default panel view.
+ */
+ static assertPanelViewDefault() {
+ info("Checking that the select-translations panel shows the default view");
+ SelectTranslationsTestUtils.#assertPanelMainViewId(
+ "select-translations-panel-view-default"
+ );
+ SelectTranslationsTestUtils.#assertPanelElementVisibility({
+ betaIcon: true,
+ fromLabel: true,
+ fromMenuList: true,
+ header: true,
+ textArea: true,
+ toLabel: true,
+ toMenuList: true,
+ copyButton: true,
+ doneButton: true,
+ translateFullPageButton: true,
+ });
+ }
+
+ /**
+ * Asserts that the selected from-language matches the provided language tag.
+ *
+ * @param {string} langTag - A BCP-47 language tag.
+ */
+ static assertSelectedFromLanguage({ langTag, l10nId }) {
+ SharedTranslationsTestUtils._assertSelectedFromLanguage(
+ SelectTranslationsPanel,
+ { langTag, l10nId }
+ );
+ }
+
+ /**
+ * Asserts that the selected to-language matches the provided language tag.
+ *
+ * @param {string} langTag - A BCP-47 language tag.
+ */
+ static assertSelectedToLanguage({ langTag, l10nId }) {
+ SharedTranslationsTestUtils._assertSelectedToLanguage(
+ SelectTranslationsPanel,
+ { langTag, l10nId }
+ );
+ }
+
+ /**
+ * Simulates clicking the done button and waits for the panel to close.
+ */
+ static async clickDoneButton() {
+ logAction();
+ const { doneButton } = SelectTranslationsPanel.elements;
+ assertVisibility({ visible: { doneButton } });
+ await SelectTranslationsTestUtils.waitForPanelPopupEvent(
+ "popuphidden",
+ () => {
+ click(doneButton, "Clicking the done button");
+ }
+ );
}
/**
@@ -1325,38 +1545,62 @@ class SelectTranslationsTestUtils {
}
if (openAtFirstParagraph === true) {
- await runInPage(async TranslationsTest => {
- const { getFirstParagraph } = TranslationsTest.getSelectors();
- const paragraph = getFirstParagraph();
- await TranslationsTest.rightClickContentElement(paragraph);
- });
+ await SharedTranslationsTestUtils._waitForPopupEvent(
+ "contentAreaContextMenu",
+ "popupshown",
+ async () => {
+ await runInPage(async TranslationsTest => {
+ const { getFirstParagraph } = TranslationsTest.getSelectors();
+ const paragraph = getFirstParagraph();
+ await TranslationsTest.rightClickContentElement(paragraph);
+ });
+ }
+ );
return;
}
if (openAtSpanishParagraph === true) {
- await runInPage(async TranslationsTest => {
- const { getSpanishParagraph } = TranslationsTest.getSelectors();
- const paragraph = getSpanishParagraph();
- await TranslationsTest.rightClickContentElement(paragraph);
- });
+ await SharedTranslationsTestUtils._waitForPopupEvent(
+ "contentAreaContextMenu",
+ "popupshown",
+ async () => {
+ await runInPage(async TranslationsTest => {
+ const { getSpanishParagraph } = TranslationsTest.getSelectors();
+ const paragraph = getSpanishParagraph();
+ await TranslationsTest.rightClickContentElement(paragraph);
+ });
+ }
+ );
return;
}
if (openAtEnglishHyperlink === true) {
- await runInPage(async TranslationsTest => {
- const { getEnglishHyperlink } = TranslationsTest.getSelectors();
- const hyperlink = getEnglishHyperlink();
- await TranslationsTest.rightClickContentElement(hyperlink);
- });
+ await SharedTranslationsTestUtils._waitForPopupEvent(
+ "contentAreaContextMenu",
+ "popupshown",
+ async () => {
+ await runInPage(async TranslationsTest => {
+ const { getEnglishHyperlink } = TranslationsTest.getSelectors();
+ const hyperlink = getEnglishHyperlink();
+ await TranslationsTest.rightClickContentElement(hyperlink);
+ });
+ }
+ );
return;
}
if (openAtSpanishHyperlink === true) {
- await runInPage(async TranslationsTest => {
- const { getSpanishHyperlink } = TranslationsTest.getSelectors();
- const hyperlink = getSpanishHyperlink();
- await TranslationsTest.rightClickContentElement(hyperlink);
- });
+ await SharedTranslationsTestUtils._waitForPopupEvent(
+ "contentAreaContextMenu",
+ "popupshown",
+ async () => {
+ await runInPage(async TranslationsTest => {
+ const { getSpanishHyperlink } = TranslationsTest.getSelectors();
+ const hyperlink = getSpanishHyperlink();
+ await TranslationsTest.rightClickContentElement(hyperlink);
+ });
+ }
+ );
return;
}
@@ -1364,6 +1608,96 @@ class SelectTranslationsTestUtils {
"openContextMenu() was not provided a declaration for which element to open the menu at."
);
}
+
+ /**
+ * Opens the Select Translations panel via the context menu based on specified options.
+ *
+ * @param {Function} runInPage - A content-exposed function to run within the context of the page.
+ * @param {object} options - Options for selecting paragraphs and opening the context menu.
+ * @param {boolean} options.selectFirstParagraph - Selects the first paragraph before opening the context menu.
+ * @param {boolean} options.selectSpanishParagraph - Selects the Spanish paragraph before opening the context menu.
+ * This is only available in SPANISH_TEST_PAGE.
+ * @param {string} options.expectedTargetLanguage - The target language for translation.
+ * @param {boolean} options.openAtFirstParagraph - Opens the context menu at the first paragraph.
+ * @param {boolean} options.openAtSpanishParagraph - Opens at the Spanish paragraph.
+ * This is only available in SPANISH_TEST_PAGE.
+ * @param {boolean} options.openAtEnglishHyperlink - Opens at the English hyperlink.
+ * This is only available in SPANISH_TEST_PAGE.
+ * @param {boolean} options.openAtSpanishHyperlink - Opens at the Spanish hyperlink.
+ * This is only available in SPANISH_TEST_PAGE.
+ * @param {Function|null} [options.onOpenPanel=null] - An optional callback function to execute after the panel opens.
+ * @param {string|null} [message=null] - An optional message to log to info.
+ * @throws Throws an error if the context menu could not be opened with the provided options.
+ * @returns {Promise<void>}
+ */
+ static async openPanel(
+ runInPage,
+ {
+ selectFirstParagraph,
+ selectSpanishParagraph,
+ expectedTargetLanguage,
+ openAtFirstParagraph,
+ openAtSpanishParagraph,
+ openAtEnglishHyperlink,
+ openAtSpanishHyperlink,
+ onOpenPanel,
+ },
+ message
+ ) {
+ logAction();
+
+ if (message) {
+ info(message);
+ }
+
+ await SelectTranslationsTestUtils.assertContextMenuTranslateSelectionItem(
+ runInPage,
+ {
+ selectFirstParagraph,
+ selectSpanishParagraph,
+ expectedTargetLanguage,
+ openAtFirstParagraph,
+ openAtSpanishParagraph,
+ openAtEnglishHyperlink,
+ openAtSpanishHyperlink,
+ },
+ message
+ );
+
+ const menuItem = getById("context-translate-selection");
+
+ await SelectTranslationsTestUtils.waitForPanelPopupEvent(
+ "popupshown",
+ () => click(menuItem),
+ onOpenPanel
+ );
+ }
+
+ /**
+ * XUL popups will fire the popupshown and popuphidden events. These will fire for
+ * any type of popup in the browser. This function waits for one of those events, and
+ * checks that the viewId of the popup is PanelUI-profiler
+ *
+ * @param {"popupshown" | "popuphidden"} eventName
+ * @param {Function} callback
+ * @param {Function} postEventAssertion
+ * An optional assertion to be made immediately after the event occurs.
+ * @returns {Promise<void>}
+ */
+ static async waitForPanelPopupEvent(
+ eventName,
+ callback,
+ postEventAssertion = null
+ ) {
+ // De-lazify the panel elements.
+ SelectTranslationsPanel.elements;
+ await SharedTranslationsTestUtils._waitForPopupEvent(
+ "select-translations-panel",
+ eventName,
+ callback,
+ postEventAssertion
+ );
+ }
}
class TranslationsSettingsTestUtils {