Bug 1429974 - TypeError: this.syncFromShowSearchSuggestionsFirstPref is not a function. r?mak draft
authorDrew Willcoxon <adw@mozilla.com>
Tue, 16 Jan 2018 16:20:14 -0800
changeset 721296 3d76ba6a083446c90b430be04115b57978c98231
parent 720975 9be7249e74fd7f6d9163b59d3386ed01038197a0
child 746283 db304bc27ea43d00018e9d8dce773424fd4b75ae
push id95784
push userbmo:adw@mozilla.com
push dateWed, 17 Jan 2018 00:20:37 +0000
reviewersmak
bugs1429974
milestone59.0a1
Bug 1429974 - TypeError: this.syncFromShowSearchSuggestionsFirstPref is not a function. r?mak MozReview-Commit-ID: GgNiyRWKpEL
browser/components/preferences/in-content/search.js
browser/components/preferences/in-content/tests/browser_searchShowSuggestionsFirst.js
--- 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);
 });