commit bb6366e8e23f342a0750bb300f97feeecb8be2cc
parent bcbd638c2a3b0f267f98c39e8ced0306a9ebf51f
Author: Erik Nordin <enordin@mozilla.com>
Date: Wed, 8 Oct 2025 19:28:55 +0000
Bug 1967758 - Remove unused identifiedLangTag entry r=translations-reviewers,gregtatum
This patch removes a leftover, unused entry from Bug 1975744
when `identifiedLangTag` was refactored to be an `identified`
object with a `language` field.
Differential Revision: https://phabricator.services.mozilla.com/D267654
Diffstat:
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/browser/components/translations/tests/browser/browser_translations_full_page_language_id_behavior.js b/browser/components/translations/tests/browser/browser_translations_full_page_language_id_behavior.js
@@ -296,3 +296,57 @@ add_task(async function test_language_identification_behavior() {
await cleanup();
}
});
+
+/**
+ * This test case tests the behavior when the page has no declared language
+ * tag and the detected language is not supported by Translations.
+ */
+add_task(async function test_detected_language_unsupported() {
+ info("Testing unsupported detected language with no declared language");
+ TranslationsParent.testAutomaticPopup = true;
+
+ let wasPopupShown = false;
+ window.FullPageTranslationsPanel.elements; // De-lazify the panel.
+
+ const { resolve } = Promise.withResolvers();
+ const panel = window.document.getElementById("full-page-translations-panel");
+
+ function handlePopupShown() {
+ wasPopupShown = true;
+ panel.removeEventListener("popupshown", handlePopupShown);
+ resolve();
+ }
+ panel.addEventListener("popupshown", handlePopupShown);
+
+ const { cleanup, runInPage } = await loadTestPage({
+ page: SPANISH_PAGE_UNDECLARED_URL,
+ // Deliberately omit Spanish so that it is not supported.
+ languagePairs: [
+ { fromLang: "en", toLang: "fr" },
+ { fromLang: "fr", toLang: "en" },
+ { fromLang: "en", toLang: "uk" },
+ { fromLang: "uk", toLang: "en" },
+ ],
+ autoDownloadFromRemoteSettings: true,
+ contentEagerMode: true,
+ });
+
+ await FullPageTranslationsTestUtils.assertTranslationsButton(
+ { button: false },
+ "The translations button is not visible when the detected language is unsupported."
+ );
+
+ await FullPageTranslationsTestUtils.assertPageIsNotTranslated(
+ runInPage,
+ "No translation should occur when the detected language is unsupported."
+ );
+
+ is(
+ wasPopupShown,
+ false,
+ "A translation was not offered for an unsupported detected language."
+ );
+
+ TranslationsParent.testAutomaticPopup = false;
+ await cleanup();
+});
diff --git a/toolkit/components/translations/actors/TranslationsParent.sys.mjs b/toolkit/components/translations/actors/TranslationsParent.sys.mjs
@@ -844,7 +844,7 @@ export class TranslationsParent extends JSWindowActorParent {
if (
!TranslationsParent.findCompatibleSourceLangTagSync(
- detectedLanguages.identifiedLangTag,
+ detectedLanguages.identified.language,
await TranslationsParent.getNonPivotLanguagePairs()
)
) {
@@ -3712,7 +3712,7 @@ export class TranslationsParent extends JSWindowActorParent {
userLangTag: null,
isDocLangTagSupported: false,
htmlLangAttribute: htmlLangAttribute ?? null,
- identifiedLangTag: null,
+ identified: null,
};
/**