Bug 1176205: Disable search suggestions by default and hide the UI on non-nightly builds. r=adw, r=mak

This commit is contained in:
Dave Townsend 2015-06-24 14:09:59 -07:00
parent ee106814cf
commit c4c0b06f69
17 changed files with 48 additions and 43 deletions

View File

@ -348,7 +348,11 @@ pref("browser.urlbar.match.url", "@");
pref("browser.urlbar.suggest.history", true);
pref("browser.urlbar.suggest.bookmark", true);
pref("browser.urlbar.suggest.openpage", true);
#ifdef NIGHTLY_BUILD
pref("browser.urlbar.suggest.searches", true);
#else
pref("browser.urlbar.suggest.searches", false);
#endif
// Restrictions to current suggestions can also be applied (intersection).
// Typed suggestion works only if history is set to true.

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/AppConstants.jsm");
var gPrivacyPane = {
/**
@ -103,6 +105,8 @@ var gPrivacyPane = {
gPrivacyPane.showCookies);
setEventListener("clearDataSettings", "command",
gPrivacyPane.showClearPrivateDataSettings);
document.getElementById("searchesSuggestion").hidden = !AppConstants.NIGHTLY_BUILD;
},
// HISTORY MODE

View File

@ -258,6 +258,7 @@
accesskey="&locbar.openpage.accesskey;"
preference="browser.urlbar.suggest.openpage"/>
<checkbox id="searchesSuggestion" label="&locbar.searches.label;"
hidden="true"
onsyncfrompreference="return gPrivacyPane.writeSuggestionPref();"
accesskey="&locbar.searches.accesskey;"
preference="browser.urlbar.suggest.searches"/>

View File

@ -19,8 +19,5 @@ function test() {
test_dependent_cookie_elements,
test_dependent_clearonclose_elements,
test_dependent_prefs,
// reset all preferences to their default values once we're done
reset_preferences
]);
}

View File

@ -18,8 +18,5 @@ function test() {
test_custom_retention("rememberForms", "remember"),
test_custom_retention("rememberForms", "custom"),
test_historymode_retention("remember", "remember"),
// reset all preferences to their default values once we're done
reset_preferences
]);
}

View File

@ -27,8 +27,5 @@ function test() {
test_custom_retention("alwaysClear", "remember"),
test_custom_retention("alwaysClear", "custom"),
test_historymode_retention("remember", "remember"),
// reset all preferences to their default values once we're done
reset_preferences
]));
}

View File

@ -12,15 +12,16 @@ function test() {
}
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
run_test_subset([
let tests = [
test_locbar_suggestion_retention("history", true),
test_locbar_suggestion_retention("bookmark", true),
test_locbar_suggestion_retention("searches", true),
test_locbar_suggestion_retention("openpage", false),
test_locbar_suggestion_retention("history", true),
test_locbar_suggestion_retention("history", false),
];
// reset all preferences to their default values once we're done
reset_preferences
]);
if (AppConstants.NIGHTLY_BUILD)
tests.push(test_locbar_suggestion_retention("searches", true)),
run_test_subset(tests);
}

View File

@ -27,8 +27,5 @@ function test() {
// history mode should now be remember
test_historymode_retention("remember", "remember"),
// reset all preferences to their default values once we're done
reset_preferences
]);
}

View File

@ -315,11 +315,18 @@ function test_locbar_suggestion_retention(suggestion, autocomplete) {
};
}
const gPrefCache = new Map();
function cache_preferences(win) {
let prefs = win.document.querySelectorAll("#privacyPreferences > preference");
for (let pref of prefs)
gPrefCache.set(pref.name, pref.value);
}
function reset_preferences(win) {
let prefs = win.document.querySelectorAll("#privacyPreferences > preference");
for (let i = 0; i < prefs.length; ++i)
if (prefs[i].hasUserValue)
prefs[i].reset();
for (let pref of prefs)
pref.value = gPrefCache.get(pref.name);
}
let testRunner;
@ -334,7 +341,7 @@ function run_test_subset(subset) {
});
testRunner = {
tests: subset,
tests: [cache_preferences, ...subset, reset_preferences],
counter: 0,
runNext: function() {
if (this.counter == this.tests.length) {

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/AppConstants.jsm");
var gPrivacyPane = {
@ -69,6 +70,8 @@ var gPrivacyPane = {
this._initTrackingProtection();
#endif
this._initAutocomplete();
document.getElementById("searchesSuggestion").hidden = !AppConstants.NIGHTLY_BUILD;
},
// HISTORY MODE

View File

@ -284,6 +284,7 @@
accesskey="&locbar.openpage.accesskey;"
preference="browser.urlbar.suggest.openpage"/>
<checkbox id="searchesSuggestion" label="&locbar.searches.label;"
hidden="true"
onsyncfrompreference="return gPrivacyPane.writeSuggestionPref();"
accesskey="&locbar.searches.accesskey;"
preference="browser.urlbar.suggest.searches"/>

View File

@ -20,8 +20,5 @@ function test() {
test_dependent_cookie_elements,
test_dependent_clearonclose_elements,
test_dependent_prefs,
// reset all preferences to their default values once we're done
reset_preferences
]);
}

View File

@ -19,8 +19,5 @@ function test() {
test_custom_retention("rememberForms", "remember"),
test_custom_retention("rememberForms", "custom"),
test_historymode_retention("remember", "remember"),
// reset all preferences to their default values once we're done
reset_preferences
]);
}

View File

@ -28,8 +28,5 @@ function test() {
test_custom_retention("alwaysClear", "remember"),
test_custom_retention("alwaysClear", "custom"),
test_historymode_retention("remember", "remember"),
// reset all preferences to their default values once we're done
reset_preferences
]));
}

View File

@ -12,15 +12,16 @@ function test() {
}
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
run_test_subset([
let tests = [
test_locbar_suggestion_retention("history", true),
test_locbar_suggestion_retention("bookmark", true),
test_locbar_suggestion_retention("searches", true),
test_locbar_suggestion_retention("openpage", false),
test_locbar_suggestion_retention("history", true),
test_locbar_suggestion_retention("history", false),
];
// reset all preferences to their default values once we're done
reset_preferences
]);
if (AppConstants.NIGHTLY_BUILD)
tests.push(test_locbar_suggestion_retention("searches", true)),
run_test_subset(tests);
}

View File

@ -28,8 +28,5 @@ function test() {
// history mode should now be remember
test_historymode_retention("remember", "remember"),
// reset all preferences to their default values once we're done
reset_preferences
]);
}

View File

@ -321,11 +321,18 @@ function test_locbar_suggestion_retention(suggestion, autocomplete) {
};
}
const gPrefCache = new Map();
function cache_preferences(win) {
let prefs = win.document.querySelectorAll("#privacyPreferences > preference");
for (let pref of prefs)
gPrefCache.set(pref.name, pref.value);
}
function reset_preferences(win) {
let prefs = win.document.getElementsByTagName("preference");
for (let i = 0; i < prefs.length; ++i)
if (prefs[i].hasUserValue)
prefs[i].reset();
let prefs = win.document.querySelectorAll("#privacyPreferences > preference");
for (let pref of prefs)
pref.value = gPrefCache.get(pref.name);
}
let testRunner;
@ -336,7 +343,7 @@ function run_test_subset(subset) {
waitForExplicitFinish();
testRunner = {
tests: subset,
tests: [cache_preferences, ...subset, reset_preferences],
counter: 0,
runNext: function() {
if (this.counter == this.tests.length) {