Bug 1855726 - Remove autotranslate prefs from . Remove usage of the pref and corresponsing lazy getter from TranslateParent.sys.mjs and also remove the corresponding test cases. r=nordzilla

Differential Revision: https://phabricator.services.mozilla.com/D190849
This commit is contained in:
nzai 2023-11-08 15:47:46 +00:00
Родитель 39e47985bb
Коммит 73d48aacb4
3 изменённых файлов: 7 добавлений и 24 удалений

Просмотреть файл

@ -3600,7 +3600,6 @@ pref("browser.sanitizer.loglevel", "Warn");
// engine https://browser.mt/. See Bug 971044. Note that this pref can be turned
// on in different apps like Firefox Desktop, even if it's disabled by default here.
pref("browser.translations.enable", false);
// Set to "All" to see all logs, which are useful for debugging. Set to "Info" to see
// the application logic logs, and not all of the translated messages, which can be
// slow and overwhelming.
@ -3616,10 +3615,6 @@ pref("browser.translations.neverTranslateLanguages", "");
// and the full page translations uses HTML. Set this pref to true to use the HTML
// translation behavior on about:translations. Requires a page refresh.
pref("browser.translations.useHTML", false);
// Normally there is a UI to ask the user to translate a page, this pref makes it
// so that the page automatically performs a translation if one is detected as being
// required.
pref("browser.translations.autoTranslate", false);
// Automatically popup an offer to translate on sites.
pref("browser.translations.automaticallyPopup", true);
// Simulate the behavior of using a device that does not support the translations engine.

Просмотреть файл

@ -70,12 +70,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
"browser.translations.enable"
);
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
"autoTranslatePagePref",
"browser.translations.autoTranslate"
);
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
"chaosErrorsPref",
@ -965,17 +959,7 @@ export class TranslationsParent extends JSWindowActorParent {
return false;
}
if (
// The user has not marked this language as always translate.
!TranslationsParent.shouldAlwaysTranslateLanguage(langTags) &&
// The pref to always auto-translate is off.
!lazy.autoTranslatePagePref
) {
return false;
}
// The page can be auto-translated
return true;
return TranslationsParent.shouldAlwaysTranslateLanguage(langTags);
}
/** @type {Promise<LanguageIdModelRecord> | null} */

Просмотреть файл

@ -665,10 +665,14 @@ async function captureTranslationsError(callback) {
* @param {Object} options - The options for `loadTestPage` plus a `runInPage` function.
*/
async function autoTranslatePage(options) {
const { prefs, ...otherOptions } = options;
const { prefs, languagePairs, ...otherOptions } = options;
const fromLangs = languagePairs.map(language => language.fromLang).join(",");
const { cleanup, runInPage } = await loadTestPage({
autoDownloadFromRemoteSettings: true,
prefs: [["browser.translations.autoTranslate", true], ...(prefs ?? [])],
prefs: [
["browser.translations.alwaysTranslateLanguages", fromLangs],
...(prefs ?? []),
],
...otherOptions,
});
await runInPage(options.runInPage);