Backed out 2 changesets (bug 1588785) for causing bc perma failures in browser_searchDefaultEngine.js on a CLOSED TREE

Backed out changeset 6ad4b26b21d7 (bug 1588785)
Backed out changeset 4a4afa268baf (bug 1588785)
This commit is contained in:
Oana Pop Rus 2019-10-18 18:45:58 +03:00
Родитель 617a761d10
Коммит 852f034b58
22 изменённых файлов: 35 добавлений и 254 удалений

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

@ -393,6 +393,8 @@ pref("browser.search.widget.inNavBar", false);
// engine in private browsing mode.
#ifdef EARLY_BETA_OR_EARLIER
pref("browser.search.separatePrivateDefault.ui.enabled", true);
#else
pref("browser.search.separatePrivateDefault.ui.enabled", false);
#endif
// The maximum amount of times the private default banner is shown.
pref("browser.search.separatePrivateDefault.ui.banner.max", 0);

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

@ -4403,7 +4403,7 @@ const BrowserSearch = {
// Asynchronously initialize the search service if necessary, to get the
// current engine for working out the placeholder.
this._updateURLBarPlaceholderFromDefaultEngine(
PrivateBrowsingUtils.isWindowPrivate(window),
this._usePrivateSettings,
// Delay the update for this until so that we don't change it while
// the user is looking at it / isn't expecting it.
true
@ -4439,24 +4439,31 @@ const BrowserSearch = {
this._removeMaybeOfferedEngine(engineName);
break;
case "engine-default":
if (
this._searchInitComplete &&
!PrivateBrowsingUtils.isWindowPrivate(window)
) {
if (this._searchInitComplete && !this._usePrivateSettings) {
this._updateURLBarPlaceholder(engineName, false);
}
break;
case "engine-default-private":
if (
this._searchInitComplete &&
PrivateBrowsingUtils.isWindowPrivate(window)
) {
if (this._searchInitComplete && this._usePrivateSettings) {
this._updateURLBarPlaceholder(engineName, true);
}
break;
}
},
/**
* @returns True if we are using a separate default private engine, and
* we are in a private window.
*/
get _usePrivateSettings() {
return (
Services.prefs.getBoolPref(
"browser.search.separatePrivateDefault",
true
) && PrivateBrowsingUtils.isWindowPrivate(window)
);
},
_addMaybeOfferedEngine(engineName) {
let selectedBrowserOffersEngine = false;
for (let browser of gBrowser.browsers) {
@ -4514,7 +4521,7 @@ const BrowserSearch = {
initPlaceHolder() {
const prefName =
"browser.urlbar.placeholderName" +
(PrivateBrowsingUtils.isWindowPrivate(window) ? ".private" : "");
(this._usePrivateSettings ? ".private" : "");
let engineName = Services.prefs.getStringPref(prefName, "");
if (engineName) {
// We can do this directly, since we know we're at DOMContentLoaded.

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

@ -50,13 +50,6 @@ add_task(async function setup() {
template: templatePrivate + "{searchTerms}",
});
await SpecialPowers.pushPrefEnv({
set: [
["browser.search.separatePrivateDefault.ui.enabled", true],
["browser.search.separatePrivateDefault", false],
],
});
let originalEngine = await Services.search.getDefault();
let originalPrivateEngine = await Services.search.getDefaultPrivate();

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

@ -8,10 +8,7 @@
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.search.separatePrivateDefault.ui.enabled", true],
["browser.search.separatePrivateDefault", false],
],
set: [["browser.search.separatePrivateDefault", false]],
});
const engine = await Services.search.addEngineWithDetails("MozSearch", {

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

@ -37,10 +37,7 @@ add_task(async function setup() {
BrowserTestUtils.removeTab(urlTab);
await SpecialPowers.pushPrefEnv({
set: [
["browser.search.separatePrivateDefault.ui.enabled", true],
["browser.search.separatePrivateDefault", false],
],
set: [["browser.search.separatePrivateDefault", false]],
});
registerCleanupFunction(async () => {

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

@ -22,7 +22,6 @@ add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.newtab.preload", false],
["browser.search.separatePrivateDefault.ui.enabled", true],
["browser.search.separatePrivateDefault", true],
],
});

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

@ -14,10 +14,7 @@ const kPrivateSearchEngineURL = "http://example.com/?private={searchTerms}";
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.search.separatePrivateDefault.ui.enabled", true],
["browser.search.separatePrivateDefault", true],
],
set: [["browser.search.separatePrivateDefault", true]],
});
let oldCurrentEngine = await Services.search.getDefault();

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

@ -614,7 +614,6 @@ add_task(async function setup() {
"keyword.enabled",
"browser.fixup.domainwhitelist.whitelisted",
"browser.search.separatePrivateDefault",
"browser.search.separatePrivateDefault.ui.enabled",
];
for (let pref of prefList) {
Services.prefs.setBoolPref(pref, true);
@ -667,9 +666,6 @@ add_task(async function setup() {
Services.prefs.clearUserPref("browser.fixup.typo.scheme");
Services.prefs.clearUserPref(kForceHostLookup);
Services.prefs.clearUserPref("browser.search.separatePrivateDefault");
Services.prefs.clearUserPref(
"browser.search.separatePrivateDefault.ui.enabled"
);
});
});

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

@ -119,10 +119,6 @@ add_task(async function setup() {
Services.prefs.setBoolPref("keyword.enabled", true);
Services.prefs.setBoolPref("browser.search.separatePrivateDefault", true);
Services.prefs.setBoolPref(
"browser.search.separatePrivateDefault.ui.enabled",
true
);
Services.io
.getProtocolHandler("resource")
@ -164,9 +160,6 @@ add_task(async function setup() {
await Services.search.removeEngine(newPrivateEngine);
Services.prefs.clearUserPref("keyword.enabled");
Services.prefs.clearUserPref("browser.search.separatePrivateDefault");
Services.prefs.clearUserPref(
"browser.search.separatePrivateDefault.ui.enabled"
);
});
});

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

@ -4449,7 +4449,6 @@ pref("browser.search.geoSpecificDefaults", false);
pref("browser.search.geoip.url", "https://location.services.mozilla.com/v1/country?key=%MOZILLA_API_KEY%");
pref("browser.search.geoip.timeout", 3000);
pref("browser.search.separatePrivateDefault", false);
pref("browser.search.separatePrivateDefault.ui.enabled", false);
#ifdef MOZ_OFFICIAL_BRANDING
// {moz:official} expands to "official"

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

@ -32,6 +32,13 @@ XPCOMUtils.defineLazyServiceGetters(this, {
gEnvironment: ["@mozilla.org/process/environment;1", "nsIEnvironment"],
});
XPCOMUtils.defineLazyPreferenceGetter(
this,
"gSeparatePrivateDefault",
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault",
false
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"gGeoSpecificDefaultsEnabled",
@ -662,16 +669,6 @@ SearchService.prototype = {
*/
_metaData: {},
// This reflects the combined values of the prefs for enabling the separate
// private default UI, and for the user choosing a separate private engine.
// If either one is disabled, then we don't enable the separate private default.
get _separatePrivateDefault() {
return (
this._separatePrivateDefaultPrefValue &&
this._separatePrivateDefaultEnabledPrefValue
);
},
/**
* Resets the locally stored data to the original empty values in preparation
* for a reinit or a reset.
@ -726,22 +723,6 @@ SearchService.prototype = {
async _init(skipRegionCheck) {
SearchUtils.log("_init start");
XPCOMUtils.defineLazyPreferenceGetter(
this,
"_separatePrivateDefaultPrefValue",
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault",
false,
this._onSeparateDefaultPrefChanged.bind(this)
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"_separatePrivateDefaultEnabledPrefValue",
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
false,
this._onSeparateDefaultPrefChanged.bind(this)
);
try {
// See if we have a cache file so we don't have to parse a bunch of XML.
let cache = await this._readCacheFile();
@ -988,7 +969,7 @@ SearchService.prototype = {
* browsing engine will be returned.
*/
get originalPrivateDefaultEngine() {
return this._originalDefaultEngine(this._separatePrivateDefault);
return this._originalDefaultEngine(gSeparatePrivateDefault);
},
resetToOriginalDefaultEngine() {
@ -1302,17 +1283,9 @@ SearchService.prototype = {
this._currentEngine,
SearchUtils.MODIFIED_TYPE.DEFAULT
);
// If we've not got a separate private active, notify update of the
// private so that the UI updates correctly.
if (!this._separatePrivateDefault) {
SearchUtils.notifyAction(
this._currentEngine,
SearchUtils.MODIFIED_TYPE.DEFAULT_PRIVATE
);
}
}
if (
this._separatePrivateDefault &&
gSeparatePrivateDefault &&
prevPrivateEngine &&
this.defaultPrivateEngine !== prevPrivateEngine
) {
@ -2649,7 +2622,7 @@ SearchService.prototype = {
// tests. Really, removeEngine should always commit to updating any
// changed defaults.
if (
this._separatePrivateDefault &&
gSeparatePrivateDefault &&
engineToRemove == this.defaultPrivateEngine
) {
this._currentPrivateEngine = null;
@ -2921,14 +2894,6 @@ SearchService.prototype = {
this[currentEngine],
SearchUtils.MODIFIED_TYPE[privateMode ? "DEFAULT_PRIVATE" : "DEFAULT"]
);
// If we've not got a separate private active, notify update of the
// private so that the UI updates correctly.
if (!privateMode && !this._separatePrivateDefault) {
SearchUtils.notifyAction(
this[currentEngine],
SearchUtils.MODIFIED_TYPE.DEFAULT_PRIVATE
);
}
},
get defaultEngine() {
@ -2940,11 +2905,11 @@ SearchService.prototype = {
},
get defaultPrivateEngine() {
return this._getEngineDefault(this._separatePrivateDefault);
return this._getEngineDefault(gSeparatePrivateDefault);
},
set defaultPrivateEngine(newEngine) {
this._setEngineDefault(this._separatePrivateDefault, newEngine);
this._setEngineDefault(gSeparatePrivateDefault, newEngine);
},
async getDefault() {
@ -2967,19 +2932,6 @@ SearchService.prototype = {
return (this.defaultPrivateEngine = engine);
},
_onSeparateDefaultPrefChanged() {
// We should notify if the normal default, and the currently saved private
// default are different. Otherwise, save the energy.
if (this.defaultEngine != this._getEngineDefault(true)) {
SearchUtils.notifyAction(
// Always notify with the new private engine, the function checks
// the preference value for us.
this.defaultPrivateEngine,
SearchUtils.MODIFIED_TYPE.DEFAULT_PRIVATE
);
}
},
async _getEngineInfo(engine) {
if (!engine) {
// The defaultEngine getter will throw if there's no engine at all,
@ -3107,7 +3059,7 @@ SearchService.prototype = {
defaultSearchEngineData,
};
if (this._separatePrivateDefault) {
if (gSeparatePrivateDefault) {
let [
privateShortName,
defaultPrivateSearchEngineData,

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

@ -136,15 +136,6 @@ async function forceExpiration() {
await promiseSaveGlobalMetadata(metadata);
}
function promiseDefaultNotification(type = "normal") {
return SearchTestUtils.promiseSearchNotification(
SearchUtils.MODIFIED_TYPE[
type == "private" ? "DEFAULT_PRIVATE" : "DEFAULT"
],
SearchUtils.TOPIC_ENGINE_MODIFIED
);
}
/**
* Clean the profile of any cache file left from a previous run.
*

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

@ -107,10 +107,6 @@ class SearchConfigTest {
// Enable separatePrivateDefault testing. We test with this on, as we have
// separate tests for ensuring the normal = private when this is off.
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
true
);
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault",
true

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

@ -13,13 +13,6 @@ add_task(async function setup() {
await AddonTestUtils.promiseStartupManager();
});
function promiseDefaultNotification() {
return SearchTestUtils.promiseSearchNotification(
SearchUtils.MODIFIED_TYPE.DEFAULT,
SearchUtils.TOPIC_ENGINE_MODIFIED
);
}
add_task(async function test_defaultEngine() {
let search = Services.search;
await search.init();
@ -31,19 +24,11 @@ add_task(async function test_defaultEngine() {
{ name: "A second test engine", xmlFileName: "engine2.xml" },
]);
let promise = promiseDefaultNotification();
search.defaultEngine = engine1;
Assert.equal(await promise, engine1);
Assert.equal(search.defaultEngine, engine1);
promise = promiseDefaultNotification();
search.defaultEngine = engine2;
Assert.equal(await promise, engine2);
Assert.equal(search.defaultEngine, engine2);
promise = promiseDefaultNotification();
search.defaultEngine = engine1;
Assert.equal(await promise, engine1);
Assert.equal(search.defaultEngine, engine1);
// Test that hiding the currently-default engine affects the defaultEngine getter
@ -59,8 +44,6 @@ add_task(async function test_defaultEngine() {
// Test that setting defaultEngine to an already-hidden engine works, but
// doesn't change the return value of the getter
promise = promiseDefaultNotification();
search.defaultEngine = engine1;
Assert.equal(await promise, engine1);
Assert.equal(search.defaultEngine, engine2);
});

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

@ -6,10 +6,6 @@ add_task(async function setup() {
useTestEngineConfig();
Services.prefs.setCharPref(SearchUtils.BROWSER_SEARCH_PREF + "region", "US");
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
true
);
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault",
true

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

@ -17,10 +17,6 @@ add_task(async function setup() {
useTestEngineConfig();
Services.prefs.setCharPref(SearchUtils.BROWSER_SEARCH_PREF + "region", "US");
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
true
);
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault",
true
@ -49,13 +45,7 @@ add_task(async function test_defaultPrivateEngine() {
"Should have the original default as the default engine"
);
let promise = promiseDefaultNotification("private");
Services.search.defaultPrivateEngine = engine1;
Assert.equal(
await promise,
engine1,
"Should have notified setting the private engine to the new one"
);
Assert.equal(
Services.search.defaultPrivateEngine,
engine1,
@ -66,13 +56,7 @@ add_task(async function test_defaultPrivateEngine() {
originalDefault,
"Should not have changed the original default engine"
);
promise = promiseDefaultNotification("private");
await Services.search.setDefaultPrivate(engine2);
Assert.equal(
await promise,
engine2,
"Should have notified setting the private engine to the new one using async api"
);
Assert.equal(
Services.search.defaultPrivateEngine,
engine2,
@ -92,13 +76,7 @@ add_task(async function test_defaultPrivateEngine() {
"Should not have changed the original default engine"
);
promise = promiseDefaultNotification("private");
await Services.search.setDefaultPrivate(engine1);
Assert.equal(
await promise,
engine1,
"Should have notified reverting the private engine to the selected one using async api"
);
Assert.equal(
Services.search.defaultPrivateEngine,
engine1,
@ -129,33 +107,12 @@ add_task(async function test_defaultPrivateEngine() {
});
add_task(async function test_defaultPrivateEngine_turned_off() {
Services.search.defaultEngine = originalDefault;
Services.search.defaultPrivateEngine = engine1;
let promise = promiseDefaultNotification("private");
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault",
false
);
Assert.equal(
await promise,
originalDefault,
"Should have notified setting the first engine correctly."
);
promise = promiseDefaultNotification("normal");
let privatePromise = promiseDefaultNotification("private");
Services.search.defaultPrivateEngine = engine1;
Assert.equal(
await promise,
engine1,
"Should have notified setting the first engine correctly."
);
Assert.equal(
await privatePromise,
engine1,
"Should have notified setting of the private engine as well."
);
Assert.equal(
Services.search.defaultPrivateEngine,
engine1,
@ -166,13 +123,7 @@ add_task(async function test_defaultPrivateEngine_turned_off() {
engine1,
"Should keep the default engine in sync with the pref off"
);
promise = promiseDefaultNotification("normal");
Services.search.defaultPrivateEngine = engine2;
Assert.equal(
await promise,
engine2,
"Should have notified setting the second engine correctly."
);
Assert.equal(
Services.search.defaultPrivateEngine,
engine2,
@ -183,13 +134,7 @@ add_task(async function test_defaultPrivateEngine_turned_off() {
engine2,
"Should keep the default engine in sync with the pref off"
);
promise = promiseDefaultNotification("normal");
Services.search.defaultPrivateEngine = engine1;
Assert.equal(
await promise,
engine1,
"Should have notified resetting to the first engine again"
);
Assert.equal(
Services.search.defaultPrivateEngine,
engine1,
@ -244,39 +189,3 @@ add_task(async function test_defaultPrivateEngine_turned_off() {
"Should also keep the normal default if attempted to be set to a hidden engine"
);
});
add_task(async function test_defaultPrivateEngine_ui_turned_off() {
engine1.hidden = false;
engine2.hidden = false;
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault",
true
);
Services.search.defaultEngine = engine2;
Services.search.defaultPrivateEngine = engine1;
let promise = promiseDefaultNotification("private");
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
false
);
Assert.equal(
await promise,
engine2,
"Should have notified for resetting of the private pref."
);
promise = promiseDefaultNotification("normal");
Services.search.defaultPrivateEngine = engine1;
Assert.equal(
await promise,
engine1,
"Should have notified setting the first engine correctly."
);
Assert.equal(
Services.search.defaultPrivateEngine,
engine1,
"Should be set to the first engine correctly"
);
});

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

@ -8,10 +8,6 @@
add_task(function test_setup() {
useTestEngineConfig();
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
true
);
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault",
true

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

@ -11,10 +11,6 @@
add_task(async function test_searchDefaultEngineUS() {
useTestEngineConfig("resource://test/data1/");
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
true
);
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault",
true

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

@ -9,11 +9,6 @@
add_task(async function test_searchDefaultEngineUS() {
useTestEngineConfig();
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
true
);
Services.prefs.setCharPref(SearchUtils.BROWSER_SEARCH_PREF + "region", "US");
await AddonTestUtils.promiseStartupManager();

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

@ -8,11 +8,6 @@
add_task(async function setup() {
await AddonTestUtils.promiseStartupManager();
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
true
);
useTestEngineConfig();
});

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

@ -55,10 +55,6 @@ add_task(async function setup() {
await AddonTestUtils.promiseStartupManager();
useHttpServer();
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
true
);
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault",
true

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

@ -1894,10 +1894,6 @@ async function checkDefaultSearch(privateOn, reInitSearchService) {
);
// Start off with separate default engine for private browsing turned off.
Preferences.set(
"browser.search.separatePrivateDefault.ui.enabled",
privateOn
);
Preferences.set("browser.search.separatePrivateDefault", privateOn);
let data = await TelemetryEnvironment.testCleanRestart().onInitialized();