tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 60e47676743cc4a2e3b976864f0a9d01145374f0
parent a72f8f31ab53f952c0ae63a4df0dd1ecc88f9b2a
Author: Erik Nordin <enordin@mozilla.com>
Date:   Sat, 18 Oct 2025 02:16:51 +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:
Mbrowser/components/translations/tests/browser/browser_translations_full_page_language_id_behavior.js | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtoolkit/components/translations/actors/TranslationsParent.sys.mjs | 4++--
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 @@ -831,7 +831,7 @@ export class TranslationsParent extends JSWindowActorParent { if ( !TranslationsParent.findCompatibleSourceLangTagSync( - detectedLanguages.identifiedLangTag, + detectedLanguages.identified.language, await TranslationsParent.getNonPivotLanguagePairs() ) ) { @@ -3709,7 +3709,7 @@ export class TranslationsParent extends JSWindowActorParent { userLangTag: null, isDocLangTagSupported: false, htmlLangAttribute: htmlLangAttribute ?? null, - identifiedLangTag: null, + identified: null, }; /**