mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 14:20:14 +02:00
Bug 1493711 - Pref off downloading langpacks outside of release r=jaws
Differential Revision: https://phabricator.services.mozilla.com/D8909 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e7dc869f77
commit
597134aa66
4 changed files with 79 additions and 13 deletions
|
|
@ -1764,6 +1764,12 @@ pref("app.shield.optoutstudies.enabled", false);
|
||||||
|
|
||||||
// Multi-lingual preferences
|
// Multi-lingual preferences
|
||||||
pref("intl.multilingual.enabled", false);
|
pref("intl.multilingual.enabled", false);
|
||||||
|
// AMO only serves language packs for release versions, so this feature only works on release.
|
||||||
|
#ifdef RELEASE
|
||||||
|
pref("intl.multilingual.downloadEnabled", true);
|
||||||
|
#else
|
||||||
|
pref("intl.multilingual.downloadEnabled", false);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Simulate conditions that will happen when the browser
|
// Simulate conditions that will happen when the browser
|
||||||
// is running with Fission enabled. This is meant to assist
|
// is running with Fission enabled. This is meant to assist
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,11 @@ var gBrowserLanguagesDialog = {
|
||||||
_requestedLocales: null,
|
_requestedLocales: null,
|
||||||
requestedLocales: null,
|
requestedLocales: null,
|
||||||
|
|
||||||
|
get downloadEnabled() {
|
||||||
|
// Downloading langpacks isn't always supported, check the pref.
|
||||||
|
return Services.prefs.getBoolPref("intl.multilingual.downloadEnabled");
|
||||||
|
},
|
||||||
|
|
||||||
beforeAccept() {
|
beforeAccept() {
|
||||||
this.requestedLocales = this.getRequestedLocales();
|
this.requestedLocales = this.getRequestedLocales();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -352,6 +357,10 @@ var gBrowserLanguagesDialog = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadLocalesFromAMO() {
|
async loadLocalesFromAMO() {
|
||||||
|
if (!this.downloadEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Disable the dropdown while we hit the network.
|
// Disable the dropdown while we hit the network.
|
||||||
this._availableLocales.disableWithMessageId("browser-languages-searching");
|
this._availableLocales.disableWithMessageId("browser-languages-searching");
|
||||||
|
|
||||||
|
|
@ -404,10 +413,12 @@ var gBrowserLanguagesDialog = {
|
||||||
} else {
|
} else {
|
||||||
items = [];
|
items = [];
|
||||||
}
|
}
|
||||||
|
if (this.downloadEnabled) {
|
||||||
items.push({
|
items.push({
|
||||||
label: await document.l10n.formatValue("browser-languages-search"),
|
label: await document.l10n.formatValue("browser-languages-search"),
|
||||||
value: "search",
|
value: "search",
|
||||||
});
|
});
|
||||||
|
}
|
||||||
this._availableLocales.setItems(items);
|
this._availableLocales.setItems(items);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -755,15 +755,18 @@ var gMainPane = {
|
||||||
fragment.appendChild(menuitem);
|
fragment.appendChild(menuitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an option to search for more languages.
|
// Add an option to search for more languages if downloading is supported.
|
||||||
|
if (Services.prefs.getBoolPref("intl.multilingual.downloadEnabled")) {
|
||||||
let menuitem = document.createXULElement("menuitem");
|
let menuitem = document.createXULElement("menuitem");
|
||||||
menuitem.id = "defaultBrowserLanguageSearch";
|
menuitem.id = "defaultBrowserLanguageSearch";
|
||||||
menuitem.setAttribute(
|
menuitem.setAttribute(
|
||||||
"label", await document.l10n.formatValue("browser-languages-search"));
|
"label", await document.l10n.formatValue("browser-languages-search"));
|
||||||
|
menuitem.setAttribute("value", "search");
|
||||||
menuitem.addEventListener("command", () => {
|
menuitem.addEventListener("command", () => {
|
||||||
gMainPane.showBrowserLanguages({search: true});
|
gMainPane.showBrowserLanguages({search: true});
|
||||||
});
|
});
|
||||||
fragment.appendChild(menuitem);
|
fragment.appendChild(menuitem);
|
||||||
|
}
|
||||||
|
|
||||||
let menulist = document.getElementById("defaultBrowserLanguage");
|
let menulist = document.getElementById("defaultBrowserLanguage");
|
||||||
let menupopup = menulist.querySelector("menupopup");
|
let menupopup = menulist.querySelector("menupopup");
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,7 @@ add_task(async function testReorderingBrowserLanguages() {
|
||||||
await SpecialPowers.pushPrefEnv({
|
await SpecialPowers.pushPrefEnv({
|
||||||
set: [
|
set: [
|
||||||
["intl.multilingual.enabled", true],
|
["intl.multilingual.enabled", true],
|
||||||
|
["intl.multilingual.downloadEnabled", true],
|
||||||
["intl.locale.requested", "pl,en-US"],
|
["intl.locale.requested", "pl,en-US"],
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
@ -219,6 +220,7 @@ add_task(async function testAddAndRemoveRequestedLanguages() {
|
||||||
await SpecialPowers.pushPrefEnv({
|
await SpecialPowers.pushPrefEnv({
|
||||||
set: [
|
set: [
|
||||||
["intl.multilingual.enabled", true],
|
["intl.multilingual.enabled", true],
|
||||||
|
["intl.multilingual.downloadEnabled", true],
|
||||||
["intl.locale.requested", "en-US"],
|
["intl.locale.requested", "en-US"],
|
||||||
["extensions.langpacks.signatures.required", false],
|
["extensions.langpacks.signatures.required", false],
|
||||||
],
|
],
|
||||||
|
|
@ -292,6 +294,7 @@ add_task(async function testInstallFromAMO() {
|
||||||
await SpecialPowers.pushPrefEnv({
|
await SpecialPowers.pushPrefEnv({
|
||||||
set: [
|
set: [
|
||||||
["intl.multilingual.enabled", true],
|
["intl.multilingual.enabled", true],
|
||||||
|
["intl.multilingual.downloadEnabled", true],
|
||||||
["intl.locale.requested", "en-US"],
|
["intl.locale.requested", "en-US"],
|
||||||
["extensions.getAddons.langpacks.url", langpacksUrl],
|
["extensions.getAddons.langpacks.url", langpacksUrl],
|
||||||
["extensions.langpacks.signatures.required", false],
|
["extensions.langpacks.signatures.required", false],
|
||||||
|
|
@ -360,3 +363,46 @@ add_task(async function testInstallFromAMO() {
|
||||||
|
|
||||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let hasSearchOption = popup => Array.from(popup.children).some(el => el.value == "search");
|
||||||
|
|
||||||
|
add_task(async function testDownloadEnabled() {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["intl.multilingual.enabled", true],
|
||||||
|
["intl.multilingual.downloadEnabled", true],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
|
||||||
|
let doc = gBrowser.contentDocument;
|
||||||
|
|
||||||
|
let defaultMenulist = doc.getElementById("defaultBrowserLanguage");
|
||||||
|
ok(hasSearchOption(defaultMenulist.firstChild), "There's a search option in the General pane");
|
||||||
|
|
||||||
|
let { available } = await openDialog(doc, false);
|
||||||
|
ok(hasSearchOption(available.firstChild), "There's a search option in the dialog");
|
||||||
|
|
||||||
|
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
add_task(async function testDownloadDisabled() {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["intl.multilingual.enabled", true],
|
||||||
|
["intl.multilingual.downloadEnabled", false],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
|
||||||
|
let doc = gBrowser.contentDocument;
|
||||||
|
|
||||||
|
let defaultMenulist = doc.getElementById("defaultBrowserLanguage");
|
||||||
|
ok(!hasSearchOption(defaultMenulist.firstChild), "There's no search option in the General pane");
|
||||||
|
|
||||||
|
let { available } = await openDialog(doc, false);
|
||||||
|
ok(!hasSearchOption(available.firstChild), "There's no search option in the dialog");
|
||||||
|
|
||||||
|
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue