Bug 1429974 - TypeError: this.syncFromShowSearchSuggestionsFirstPref is not a function. r?mak
MozReview-Commit-ID: GgNiyRWKpEL
--- a/browser/components/preferences/in-content/search.js
+++ b/browser/components/preferences/in-content/search.js
@@ -66,17 +66,17 @@ var gSearchPane = {
},
_initShowSearchSuggestionsFirst() {
let pref = Preferences.get("browser.urlbar.matchBuckets");
let checkbox =
document.getElementById("showSearchSuggestionsFirstCheckbox");
pref.on("change", () => {
- this.syncFromShowSearchSuggestionsFirstPref(checkbox, pref);
+ this._syncFromShowSearchSuggestionsFirstPref(checkbox, pref);
});
this._syncFromShowSearchSuggestionsFirstPref(checkbox, pref);
checkbox.addEventListener("command", () => {
this._syncToShowSearchSuggestionsFirstPref(checkbox.checked, pref);
});
},
--- a/browser/components/preferences/in-content/tests/browser_searchShowSuggestionsFirst.js
+++ b/browser/components/preferences/in-content/tests/browser_searchShowSuggestionsFirst.js
@@ -22,16 +22,24 @@ add_task(async function openWithSearchSu
checkbox.checked = false;
checkbox.doCommand();
// The pref should now be set so that history is shown first.
Assert.equal(Services.prefs.getCharPref(PREF_NAME, ""),
HISTORY_FIRST_PREF_VALUE,
"Pref should now be set to show history first");
+ // Clear the pref.
+ Services.prefs.clearUserPref(PREF_NAME);
+
+ // The checkbox should have become checked again.
+ Assert.equal(checkbox.checked, true,
+ "Checkbox should become checked after clearing pref");
+
+ // Clean up.
gBrowser.removeCurrentTab();
});
// Open preferences with history shown first.
add_task(async function openWithHistoryShownFirst() {
// Set the pref to show history first.
Services.prefs.setCharPref(PREF_NAME, HISTORY_FIRST_PREF_VALUE);
@@ -44,10 +52,19 @@ add_task(async function openWithHistoryS
// Check the checkbox.
checkbox.checked = true;
checkbox.doCommand();
// The pref should now be cleared so that search suggestions are shown first.
Assert.equal(Services.prefs.getCharPref(PREF_NAME, ""), "",
"Pref should now be cleared to show search suggestions first");
+ // Set the pref again.
+ Services.prefs.setCharPref(PREF_NAME, HISTORY_FIRST_PREF_VALUE);
+
+ // The checkbox should have become unchecked again.
+ Assert.equal(checkbox.checked, false,
+ "Checkbox should become unchecked after setting pref");
+
+ // Clean up.
gBrowser.removeCurrentTab();
+ Services.prefs.clearUserPref(PREF_NAME);
});