Skip to content

Commit

Permalink
Bug 1755996 - Add pref for removal of search engine infobar. r=Standard8
Browse files Browse the repository at this point in the history
  • Loading branch information
mandysGit committed Feb 17, 2022
1 parent dd2739a commit 925925f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ function submitHandler(request, response) {
}

add_task(async function setup() {
// This ensures the infobar is not shown in this test.
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
sinon.stub(BrowserSearch, "removalOfSearchEngineNotificationBox");
// Ensure the initial init is complete.
await Services.search.init();

Expand Down Expand Up @@ -91,7 +88,6 @@ add_task(async function setup() {
await PlacesUtils.history.clear();
gCUITestUtils.removeSearchBar();
await settingsWritten;
sinon.restore();
});
});

Expand Down
1 change: 1 addition & 0 deletions modules/libpref/init/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4109,6 +4109,7 @@ pref("browser.search.suggest.enabled", true);
pref("browser.search.suggest.enabled.private", false);
pref("browser.search.separatePrivateDefault", false);
pref("browser.search.separatePrivateDefault.ui.enabled", false);
pref("browser.search.removeEngineInfobar.enabled", true);

// GMPInstallManager prefs

Expand Down
2 changes: 2 additions & 0 deletions testing/profiles/common/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ user_pref("browser.pagethumbnails.capturing_disabled", true);
// Tell the search service we are running in the US. This also has the desired
// side-effect of preventing our geoip lookup.
user_pref("browser.search.region", "US");
// disable infobar for tests
user_pref("browser.search.removeEngineInfobar.enabled", false);
// Disable webapp updates. Yes, it is supposed to be an integer.
user_pref("browser.webapps.checkForUpdates", 0);
// We do not wish to display datareporting policy notifications as it might
Expand Down
6 changes: 4 additions & 2 deletions toolkit/components/search/SearchService.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ SearchService.prototype = {
newCurrentEngine !== prevCurrentEngine &&
prevMetaData &&
settings.metaData &&
!this._hasUserMetaDataChanged(prevMetaData)
!this._hasUserMetaDataChanged(prevMetaData) &&
Services.prefs.getBoolPref("browser.search.removeEngineInfobar.enabled")
) {
this._showRemovalOfSearchEngineNotificationBox(
prevCurrentEngine,
Expand Down Expand Up @@ -837,7 +838,8 @@ SearchService.prototype = {
if (
prevMetaData &&
settings.metaData &&
!this._hasUserMetaDataChanged(prevMetaData)
!this._hasUserMetaDataChanged(prevMetaData) &&
Services.prefs.getBoolPref("browser.search.removeEngineInfobar.enabled")
) {
this._showRemovalOfSearchEngineNotificationBox(
prevCurrentEngine.name,
Expand Down
11 changes: 4 additions & 7 deletions toolkit/components/search/tests/xpcshell/test_selectedEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
const kDefaultEngineName = "engine1";

add_task(async function setup() {
// Stub removal of search engine notification box.
// This ensures that BrowserSearch.win is not accessed in this test.
sinon.stub(
await Services.search.wrappedJSObject,
"_showRemovalOfSearchEngineNotificationBox"
);

useHttpServer();
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.useTestEngines("data1");
Assert.ok(!Services.search.isInitialized);
Services.prefs.setBoolPref(
"browser.search.removeEngineInfobar.enabled",
false
);
});

// Check that the default engine matches the defaultenginename pref
Expand Down
2 changes: 2 additions & 0 deletions toolkit/components/search/tests/xpcshell/xpcshell.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ head = head_search.js
dupe-manifest =
tags=searchmain
skip-if = toolkit == 'android'
prefs =
browser.search.removeEngineInfobar.enabled=true

support-files =
data/engine.xml
Expand Down

0 comments on commit 925925f

Please sign in to comment.