Bug 1173939 - Race condition in browser.urlbar.suggest. preferences handlers. r=adw
authorMarco Bonardo <mbonardo@mozilla.com>
Thu, 16 Jul 2015 13:37:47 +0200
changeset 253394 bee4bb9284f3f714ce809f8c26e01e531e142163
parent 253393 8b82cd6f0178faa46f7d6844a8af971663bb26bd
child 253395 a5b19d05fcdbbc2e58d0e164e6e6923ebcd224dc
push id62438
push userryanvm@gmail.com
push dateFri, 17 Jul 2015 14:27:33 +0000
treeherdermozilla-inbound@ea2b6887033b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1173939
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1173939 - Race condition in browser.urlbar.suggest. preferences handlers. r=adw
browser/components/preferences/in-content/privacy.js
browser/components/preferences/in-content/privacy.xul
browser/components/preferences/privacy.js
browser/components/preferences/privacy.xul
toolkit/components/places/UnifiedComplete.js
toolkit/components/places/nsPlacesAutoComplete.js
toolkit/components/places/tests/autocomplete/test_enabled.js
toolkit/components/places/tests/unifiedcomplete/test_enabled.js
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -364,29 +364,16 @@ var gPrivacyPane = {
       mode.selectedIndex = this._lastMode;
       mode.doCommand();
 
       this._shouldPromptForRestart = true;
   },
 
   // HISTORY
 
-  /**
-   * Update browser.urlbar.autocomplete.enabled when a
-   * browser.urlbar.suggest.* pref is changed from the ui.
-   */
-  writeSuggestionPref() {
-    let getVal = (aPref) => {
-      return document.getElementById("browser.urlbar.suggest." + aPref).value;
-    }
-    // autocomplete.enabled is true if any of the suggestions is true
-    let enabled = ["history", "bookmark", "openpage", "searches"].map(getVal).some(v => v);
-    Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", enabled);
-  },
-
   /*
    * Preferences:
    *
    * places.history.enabled
    * - whether history is enabled or not
    * browser.formfill.enable
    * - true if entries in forms and the search bar should be saved, false
    *   otherwise
--- a/browser/components/preferences/in-content/privacy.xul
+++ b/browser/components/preferences/in-content/privacy.xul
@@ -248,25 +248,21 @@
 
 <!-- Location Bar -->
 <groupbox id="locationBarGroup"
           data-category="panePrivacy"
           hidden="true">
   <caption><label>&locationBar.label;</label></caption>
   <label id="locationBarSuggestionLabel">&locbar.suggest.label;</label>
   <checkbox id="historySuggestion" label="&locbar.history.label;"
-            onsyncfrompreference="return gPrivacyPane.writeSuggestionPref();"
             accesskey="&locbar.history.accesskey;"
             preference="browser.urlbar.suggest.history"/>
   <checkbox id="bookmarkSuggestion" label="&locbar.bookmarks.label;"
-            onsyncfrompreference="return gPrivacyPane.writeSuggestionPref();"
             accesskey="&locbar.bookmarks.accesskey;"
             preference="browser.urlbar.suggest.bookmark"/>
   <checkbox id="openpageSuggestion" label="&locbar.openpage.label;"
-            onsyncfrompreference="return gPrivacyPane.writeSuggestionPref();"
             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"/>
 </groupbox>
--- a/browser/components/preferences/privacy.js
+++ b/browser/components/preferences/privacy.js
@@ -319,29 +319,16 @@ var gPrivacyPane = {
       mode.selectedIndex = this._lastMode;
       mode.doCommand();
 
       this._shouldPromptForRestart = true;
   },
 
   // HISTORY
 
-  /**
-   * Update browser.urlbar.autocomplete.enabled when a
-   * browser.urlbar.suggest.* pref is changed from the ui.
-   */
-  writeSuggestionPref() {
-    let getVal = (aPref) => {
-      return document.getElementById("browser.urlbar.suggest." + aPref).value;
-    }
-    // autocomplete.enabled is true if any of the suggestions is true
-    let enabled = ["history", "bookmark", "openpage", "searches"].map(getVal).some(v => v);
-    Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", enabled);
-  },
-
   /*
    * Preferences:
    *
    * places.history.enabled
    * - whether history is enabled or not
    * browser.formfill.enable
    * - true if entries in forms and the search bar should be saved, false
    *   otherwise
--- a/browser/components/preferences/privacy.xul
+++ b/browser/components/preferences/privacy.xul
@@ -267,30 +267,26 @@
     <!-- Location Bar -->
     <groupbox id="locationBarGroup">
       <caption label="&locationBar.label;"/>
 
       <label id="locationBarSuggestionLabel">&locbar.suggest.label;</label>
 
       <vbox id="tabPrefsBox" align="start" flex="1">
         <checkbox id="historySuggestion" label="&locbar.history.label;"
-                  onsyncfrompreference="return gPrivacyPane.writeSuggestionPref();"
                   accesskey="&locbar.history.accesskey;"
                   preference="browser.urlbar.suggest.history"/>
         <checkbox id="bookmarkSuggestion" label="&locbar.bookmarks.label;"
-                  onsyncfrompreference="return gPrivacyPane.writeSuggestionPref();"
                   accesskey="&locbar.bookmarks.accesskey;"
                   preference="browser.urlbar.suggest.bookmark"/>
         <checkbox id="openpageSuggestion" label="&locbar.openpage.label;"
-                  onsyncfrompreference="return gPrivacyPane.writeSuggestionPref();"
                   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"/>
       </vbox>
     </groupbox>
 
   </prefpane>
 
 </overlay>
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -341,53 +341,64 @@ XPCOMUtils.defineLazyGetter(this, "Switc
   }
 }));
 
 /**
  * This helper keeps track of preferences and keeps their values up-to-date.
  */
 XPCOMUtils.defineLazyGetter(this, "Prefs", () => {
   let prefs = new Preferences(PREF_BRANCH);
-  let types = ["History", "Bookmark", "Openpage", "Typed", "Searches"];
+  let types = ["History", "Bookmark", "Openpage", "Searches"];
 
-  function syncEnabledPref(init = false) {
+  function syncEnabledPref() {
+    loadSyncedPrefs();
+
     let suggestPrefs = [
       PREF_SUGGEST_HISTORY,
       PREF_SUGGEST_BOOKMARK,
       PREF_SUGGEST_OPENPAGE,
       PREF_SUGGEST_SEARCHES,
     ];
 
-    if (init) {
-      // Make sure to initialize the properties when first called with init = true.
-      store.enabled = prefs.get(...PREF_ENABLED);
-      store.suggestHistory = prefs.get(...PREF_SUGGEST_HISTORY);
-      store.suggestBookmark = prefs.get(...PREF_SUGGEST_BOOKMARK);
-      store.suggestOpenpage = prefs.get(...PREF_SUGGEST_OPENPAGE);
-      store.suggestTyped = prefs.get(...PREF_SUGGEST_HISTORY_ONLYTYPED);
-      store.suggestSearches = prefs.get(...PREF_SUGGEST_SEARCHES);
-    }
-
     if (store.enabled) {
       // If the autocomplete preference is active, set to default value all suggest
       // preferences only if all of them are false.
       if (types.every(type => store["suggest" + type] == false)) {
         for (let type of suggestPrefs) {
           prefs.set(...type);
         }
       }
     } else {
       // If the preference was deactivated, deactivate all suggest preferences.
       for (let type of suggestPrefs) {
         prefs.set(type[0], false);
       }
     }
   }
 
+  function loadSyncedPrefs () {
+    store.enabled = prefs.get(...PREF_ENABLED);
+    store.suggestHistory = prefs.get(...PREF_SUGGEST_HISTORY);
+    store.suggestBookmark = prefs.get(...PREF_SUGGEST_BOOKMARK);
+    store.suggestOpenpage = prefs.get(...PREF_SUGGEST_OPENPAGE);
+    store.suggestTyped = prefs.get(...PREF_SUGGEST_HISTORY_ONLYTYPED);
+    store.suggestSearches = prefs.get(...PREF_SUGGEST_SEARCHES);
+  }
+
   function loadPrefs(subject, topic, data) {
+    if (data) {
+      // Synchronize suggest.* prefs with autocomplete.enabled.
+      if (data == PREF_BRANCH + PREF_ENABLED[0]) {
+        syncEnabledPref();
+      } else if (data.startsWith(PREF_BRANCH + "suggest.")) {
+        loadSyncedPrefs();
+        prefs.set(PREF_ENABLED[0], types.some(type => store["suggest" + type]));
+      }
+    }
+
     store.enabled = prefs.get(...PREF_ENABLED);
     store.autofill = prefs.get(...PREF_AUTOFILL);
     store.autofillTyped = prefs.get(...PREF_AUTOFILL_TYPED);
     store.autofillSearchEngines = prefs.get(...PREF_AUTOFILL_SEARCHENGINES);
     store.restyleSearches = prefs.get(...PREF_RESTYLESEARCHES);
     store.delay = prefs.get(...PREF_DELAY);
     store.matchBehavior = prefs.get(...PREF_BEHAVIOR);
     store.filterJavaScript = prefs.get(...PREF_FILTER_JS);
@@ -405,17 +416,17 @@ XPCOMUtils.defineLazyGetter(this, "Prefs
     store.suggestOpenpage = prefs.get(...PREF_SUGGEST_OPENPAGE);
     store.suggestTyped = prefs.get(...PREF_SUGGEST_HISTORY_ONLYTYPED);
     store.suggestSearches = prefs.get(...PREF_SUGGEST_SEARCHES);
 
     // If history is not set, onlyTyped value should be ignored.
     if (!store.suggestHistory) {
       store.suggestTyped = false;
     }
-    store.defaultBehavior = types.reduce((memo, type) => {
+    store.defaultBehavior = types.concat("Typed").reduce((memo, type) => {
       let prefValue = store["suggest" + type];
       return memo | (prefValue &&
                      Ci.mozIPlacesAutoComplete["BEHAVIOR_" + type.toUpperCase()]);
     }, 0);
 
     // Further restrictions to apply for "empty searches" (i.e. searches for "").
     // The empty behavior is typed history, if history is enabled. Otherwise,
     // it is bookmarks, if they are enabled. If both history and bookmarks are disabled,
@@ -442,31 +453,33 @@ XPCOMUtils.defineLazyGetter(this, "Prefs
       [ store.restrictBookmarkToken, "bookmark" ],
       [ store.restrictTagToken, "tag" ],
       [ store.restrictOpenPageToken, "openpage" ],
       [ store.matchTitleToken, "title" ],
       [ store.matchURLToken, "url" ],
       [ store.restrictTypedToken, "typed" ],
       [ store.restrictSearchesToken, "searches" ],
     ]);
-
-    // Synchronize suggest.* prefs with autocomplete.enabled every time
-    // autocomplete.enabled is changed.
-    if (data == PREF_BRANCH + PREF_ENABLED[0]) {
-      syncEnabledPref();
-    }
   }
 
   let store = {
-    observe: loadPrefs,
+    _ignoreNotifications: false,
+    observe(subject, topic, data) {
+      // Avoid re-entrancy when flipping linked preferences.
+      if (this._ignoreNotifications)
+        return;
+      this._ignoreNotifications = true;
+      loadPrefs(subject, topic, data);
+      this._ignoreNotifications = false;
+    },
     QueryInterface: XPCOMUtils.generateQI([ Ci.nsIObserver ])
   };
 
   // Synchronize suggest.* prefs with autocomplete.enabled at initialization
-  syncEnabledPref(true);
+  syncEnabledPref();
 
   loadPrefs();
   prefs.observe("", store);
 
   return Object.seal(store);
 });
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/toolkit/components/places/nsPlacesAutoComplete.js
+++ b/toolkit/components/places/nsPlacesAutoComplete.js
@@ -198,16 +198,29 @@ function safePrefGetter(aPrefBranch, aNa
   try {
     return aPrefBranch["get" + type + "Pref"](aName);
   }
   catch (e) {
     return aDefault;
   }
 }
 
+/**
+ * Whether UnifiedComplete is alive.
+ */
+function isUnifiedCompleteInstantiated() {
+  try {
+    return Components.manager.QueryInterface(Ci.nsIServiceManager)
+                     .isServiceInstantiated(Cc["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"],
+                                            Ci.mozIPlacesAutoComplete);
+  } catch (ex) {
+    return false;
+  }
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 //// AutoCompleteStatementCallbackWrapper class
 
 /**
  * Wraps a callback and ensures that handleCompletion is not dispatched if the
  * query is no longer tracked.
  *
  * @param aAutocomplete
@@ -459,17 +472,17 @@ function nsPlacesAutoComplete()
 
   //////////////////////////////////////////////////////////////////////////////
   //// Initialization
 
   // load preferences
   this._prefs = Cc["@mozilla.org/preferences-service;1"].
                 getService(Ci.nsIPrefService).
                 getBranch(kBrowserUrlbarBranch);
-  this._syncEnabledPref(true);
+  this._syncEnabledPref();
   this._loadPrefs(true);
 
   // register observers
   this._os = Cc["@mozilla.org/observer-service;1"].
               getService(Ci.nsIObserverService);
   this._os.addObserver(this, kTopicShutdown, false);
 
 }
@@ -691,17 +704,22 @@ nsPlacesAutoComplete.prototype = {
         }
       }
 
       if (this._databaseInitialized) {
         this._db.asyncClose();
       }
     }
     else if (aTopic == kPrefChanged) {
-      this._loadPrefs(aSubject, aTopic, aData);
+      // Avoid re-entrancy when flipping linked preferences.
+      if (this._ignoreNotifications)
+        return;
+      this._ignoreNotifications = true;
+      this._loadPrefs(false, aTopic, aData);
+      this._ignoreNotifications = false;
     }
   },
 
   //////////////////////////////////////////////////////////////////////////////
   //// nsPlacesAutoComplete
 
   get _databaseInitialized()
     Object.getOwnPropertyDescriptor(this, "_db").value !== undefined,
@@ -802,30 +820,26 @@ nsPlacesAutoComplete.prototype = {
       }
       this._telemetryStartTime = null;
     }
   },
 
   /**
    * Synchronize suggest.* prefs with autocomplete.enabled.
    */
-  _syncEnabledPref: function PAC_syncEnabledPref(init = false)
+  _syncEnabledPref: function PAC_syncEnabledPref()
   {
     let suggestPrefs = ["suggest.history", "suggest.bookmark", "suggest.openpage"];
-    let types = ["History", "Bookmark", "Openpage", "Typed"];
+    let types = ["History", "Bookmark", "Openpage"];
 
-    if (init) {
-      // Make sure to initialize the properties when first called with init = true.
-      this._enabled = safePrefGetter(this._prefs, kBrowserUrlbarAutocompleteEnabledPref,
-                                     true);
-      this._suggestHistory = safePrefGetter(this._prefs, "suggest.history", true);
-      this._suggestBookmark = safePrefGetter(this._prefs, "suggest.bookmark", true);
-      this._suggestOpenpage = safePrefGetter(this._prefs, "suggest.openpage", true);
-      this._suggestTyped = safePrefGetter(this._prefs, "suggest.history.onlyTyped", false);
-    }
+    this._enabled = safePrefGetter(this._prefs, kBrowserUrlbarAutocompleteEnabledPref,
+                                   true);
+    this._suggestHistory = safePrefGetter(this._prefs, "suggest.history", true);
+    this._suggestBookmark = safePrefGetter(this._prefs, "suggest.bookmark", true);
+    this._suggestOpenpage = safePrefGetter(this._prefs, "suggest.openpage", true);
 
     if (this._enabled) {
       // If the autocomplete preference is active, activate all suggest
       // preferences only if all of them are false.
       if (types.every(type => this["_suggest" + type] == false)) {
         for (let type of suggestPrefs) {
           this._prefs.setBoolPref(type, true);
         }
@@ -846,16 +860,28 @@ nsPlacesAutoComplete.prototype = {
    *        default value is false.
    * @param [optional] aTopic
    *        Observer's topic, if any.
    * @param [optional] aSubject
    *        Observer's subject, if any.
    */
   _loadPrefs: function PAC_loadPrefs(aRegisterObserver, aTopic, aData)
   {
+    // Avoid race conditions with UnifiedComplete component.
+    if (aData && !isUnifiedCompleteInstantiated()) {
+      // Synchronize suggest.* prefs with autocomplete.enabled.
+      if (aData == kBrowserUrlbarAutocompleteEnabledPref) {
+        this._syncEnabledPref();
+      } else if (aData.startsWith("suggest.")) {
+        let suggestPrefs = ["suggest.history", "suggest.bookmark", "suggest.openpage"];
+        this._prefs.setBoolPref(kBrowserUrlbarAutocompleteEnabledPref,
+                                suggestPrefs.some(pref => safePrefGetter(this._prefs, pref, true)));
+      }
+    }
+
     this._enabled = safePrefGetter(this._prefs,
                                    kBrowserUrlbarAutocompleteEnabledPref,
                                    true);
     this._matchBehavior = safePrefGetter(this._prefs,
                                          "matchBehavior",
                                          MATCH_BOUNDARY_ANYWHERE);
     this._filterJavaScript = safePrefGetter(this._prefs, "filter.javascript", true);
     this._maxRichResults = safePrefGetter(this._prefs, "maxRichResults", 25);
@@ -905,22 +931,16 @@ nsPlacesAutoComplete.prototype = {
         this._matchBehavior != MATCH_BOUNDARY &&
         this._matchBehavior != MATCH_BEGINNING) {
       this._matchBehavior = MATCH_BOUNDARY_ANYWHERE;
     }
     // register observer
     if (aRegisterObserver) {
       this._prefs.addObserver("", this, false);
     }
-
-    // Synchronize suggest.* prefs with autocomplete.enabled every time
-    // autocomplete.enabled is changed.
-    if (aData == kBrowserUrlbarAutocompleteEnabledPref) {
-      this._syncEnabledPref();
-    }
   },
 
   /**
    * Given an array of tokens, this function determines which query should be
    * ran.  It also removes any special search tokens.
    *
    * @param aTokens
    *        An array of search tokens.
--- a/toolkit/components/places/tests/autocomplete/test_enabled.js
+++ b/toolkit/components/places/tests/autocomplete/test_enabled.js
@@ -26,8 +26,44 @@ let gTests = [
    "url", [], function() setSearch(0)],
   ["3: resume normal search",
    "url", [0], function() setSearch(1)],
 ];
 
 function setSearch(aSearch) {
   prefs.setBoolPref("browser.urlbar.autocomplete.enabled", !!aSearch);
 }
+
+add_task(function* test_sync_enabled() {
+  // Initialize unified complete.
+  Cc["@mozilla.org/autocomplete/search;1?name=history"]
+    .getService(Ci.mozIPlacesAutoComplete);
+
+  let types = [ "history", "bookmark", "openpage" ];
+
+  // Test the service keeps browser.urlbar.autocomplete.enabled synchronized
+  // with browser.urlbar.suggest prefs.
+  for (let type of types) {
+    Services.prefs.setBoolPref("browser.urlbar.suggest." + type, true);
+  }
+  Assert.equal(Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled"), true);
+
+  // Disable autocomplete and check all the suggest prefs are set to false.
+  Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", false);
+  for (let type of types) {
+    Assert.equal(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), false);
+  }
+
+  // Setting even a single suggest pref to true should enable autocomplete.
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
+  for (let type of types.filter(t => t != "history")) {
+    Assert.equal(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), false);
+  }
+  Assert.equal(Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled"), true);
+
+  // Disable autocoplete again, then re-enable it and check suggest prefs
+  // have been reset.
+  Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", false);
+  Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", true);
+  for (let type of types.filter(t => t != "history")) {
+    Assert.equal(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), true);
+  }
+});
--- a/toolkit/components/places/tests/unifiedcomplete/test_enabled.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_enabled.js
@@ -1,18 +1,11 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-/**
- * Test for bug 471903 to make sure searching in autocomplete can be turned on
- * and off. Also test bug 463535 for pref changing search.
- */
-
 add_task(function* test_enabled() {
+  // Test for bug 471903 to make sure searching in autocomplete can be turned on
+  // and off. Also test bug 463535 for pref changing search.
   let uri = NetUtil.newURI("http://url/0");
   yield PlacesTestUtils.addVisits([ { uri: uri, title: "title" } ]);
 
   do_print("plain search");
   yield check_autocomplete({
     search: "url",
     matches: [ { uri: uri, title: "title" } ]
   });
@@ -28,8 +21,44 @@ add_task(function* test_enabled() {
   Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", true);
   yield check_autocomplete({
     search: "url",
     matches: [ { uri: uri, title: "title" } ]
   });
 
   yield cleanup();
 });
+
+add_task(function* test_sync_enabled() {
+  // Initialize unified complete.
+  Cc["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"]
+    .getService(Ci.mozIPlacesAutoComplete);
+
+  let types = [ "history", "bookmark", "openpage", "searches" ];
+
+  // Test the service keeps browser.urlbar.autocomplete.enabled synchronized
+  // with browser.urlbar.suggest prefs.
+  for (let type of types) {
+    Services.prefs.setBoolPref("browser.urlbar.suggest." + type, true);
+  }
+  Assert.equal(Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled"), true);
+
+  // Disable autocomplete and check all the suggest prefs are set to false.
+  Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", false);
+  for (let type of types) {
+    Assert.equal(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), false);
+  }
+
+  // Setting even a single suggest pref to true should enable autocomplete.
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
+  for (let type of types.filter(t => t != "history")) {
+    Assert.equal(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), false);
+  }
+  Assert.equal(Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled"), true);
+
+  // Disable autocoplete again, then re-enable it and check suggest prefs
+  // have been reset.
+  Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", false);
+  Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", true);
+  for (let type of types.filter(t => t != "history")) {
+    Assert.equal(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), true);
+  }
+});