Bug 530209 - Improve search suggestions ui for locationbar prefs. r=mak
authorAlex Bardas <alex.bardas@gmail.com>
Wed, 12 Nov 2014 08:16:00 -0500
changeset 215418 af22db534027c50734986e23b9451e5616ed0bae
parent 215417 86e5c0b7f1cde727dd86713733066ef32d72fad1
child 215419 d53d4abae160d8433ebe3accb497469933336d84
push id27816
push usercbook@mozilla.com
push dateThu, 13 Nov 2014 13:26:15 +0000
treeherdermozilla-central@44cdce6fca3a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs530209
milestone36.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 530209 - Improve search suggestions ui for locationbar prefs. r=mak
browser/app/profile/firefox.js
browser/components/nsBrowserGlue.js
browser/components/places/tests/unit/test_browserGlue_urlbar_defaultbehavior_migration.js
browser/components/places/tests/unit/xpcshell.ini
browser/components/preferences/in-content/privacy.js
browser/components/preferences/in-content/privacy.xul
browser/components/preferences/in-content/tests/browser_privacypane_5.js
browser/components/preferences/in-content/tests/privacypane_tests_perwindow.js
browser/components/preferences/privacy.js
browser/components/preferences/privacy.xul
browser/components/preferences/tests/browser.ini
browser/components/preferences/tests/browser_privacypane_5.js
browser/components/preferences/tests/privacypane_tests_perwindow.js
browser/locales/en-US/chrome/browser/preferences/privacy.dtd
browser/metro/profile/metro.js
toolkit/components/places/SQLFunctions.cpp
toolkit/components/places/UnifiedComplete.js
toolkit/components/places/mozIPlacesAutoComplete.idl
toolkit/components/places/nsNavHistory.cpp
toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
toolkit/components/places/tests/unifiedcomplete/test_autoFill_default_behavior.js
toolkit/components/places/tests/unifiedcomplete/test_autocomplete_functional.js
toolkit/components/places/tests/unifiedcomplete/test_empty_search.js
toolkit/components/places/tests/unifiedcomplete/test_special_search.js
toolkit/components/places/tests/unit/test_adaptive_bug527311.js
toolkit/components/places/tests/unit/test_frecency.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -345,23 +345,24 @@ pref("browser.urlbar.restrict.history", 
 pref("browser.urlbar.restrict.bookmark", "*");
 pref("browser.urlbar.restrict.tag", "+");
 pref("browser.urlbar.restrict.openpage", "%");
 pref("browser.urlbar.restrict.typed", "~");
 pref("browser.urlbar.match.title", "#");
 pref("browser.urlbar.match.url", "@");
 
 // The default behavior for the urlbar can be configured to use any combination
-// of the restrict or match filters with each additional filter restricting
-// more (intersection). Add the following values to set the behavior as the
-// default: 1: history, 2: bookmark, 4: tag, 8: title, 16: url, 32: typed,
-//          64: javascript, 128: tabs
-// E.g., 0 = show all results (no filtering), 1 = only visited pages in history,
-// 2 = only bookmarks, 3 = visited bookmarks, 1+16 = history matching in the url
-pref("browser.urlbar.default.behavior", 0);
+// of the match filters with each additional filter adding more results (union).
+pref("browser.urlbar.suggest.history",              true);
+pref("browser.urlbar.suggest.bookmark",             true);
+pref("browser.urlbar.suggest.openpage",             true);
+
+// Restrictions to current suggestions can also be applied (intersection).
+// Typed suggestion works only if history is set to true.
+pref("browser.urlbar.suggest.history.onlyTyped",    false);
 
 pref("browser.urlbar.formatting.enabled", true);
 pref("browser.urlbar.trimURLs", true);
 
 pref("browser.altClickSave", false);
 
 // Enable logging downloads operations to the Error Console.
 pref("browser.download.debug", false);
@@ -1257,17 +1258,16 @@ pref("services.sync.prefs.sync.browser.s
 pref("services.sync.prefs.sync.browser.search.update", true);
 pref("services.sync.prefs.sync.browser.sessionstore.restore_on_demand", true);
 pref("services.sync.prefs.sync.browser.startup.homepage", true);
 pref("services.sync.prefs.sync.browser.startup.page", true);
 pref("services.sync.prefs.sync.browser.tabs.loadInBackground", true);
 pref("services.sync.prefs.sync.browser.tabs.warnOnClose", true);
 pref("services.sync.prefs.sync.browser.tabs.warnOnOpen", true);
 pref("services.sync.prefs.sync.browser.urlbar.autocomplete.enabled", true);
-pref("services.sync.prefs.sync.browser.urlbar.default.behavior", true);
 pref("services.sync.prefs.sync.browser.urlbar.maxRichResults", true);
 pref("services.sync.prefs.sync.dom.disable_open_during_load", true);
 pref("services.sync.prefs.sync.dom.disable_window_flip", true);
 pref("services.sync.prefs.sync.dom.disable_window_move_resize", true);
 pref("services.sync.prefs.sync.dom.event.contextmenu.enabled", true);
 pref("services.sync.prefs.sync.extensions.personas.current", true);
 pref("services.sync.prefs.sync.extensions.update.enabled", true);
 pref("services.sync.prefs.sync.intl.accept_languages", true);
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -225,17 +225,17 @@ BrowserGlue.prototype = {
     }
     delay = delay <= MAX_DELAY ? delay : MAX_DELAY;
 
     Cu.import("resource://services-sync/main.js");
     Weave.Service.scheduler.delayedAutoConnect(delay);
   },
 #endif
 
-  // nsIObserver implementation 
+  // nsIObserver implementation
   observe: function BG_observe(subject, topic, data) {
     switch (topic) {
       case "prefservice:after-app-defaults":
         this._onAppDefaults();
         break;
       case "final-ui-startup":
         this._finalUIStartup();
         break;
@@ -1454,17 +1454,17 @@ BrowserGlue.prototype = {
     var notifyBox = win.gBrowser.getNotificationBox();
     var notification = notifyBox.appendNotification(text, title, null,
                                                     notifyBox.PRIORITY_CRITICAL_MEDIUM,
                                                     buttons);
     notification.persistence = -1; // Until user closes it
   },
 
   _migrateUI: function BG__migrateUI() {
-    const UI_VERSION = 25;
+    const UI_VERSION = 26;
     const BROWSER_DOCURL = "chrome://browser/content/browser.xul";
     let currentUIVersion = 0;
     try {
       currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
     } catch(ex) {}
     if (currentUIVersion >= UI_VERSION)
       return;
 
@@ -1730,16 +1730,50 @@ BrowserGlue.prototype = {
             Services.prefs.getIntPref("privacy.donottrackheader.value") != 1) {
           Services.prefs.clearUserPref("privacy.donottrackheader.enabled");
           Services.prefs.clearUserPref("privacy.donottrackheader.value");
         }
       }
       catch (ex) {}
     }
 
+    if (currentUIVersion < 26) {
+      // Refactor urlbar suggestion preferences to make it extendable and
+      // allow new suggestion types (e.g: search suggestions).
+      let types = ["history", "bookmark", "openpage"];
+      let defaultBehavior = 0;
+      try {
+        defaultBehavior = Services.prefs.getIntPref("browser.urlbar.default.behavior");
+      } catch (ex) {}
+      try {
+        let autocompleteEnabled = Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled");
+        if (!autocompleteEnabled) {
+          defaultBehavior = -1;
+        }
+      } catch (ex) {}
+
+      // If the default behavior is:
+      //    -1  - all new "...suggest.*" preferences will be false
+      //     0  - all new "...suggest.*" preferences will use the default values
+      //   > 0  - all new "...suggest.*" preferences will be inherited
+      for (let type of types) {
+        let prefValue = defaultBehavior == 0;
+        if (defaultBehavior > 0) {
+          prefValue = !!(defaultBehavior & Ci.mozIPlacesAutoComplete["BEHAVIOR_" + type.toUpperCase()]);
+        }
+        Services.prefs.setBoolPref("browser.urlbar.suggest." + type, prefValue);
+      }
+
+      // Typed behavior will be used only for results from history.
+      if (defaultBehavior != -1 &&
+          !!(defaultBehavior & Ci.mozIPlacesAutoComplete["BEHAVIOR_TYPED"])) {
+        Services.prefs.setBoolPref("browser.urlbar.suggest.history.onlyTyped", true);
+      }
+    }
+
     // Update the migration version.
     Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
   },
 
   // ------------------------------
   // public nsIBrowserGlue members
   // ------------------------------
 
new file mode 100644
--- /dev/null
+++ b/browser/components/places/tests/unit/test_browserGlue_urlbar_defaultbehavior_migration.js
@@ -0,0 +1,150 @@
+/* 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/. */
+
+const UI_VERSION = 26;
+const TOPIC_BROWSERGLUE_TEST = "browser-glue-test";
+const TOPICDATA_BROWSERGLUE_TEST = "force-ui-migration";
+const DEFAULT_BEHAVIOR_PREF = "browser.urlbar.default.behavior";
+const AUTOCOMPLETE_PREF = "browser.urlbar.autocomplete.enabled";
+
+let gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"]
+                     .getService(Ci.nsIObserver);
+let gGetBoolPref = Services.prefs.getBoolPref;
+
+function run_test() {
+  run_next_test();
+};
+
+do_register_cleanup(cleanup);
+
+function cleanup() {
+  let prefix = "browser.urlbar.suggest.";
+  for (let type of ["history", "bookmark", "openpage", "history.onlyTyped"]) {
+    Services.prefs.clearUserPref(prefix + type);
+  }
+  Services.prefs.clearUserPref("browser.migration.version");
+  Services.prefs.clearUserPref(AUTOCOMPLETE_PREF);
+};
+
+function setupBehaviorAndMigrate(aDefaultBehavior, aAutocompleteEnabled = true) {
+  cleanup();
+  // Migrate browser.urlbar.default.behavior preference.
+  Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
+  Services.prefs.setIntPref(DEFAULT_BEHAVIOR_PREF, aDefaultBehavior);
+  Services.prefs.setBoolPref(AUTOCOMPLETE_PREF, aAutocompleteEnabled);
+  // Simulate a migration.
+  gBrowserGlue.observe(null, TOPIC_BROWSERGLUE_TEST, TOPICDATA_BROWSERGLUE_TEST);
+};
+
+add_task(function*() {
+  do_log_info("Migrate default.behavior = 0");
+  setupBehaviorAndMigrate(0);
+
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),
+    "History preference should be true.");
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.bookmark"),
+    "Bookmark preference should be true.");
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.openpage"),
+    "Openpage preference should be true.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,
+    "Typed preference should be false.");
+});
+
+add_task(function*() {
+  do_log_info("Migrate default.behavior = 1");
+  setupBehaviorAndMigrate(1);
+
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),
+    "History preference should be true.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.bookmark"), false,
+    "Bookmark preference should be false.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,
+    "Openpage preference should be false");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,
+    "Typed preference should be false");
+});
+
+add_task(function*() {
+  do_log_info("Migrate default.behavior = 2");
+  setupBehaviorAndMigrate(2);
+
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history"), false,
+    "History preference should be false.");
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.bookmark"),
+    "Bookmark preference should be true.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,
+    "Openpage preference should be false");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,
+    "Typed preference should be false");
+});
+
+add_task(function*() {
+  do_log_info("Migrate default.behavior = 3");
+  setupBehaviorAndMigrate(3);
+
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),
+    "History preference should be true.");
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.bookmark"),
+    "Bookmark preference should be true.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,
+    "Openpage preference should be false");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,
+    "Typed preference should be false");
+});
+
+add_task(function*() {
+  do_log_info("Migrate default.behavior = 19");
+  setupBehaviorAndMigrate(19);
+
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),
+    "History preference should be true.");
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.bookmark"),
+    "Bookmark preference should be true.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,
+    "Openpage preference should be false");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,
+    "Typed preference should be false");
+});
+
+add_task(function*() {
+  do_log_info("Migrate default.behavior = 33");
+  setupBehaviorAndMigrate(33);
+
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),
+    "History preference should be true.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.bookmark"), false,
+    "Bookmark preference should be false.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,
+    "Openpage preference should be false");
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"),
+    "Typed preference should be true");
+});
+
+add_task(function*() {
+  do_log_info("Migrate default.behavior = 129");
+  setupBehaviorAndMigrate(129);
+
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),
+    "History preference should be true.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.bookmark"), false,
+    "Bookmark preference should be false.");
+  Assert.ok(gGetBoolPref("browser.urlbar.suggest.openpage"),
+    "Openpage preference should be true");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,
+    "Typed preference should be false");
+});
+
+add_task(function*() {
+  do_log_info("Migrate default.behavior = 0, autocomplete.enabled = false");
+  setupBehaviorAndMigrate(0, false);
+
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history"), false,
+    "History preference should be false.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.bookmark"), false,
+    "Bookmark preference should be false.");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,
+    "Openpage preference should be false");
+  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,
+    "Typed preference should be false");
+});
--- a/browser/components/places/tests/unit/xpcshell.ini
+++ b/browser/components/places/tests/unit/xpcshell.ini
@@ -14,11 +14,12 @@ support-files =
 [test_browserGlue_corrupt.js]
 [test_browserGlue_corrupt_nobackup.js]
 [test_browserGlue_corrupt_nobackup_default.js]
 [test_browserGlue_distribution.js]
 [test_browserGlue_migrate.js]
 [test_browserGlue_prefs.js]
 [test_browserGlue_restore.js]
 [test_browserGlue_smartBookmarks.js]
+[test_browserGlue_urlbar_defaultbehavior_migration.js]
 [test_clearHistory_shutdown.js]
 [test_leftpane_corruption_handling.js]
 [test_PUIU_makeTransaction.js]
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -28,16 +28,35 @@ var gPrivacyPane = {
     let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "tracking-protection";
     link.setAttribute("href", url);
 
     document.getElementById("trackingprotectionbox").hidden = false;
   },
 #endif
 
   /**
+   * Initialize autocomplete to ensure prefs are in sync.
+   */
+  _initAutocomplete: function () {
+    let unifiedCompletePref = false;
+    try {
+      unifiedCompletePref =
+        Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
+    } catch (ex) {}
+
+    if (unifiedCompletePref) {
+      Components.classes["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"]
+                .getService(Components.interfaces.mozIPlacesAutoComplete);
+    } else {
+      Components.classes["@mozilla.org/autocomplete/search;1?name=history"]
+                .getService(Components.interfaces.mozIPlacesAutoComplete);
+    }
+  },
+
+  /**
    * Sets up the UI for the number of days of history to keep, and updates the
    * label of the "Clear Now..." button.
    */
   init: function ()
   {
     function setEventListener(aId, aEventType, aCallback)
     {
       document.getElementById(aId)
@@ -47,21 +66,18 @@ var gPrivacyPane = {
     this._updateSanitizeSettingsButton();
     this.initializeHistoryMode();
     this.updateHistoryModePane();
     this.updatePrivacyMicroControls();
     this.initAutoStartPrivateBrowsingReverter();
 #ifdef NIGHTLY_BUILD
     this._initTrackingProtection();
 #endif
+    this._initAutocomplete();
 
-    setEventListener("browser.urlbar.default.behavior", "change",
-      document.getElementById('browser.urlbar.autocomplete.enabled')
-              .updateElements
-    );
     setEventListener("privacy.sanitize.sanitizeOnShutdown", "change",
                      gPrivacyPane._updateSanitizeSettingsButton);
     setEventListener("browser.privatebrowsing.autostart", "change",
                      gPrivacyPane.updatePrivacyMicroControls);
     setEventListener("historyMode", "command", function () {
       gPrivacyPane.updateHistoryModePane();
       gPrivacyPane.updateHistoryModePrefs();
       gPrivacyPane.updatePrivacyMicroControls();
@@ -328,50 +344,26 @@ var gPrivacyPane = {
       mode.doCommand();
 
       this._shouldPromptForRestart = true;
   },
 
   // HISTORY
 
   /**
-   * Read the location bar enabled and suggestion prefs
-   * @return Int value for suggestion menulist
+   * Update browser.urlbar.autocomplete.enabled when a
+   * browser.urlbar.suggest.* pref is changed from the ui.
    */
-  readSuggestionPref: function PPP_readSuggestionPref()
-  {
-    let getVal = function(aPref)
-      document.getElementById("browser.urlbar." + aPref).value;
-
-    // Suggest nothing if autocomplete is not enabled
-    if (!getVal("autocomplete.enabled"))
-      return -1;
-
-    // Bottom 2 bits of default.behavior specify history/bookmark
-    return getVal("default.behavior") & 3;
-  },
-
-  /**
-   * Write the location bar enabled and suggestion prefs when necessary
-   * @return Bool value for enabled pref
-   */
-  writeSuggestionPref: function PPP_writeSuggestionPref()
-  {
-    let menuVal = document.getElementById("locationBarSuggestion").value;
-    let enabled = menuVal != -1;
-
-    // Only update default.behavior if we're giving suggestions
-    if (enabled) {
-      // Put the selected menu item's value directly into the bottom 2 bits
-      let behavior = document.getElementById("browser.urlbar.default.behavior");
-      behavior.value = behavior.value >> 2 << 2 | menuVal;
+  writeSuggestionPref: function () {
+    let getVal = (aPref) => {
+      return document.getElementById("browser.urlbar.suggest." + aPref).value;
     }
-
-    // Always update the enabled pref
-    return enabled;
+    // autocomplete.enabled is true if any of the suggestions is true
+    let enabled = ["history", "bookmark", "openpage"].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
--- a/browser/components/preferences/in-content/privacy.xul
+++ b/browser/components/preferences/in-content/privacy.xul
@@ -24,19 +24,25 @@
   <preference id="pref.privacy.disable_button.view_cookies"
               name="pref.privacy.disable_button.view_cookies"
               type="bool"/>
 
   <!-- Location Bar -->
   <preference id="browser.urlbar.autocomplete.enabled"
               name="browser.urlbar.autocomplete.enabled"
               type="bool"/>
-  <preference id="browser.urlbar.default.behavior"
-              name="browser.urlbar.default.behavior"
-              type="int"/>
+  <preference id="browser.urlbar.suggest.bookmark"
+              name="browser.urlbar.suggest.bookmark"
+              type="bool"/>
+  <preference id="browser.urlbar.suggest.history"
+              name="browser.urlbar.suggest.history"
+              type="bool"/>
+  <preference id="browser.urlbar.suggest.openpage"
+              name="browser.urlbar.suggest.openpage"
+              type="bool"/>
 
   <!-- History -->
   <preference id="places.history.enabled"
               name="places.history.enabled"
               type="bool"/>
   <preference id="browser.formfill.enable"
               name="browser.formfill.enable"
               type="bool"/>
@@ -226,28 +232,26 @@
           </hbox>
         </vbox>
       </vbox>
     </vbox>
   </deck>
 </groupbox>
 
 <!-- Location Bar -->
-<groupbox id="locationBarGroup" data-category="panePrivacy" hidden="true">
+<groupbox id="locationBarGroup"
+          data-category="panePrivacy"
+          hidden="true">
   <caption><label>&locationBar.label;</label></caption>
-  <hbox align="center">
-    <label id="locationBarSuggestionLabel"
-           control="locationBarSuggestion"
-           accesskey="&locbar.pre.accessKey;">&locbar.pre.label;</label>
-    <menulist id="locationBarSuggestion"
-              preference="browser.urlbar.autocomplete.enabled"
-              onsyncfrompreference="return gPrivacyPane.readSuggestionPref();"
-              onsynctopreference="return gPrivacyPane.writeSuggestionPref();">
-      <menupopup>
-        <menuitem label="&locbar.both.label;" value="0"/>
-        <menuitem label="&locbar.history.label;" value="1"/>
-        <menuitem label="&locbar.bookmarks.label;" value="2"/>
-        <menuitem label="&locbar.nothing.label;" value="-1"/>
-      </menupopup>
-    </menulist>
-    <label>&locbar.post.label;</label>
-  </hbox>
+  <label id="locationBarSuggestionLabel">&locbar.pre.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"/>
 </groupbox>
--- a/browser/components/preferences/in-content/tests/browser_privacypane_5.js
+++ b/browser/components/preferences/in-content/tests/browser_privacypane_5.js
@@ -8,18 +8,18 @@ function test() {
   let jar = getJar(rootDir);
   if (jar) {
     let tmpdir = extractJarToTmp(jar);
     rootDir = "file://" + tmpdir.path + '/';
   }
   loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
 
   run_test_subset([
-    test_locbar_suggestion_retention(-1, undefined),
-    test_locbar_suggestion_retention(1, -1),
-    test_locbar_suggestion_retention(2, 1),
-    test_locbar_suggestion_retention(0, 2),
-    test_locbar_suggestion_retention(0, 0),
+    test_locbar_suggestion_retention("history", true),
+    test_locbar_suggestion_retention("bookmark", 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
   ]);
-}
+}
\ No newline at end of file
--- a/browser/components/preferences/in-content/tests/privacypane_tests_perwindow.js
+++ b/browser/components/preferences/in-content/tests/privacypane_tests_perwindow.js
@@ -296,28 +296,24 @@ function test_custom_retention(controlTo
     case "menulist":
       controlToChange.value = valueIncrement;
       break;
     }
     controlChanged(controlToChange);
   };
 }
 
-function test_locbar_suggestion_retention(mode, expect) {
+function test_locbar_suggestion_retention(suggestion, autocomplete) {
   return function(win) {
-    let locbarsuggest = win.document.getElementById("locationBarSuggestion");
-    ok(locbarsuggest, "location bar suggestion menulist should exist");
+    let elem = win.document.getElementById(suggestion + "Suggestion");
+    ok(elem, "Suggest " + suggestion + " checkbox should exist.");
+    elem.click();
 
-    if (expect !== undefined) {
-      is(locbarsuggest.value, expect,
-        "location bar suggestion is expected to remain " + expect);
-    }
-
-    locbarsuggest.value = mode;
-    controlChanged(locbarsuggest);
+    is(Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled"), autocomplete,
+       "browser.urlbar.autocomplete.enabled pref should be " + autocomplete);
   };
 }
 
 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();
--- a/browser/components/preferences/privacy.js
+++ b/browser/components/preferences/privacy.js
@@ -31,29 +31,49 @@ var gPrivacyPane = {
     let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "tracking-protection";
     link.setAttribute("href", url);
 
     document.getElementById("trackingprotectionbox").hidden = false;
   },
 #endif
 
   /**
+   * Initialize autocomplete to ensure prefs are in sync.
+   */
+  _initAutocomplete: function () {
+    let unifiedCompletePref = false;
+    try {
+      unifiedCompletePref =
+        Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
+    } catch (ex) {}
+
+    if (unifiedCompletePref) {
+      Components.classes["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"]
+                .getService(Components.interfaces.mozIPlacesAutoComplete);
+    } else {
+      Components.classes["@mozilla.org/autocomplete/search;1?name=history"]
+                .getService(Components.interfaces.mozIPlacesAutoComplete);
+    }
+  },
+
+  /**
    * Sets up the UI for the number of days of history to keep, and updates the
    * label of the "Clear Now..." button.
    */
   init: function ()
   {
     this._updateSanitizeSettingsButton();
     this.initializeHistoryMode();
     this.updateHistoryModePane();
     this.updatePrivacyMicroControls();
     this.initAutoStartPrivateBrowsingReverter();
 #ifdef NIGHTLY_BUILD
     this._initTrackingProtection();
 #endif
+    this._initAutocomplete();
   },
 
   // HISTORY MODE
 
   /**
    * The list of preferences which affect the initial history mode settings.
    * If the auto start private browsing mode pref is active, the initial
    * history mode would be set to "Don't remember anything".
@@ -291,50 +311,26 @@ var gPrivacyPane = {
       mode.doCommand();
 
       this._shouldPromptForRestart = true;
   },
 
   // HISTORY
 
   /**
-   * Read the location bar enabled and suggestion prefs
-   * @return Int value for suggestion menulist
+   * Update browser.urlbar.autocomplete.enabled when a
+   * browser.urlbar.suggest.* pref is changed from the ui.
    */
-  readSuggestionPref: function PPP_readSuggestionPref()
-  {
-    let getVal = function(aPref)
-      document.getElementById("browser.urlbar." + aPref).value;
-
-    // Suggest nothing if autocomplete is not enabled
-    if (!getVal("autocomplete.enabled"))
-      return -1;
-
-    // Bottom 2 bits of default.behavior specify history/bookmark
-    return getVal("default.behavior") & 3;
-  },
-
-  /**
-   * Write the location bar enabled and suggestion prefs when necessary
-   * @return Bool value for enabled pref
-   */
-  writeSuggestionPref: function PPP_writeSuggestionPref()
-  {
-    let menuVal = document.getElementById("locationBarSuggestion").value;
-    let enabled = menuVal != -1;
-
-    // Only update default.behavior if we're giving suggestions
-    if (enabled) {
-      // Put the selected menu item's value directly into the bottom 2 bits
-      let behavior = document.getElementById("browser.urlbar.default.behavior");
-      behavior.value = behavior.value >> 2 << 2 | menuVal;
+  writeSuggestionPref: function PPP_writeSuggestionPref() {
+    let getVal = (aPref) => {
+      return document.getElementById("browser.urlbar.suggest." + aPref).value;
     }
-
-    // Always update the enabled pref
-    return enabled;
+    // autocomplete.enabled is true if any of the suggestions is true
+    let enabled = ["history", "bookmark", "openpage"].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
--- a/browser/components/preferences/privacy.xul
+++ b/browser/components/preferences/privacy.xul
@@ -37,20 +37,25 @@
       <preference id="pref.privacy.disable_button.view_cookies"
                   name="pref.privacy.disable_button.view_cookies"
                   type="bool"/>
 
       <!-- Location Bar -->
       <preference id="browser.urlbar.autocomplete.enabled"
                   name="browser.urlbar.autocomplete.enabled"
                   type="bool"/>
-      <preference id="browser.urlbar.default.behavior"
-                  name="browser.urlbar.default.behavior"
-                  type="int"
-                  onchange="document.getElementById('browser.urlbar.autocomplete.enabled').updateElements();"/>
+      <preference id="browser.urlbar.suggest.bookmark"
+                  name="browser.urlbar.suggest.bookmark"
+                  type="bool"/>
+      <preference id="browser.urlbar.suggest.history"
+                  name="browser.urlbar.suggest.history"
+                  type="bool"/>
+      <preference id="browser.urlbar.suggest.openpage"
+                  name="browser.urlbar.suggest.openpage"
+                  type="bool"/>
 
       <!-- History -->
       <preference id="places.history.enabled"
                   name="places.history.enabled"
                   type="bool"/>
       <preference id="browser.formfill.enable"
                   name="browser.formfill.enable"
                   type="bool"/>
@@ -249,30 +254,29 @@
       </deck>
 
     </groupbox>
 
     <!-- Location Bar -->
     <groupbox id="locationBarGroup">
       <caption label="&locationBar.label;"/>
 
-      <hbox align="center">
-        <label id="locationBarSuggestionLabel"
-               control="locationBarSuggestion"
-               accesskey="&locbar.pre.accessKey;">&locbar.pre.label;</label>
-        <menulist id="locationBarSuggestion"
-                  preference="browser.urlbar.autocomplete.enabled"
-                  onsyncfrompreference="return gPrivacyPane.readSuggestionPref();"
-                  onsynctopreference="return gPrivacyPane.writeSuggestionPref();">
-          <menupopup>
-            <menuitem label="&locbar.both.label;" value="0"/>
-            <menuitem label="&locbar.history.label;" value="1"/>
-            <menuitem label="&locbar.bookmarks.label;" value="2"/>
-            <menuitem label="&locbar.nothing.label;" value="-1"/>
-          </menupopup>
-        </menulist>
-        <label>&locbar.post.label;</label>
-      </hbox>
+      <label id="locationBarSuggestionLabel">&locbar.pre.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"/>
+      </vbox>
     </groupbox>
 
   </prefpane>
 
 </overlay>
--- a/browser/components/preferences/tests/browser.ini
+++ b/browser/components/preferences/tests/browser.ini
@@ -14,10 +14,9 @@ skip-if = e10s # Bug 941459 - pushPrefEn
 [browser_healthreport.js]
 skip-if = !healthreport || (os == 'linux' && debug)
 [browser_permissions.js]
 [browser_privacypane_1.js]
 [browser_privacypane_3.js]
 [browser_privacypane_4.js]
 skip-if = e10s # leaks windows
 [browser_privacypane_5.js]
-skip-if = e10s # leaks windows
 [browser_privacypane_8.js]
--- a/browser/components/preferences/tests/browser_privacypane_5.js
+++ b/browser/components/preferences/tests/browser_privacypane_5.js
@@ -1,26 +1,25 @@
-/* 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/. */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
                getService(Ci.mozIJSSubScriptLoader);
   let rootDir = getRootDirectory(gTestPath);
   let jar = getJar(rootDir);
   if (jar) {
     let tmpdir = extractJarToTmp(jar);
     rootDir = "file://" + tmpdir.path + '/';
   }
   loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
 
   run_test_subset([
-    test_locbar_suggestion_retention(-1, undefined),
-    test_locbar_suggestion_retention(1, -1),
-    test_locbar_suggestion_retention(2, 1),
-    test_locbar_suggestion_retention(0, 2),
-    test_locbar_suggestion_retention(0, 0),
+    test_locbar_suggestion_retention("history", true),
+    test_locbar_suggestion_retention("bookmark", 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
   ]);
-}
+}
\ No newline at end of file
--- a/browser/components/preferences/tests/privacypane_tests_perwindow.js
+++ b/browser/components/preferences/tests/privacypane_tests_perwindow.js
@@ -305,28 +305,24 @@ function test_custom_retention(controlTo
     case "menulist":
       controlToChange.value = valueIncrement;
       break;
     }
     controlChanged(controlToChange);
   };
 }
 
-function test_locbar_suggestion_retention(mode, expect) {
+function test_locbar_suggestion_retention(suggestion, autocomplete) {
   return function(win) {
-    let locbarsuggest = win.document.getElementById("locationBarSuggestion");
-    ok(locbarsuggest, "location bar suggestion menulist should exist");
+    let elem = win.document.getElementById(suggestion + "Suggestion");
+    ok(elem, "Suggest " + suggestion + " checkbox should exist.");
+    elem.click();
 
-    if (expect !== undefined) {
-      is(locbarsuggest.value, expect,
-        "location bar suggestion is expected to remain " + expect);
-    }
-
-    locbarsuggest.value = mode;
-    controlChanged(locbarsuggest);
+    is(Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled"), autocomplete,
+       "browser.urlbar.autocomplete.enabled pref should be " + autocomplete);
   };
 }
 
 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();
--- a/browser/locales/en-US/chrome/browser/preferences/privacy.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/privacy.dtd
@@ -11,22 +11,22 @@
 <!ENTITY trackingProtectionLearnMore.label "Learn more">
 <!ENTITY doNotTrackInfo.label           "Learn More">
 
 <!ENTITY  history.label                 "History">
 
 <!ENTITY  locationBar.label             "Location Bar">
 
 <!ENTITY  locbar.pre.label              "When using the location bar, suggest:">
-<!ENTITY  locbar.pre.accessKey          "u">
-<!ENTITY  locbar.post.label             "">
-<!ENTITY  locbar.both.label             "History and Bookmarks">
 <!ENTITY  locbar.history.label          "History">
+<!ENTITY  locbar.history.accesskey      "i">
 <!ENTITY  locbar.bookmarks.label        "Bookmarks">
-<!ENTITY  locbar.nothing.label          "Nothing">
+<!ENTITY  locbar.bookmarks.accesskey    "d">
+<!ENTITY  locbar.openpage.label         "Open tabs">
+<!ENTITY  locbar.openpage.accesskey     "g">
 
 <!ENTITY  acceptCookies.label           "Accept cookies from sites">
 <!ENTITY  acceptCookies.accesskey       "A">
 
 <!ENTITY  acceptThirdParty.pre.label      "Accept third-party cookies:">
 <!ENTITY  acceptThirdParty.pre.accesskey  "c">
 <!ENTITY  acceptThirdParty.always.label   "Always">
 <!ENTITY  acceptThirdParty.never.label    "Never">
--- a/browser/metro/profile/metro.js
+++ b/browser/metro/profile/metro.js
@@ -300,24 +300,31 @@ pref("browser.search.noCurrentEngine", t
 #ifdef MOZ_OFFICIAL_BRANDING
 // {moz:official} expands to "official"
 pref("browser.search.official", true);
 #endif
 
 // enable xul error pages
 pref("browser.xul.error_pages.enabled", true);
 
-// Specify emptyRestriction = 0 so that bookmarks appear in the list by default
-pref("browser.urlbar.default.behavior", 0);
-pref("browser.urlbar.default.behavior.emptyRestriction", 0);
-
 // Let the faviconservice know that we display favicons as 25x25px so that it
 // uses the right size when optimizing favicons
 pref("places.favicons.optimizeToDimension", 25);
 
+// The default behavior for the urlbar can be configured to use any combination
+// of the match filters with each additional filter adding more results (union).
+pref("browser.urlbar.suggest.history",              true);
+pref("browser.urlbar.suggest.bookmark",             true);
+pref("browser.urlbar.suggest.openpage",             true);
+pref("browser.urlbar.suggest.search",               true);
+
+// Restrictions to current suggestions can also be applied (intersection).
+// Typed suggestion works only if history is set to true.
+pref("browser.urlbar.suggest.history.onlyTyped",    false);
+
 // various and sundry awesomebar prefs (should remove/re-evaluate
 // these once bug 447900 is fixed)
 pref("browser.urlbar.trimURLs", true);
 pref("browser.urlbar.formatting.enabled", true);
 pref("browser.urlbar.clickSelectsAll", true);
 pref("browser.urlbar.doubleClickSelectsAll", true);
 pref("browser.urlbar.autoFill", false);
 pref("browser.urlbar.matchOnlyTyped", false);
--- a/toolkit/components/places/SQLFunctions.cpp
+++ b/toolkit/components/places/SQLFunctions.cpp
@@ -354,26 +354,35 @@ namespace places {
     }
 
     int32_t visitCount = aArguments->AsInt32(kArgIndexVisitCount);
     bool typed = aArguments->AsInt32(kArgIndexTyped) ? true : false;
     bool bookmark = aArguments->AsInt32(kArgIndexBookmark) ? true : false;
     nsAutoCString tags;
     (void)aArguments->GetUTF8String(kArgIndexTags, tags);
     int32_t openPageCount = aArguments->AsInt32(kArgIndexOpenPageCount);
+    bool matches = false;
+    if (HAS_BEHAVIOR(RESTRICT)) {
+      // Make sure we match all the filter requirements.  If a given restriction
+      // is active, make sure the corresponding condition is not true.
+      matches = (!HAS_BEHAVIOR(HISTORY) || visitCount > 0) &&
+                (!HAS_BEHAVIOR(TYPED) || typed) &&
+                (!HAS_BEHAVIOR(BOOKMARK) || bookmark) &&
+                (!HAS_BEHAVIOR(TAG) || !tags.IsVoid()) &&
+                (!HAS_BEHAVIOR(OPENPAGE) || openPageCount > 0);
+    } else {
+      // Make sure that we match all the filter requirements and that the
+      // corresponding condition is true if at least a given restriction is active.
+      matches = (HAS_BEHAVIOR(HISTORY) && visitCount > 0) ||
+                (HAS_BEHAVIOR(TYPED) && typed) ||
+                (HAS_BEHAVIOR(BOOKMARK) && bookmark) ||
+                (HAS_BEHAVIOR(TAG) && !tags.IsVoid()) ||
+                (HAS_BEHAVIOR(OPENPAGE) && openPageCount > 0);
+    }
 
-    // Make sure we match all the filter requirements.  If a given restriction
-    // is active, make sure the corresponding condition is not true.
-    bool matches = !(
-      (HAS_BEHAVIOR(HISTORY) && visitCount == 0) ||
-      (HAS_BEHAVIOR(TYPED) && !typed) ||
-      (HAS_BEHAVIOR(BOOKMARK) && !bookmark) ||
-      (HAS_BEHAVIOR(TAG) && tags.IsVoid()) ||
-      (HAS_BEHAVIOR(OPENPAGE) && openPageCount == 0)
-    );
     if (!matches) {
       NS_ADDREF(*_result = new IntegerVariant(0));
       return NS_OK;
     }
 
     // Obtain our search function.
     searchFunctionPtr searchFunction = getSearchFunction(matchBehavior);
 
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -6,43 +6,40 @@
 
 "use strict";
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Constants
 
 const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
 
-const TOPIC_PREFCHANGED = "nsPref:changed";
-
-const DEFAULT_BEHAVIOR = 0;
-
 const PREF_BRANCH = "browser.urlbar.";
 
 // Prefs are defined as [pref name, default value].
 const PREF_ENABLED =                [ "autocomplete.enabled",   true ];
 const PREF_AUTOFILL =               [ "autoFill",               true ];
 const PREF_AUTOFILL_TYPED =         [ "autoFill.typed",         true ];
 const PREF_AUTOFILL_SEARCHENGINES = [ "autoFill.searchEngines", true ];
 const PREF_DELAY =                  [ "delay",                  50 ];
 const PREF_BEHAVIOR =               [ "matchBehavior", MATCH_BOUNDARY_ANYWHERE ];
-const PREF_DEFAULT_BEHAVIOR =       [ "default.behavior", DEFAULT_BEHAVIOR ];
-const PREF_EMPTY_BEHAVIOR =         [ "default.behavior.emptyRestriction",
-                                      Ci.mozIPlacesAutoComplete.BEHAVIOR_HISTORY |
-                                      Ci.mozIPlacesAutoComplete.BEHAVIOR_TYPED ];
 const PREF_FILTER_JS =              [ "filter.javascript",      true ];
 const PREF_MAXRESULTS =             [ "maxRichResults",         25 ];
 const PREF_RESTRICT_HISTORY =       [ "restrict.history",       "^" ];
 const PREF_RESTRICT_BOOKMARKS =     [ "restrict.bookmark",      "*" ];
 const PREF_RESTRICT_TYPED =         [ "restrict.typed",         "~" ];
 const PREF_RESTRICT_TAG =           [ "restrict.tag",           "+" ];
 const PREF_RESTRICT_SWITCHTAB =     [ "restrict.openpage",      "%" ];
 const PREF_MATCH_TITLE =            [ "match.title",            "#" ];
 const PREF_MATCH_URL =              [ "match.url",              "@" ];
 
+const PREF_SUGGEST_HISTORY =        [ "suggest.history",        true ];
+const PREF_SUGGEST_BOOKMARK =       [ "suggest.bookmark",       true ];
+const PREF_SUGGEST_OPENPAGE =       [ "suggest.openpage",       true ];
+const PREF_SUGGEST_HISTORY_ONLYTYPED = [ "suggest.history.onlyTyped", false ];
+
 // Match type constants.
 // These indicate what type of search function we should be using.
 const MATCH_ANYWHERE = Ci.mozIPlacesAutoComplete.MATCH_ANYWHERE;
 const MATCH_BOUNDARY_ANYWHERE = Ci.mozIPlacesAutoComplete.MATCH_BOUNDARY_ANYWHERE;
 const MATCH_BOUNDARY = Ci.mozIPlacesAutoComplete.MATCH_BOUNDARY;
 const MATCH_BEGINNING = Ci.mozIPlacesAutoComplete.MATCH_BEGINNING;
 const MATCH_BEGINNING_CASE_SENSITIVE = Ci.mozIPlacesAutoComplete.MATCH_BEGINNING_CASE_SENSITIVE;
 
@@ -113,29 +110,16 @@ function defaultQuery(conditions = "") {
                               bookmarked, t.open_count,
                               :matchBehavior, :searchBehavior)
        ${conditions}
      ORDER BY h.frecency DESC, h.id DESC
      LIMIT :maxResults`;
   return query;
 }
 
-const SQL_DEFAULT_QUERY = defaultQuery();
-
-// Enforce ignoring the visit_count index, since the frecency one is much
-// faster in this case.  ANALYZE helps the query planner to figure out the
-// faster path, but it may not have up-to-date information yet.
-const SQL_HISTORY_QUERY = defaultQuery("AND +h.visit_count > 0");
-
-const SQL_BOOKMARK_QUERY = defaultQuery("AND bookmarked");
-
-const SQL_TAGS_QUERY = defaultQuery("AND tags NOTNULL");
-
-const SQL_TYPED_QUERY = defaultQuery("AND h.typed = 1");
-
 const SQL_SWITCHTAB_QUERY =
   `SELECT :query_type, t.url, t.url, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
           t.open_count, NULL
    FROM moz_openpages_temp t
    LEFT JOIN moz_places h ON h.url = t.url
    WHERE h.id IS NULL
      AND AUTOCOMPLETE_MATCH(:searchString, t.url, t.url, NULL,
                             NULL, NULL, NULL, t.open_count,
@@ -232,31 +216,31 @@ function urlQuery(conditions = "") {
     `/* do not warn (bug no): cannot use an index */
      SELECT :query_type, h.url, NULL,
             NULL, foreign_count > 0 AS bookmarked, NULL, NULL, NULL, NULL, NULL, NULL, h.frecency
      FROM moz_places h
      WHERE h.frecency <> 0
      ${conditions}
      AND AUTOCOMPLETE_MATCH(:searchString, h.url,
      h.title, '',
-     h.visit_count, h.typed, 0, 0,
+     h.visit_count, h.typed, bookmarked, 0,
      :matchBehavior, :searchBehavior)
      ORDER BY h.frecency DESC, h.id DESC
      LIMIT 1`;
   return query;
 }
 
 const SQL_URL_QUERY = urlQuery();
 
-const SQL_TYPED_URL_QUERY = urlQuery("AND typed = 1");
+const SQL_TYPED_URL_QUERY = urlQuery("AND h.typed = 1");
 
 // TODO (bug 1045924): use foreign_count once available.
 const SQL_BOOKMARKED_URL_QUERY = urlQuery("AND bookmarked");
 
-const SQL_BOOKMARKED_TYPED_URL_QUERY = urlQuery("AND bookmarked AND typed = 1");
+const SQL_BOOKMARKED_TYPED_URL_QUERY = urlQuery("AND bookmarked AND h.typed = 1");
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Getters
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
@@ -360,37 +344,90 @@ 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"];
 
-  function loadPrefs() {
+  function syncEnabledPref(init = false) {
+    let suggestPrefs = [PREF_SUGGEST_HISTORY, PREF_SUGGEST_BOOKMARK, PREF_SUGGEST_OPENPAGE];
+
+    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);
+    }
+
+    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 loadPrefs(subject, topic, data) {
     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.delay = prefs.get(...PREF_DELAY);
     store.matchBehavior = prefs.get(...PREF_BEHAVIOR);
     store.filterJavaScript = prefs.get(...PREF_FILTER_JS);
     store.maxRichResults = prefs.get(...PREF_MAXRESULTS);
     store.restrictHistoryToken = prefs.get(...PREF_RESTRICT_HISTORY);
     store.restrictBookmarkToken = prefs.get(...PREF_RESTRICT_BOOKMARKS);
     store.restrictTypedToken = prefs.get(...PREF_RESTRICT_TYPED);
     store.restrictTagToken = prefs.get(...PREF_RESTRICT_TAG);
     store.restrictOpenPageToken = prefs.get(...PREF_RESTRICT_SWITCHTAB);
     store.matchTitleToken = prefs.get(...PREF_MATCH_TITLE);
     store.matchURLToken = prefs.get(...PREF_MATCH_URL);
-    store.defaultBehavior = prefs.get(...PREF_DEFAULT_BEHAVIOR);
+    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);
+
+    // If history is not set, onlyTyped value should be ignored.
+    if (!store.suggestHistory) {
+      store.suggestTyped = false;
+    }
+    store.defaultBehavior = types.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 "").
-    store.emptySearchDefaultBehavior = store.defaultBehavior |
-                                       prefs.get(...PREF_EMPTY_BEHAVIOR);
+    // 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,
+    // it defaults to open pages.
+    store.emptySearchDefaultBehavior = Ci.mozIPlacesAutoComplete.BEHAVIOR_RESTRICT;
+    if (store.suggestHistory) {
+      store.emptySearchDefaultBehavior |= Ci.mozIPlacesAutoComplete.BEHAVIOR_HISTORY |
+                                          Ci.mozIPlacesAutoComplete.BEHAVIOR_TYPED;
+    } else if (store.suggestBookmark) {
+      store.emptySearchDefaultBehavior |= Ci.mozIPlacesAutoComplete.BEHAVIOR_BOOKMARK;
+    } else {
+      store.emptySearchDefaultBehavior |= Ci.mozIPlacesAutoComplete.BEHAVIOR_OPENPAGE;
+    }
 
     // Validate matchBehavior; default to MATCH_BOUNDARY_ANYWHERE.
     if (store.matchBehavior != MATCH_ANYWHERE &&
         store.matchBehavior != MATCH_BOUNDARY &&
         store.matchBehavior != MATCH_BEGINNING) {
       store.matchBehavior = MATCH_BOUNDARY_ANYWHERE;
     }
 
@@ -398,24 +435,32 @@ XPCOMUtils.defineLazyGetter(this, "Prefs
       [ store.restrictHistoryToken, "history" ],
       [ store.restrictBookmarkToken, "bookmark" ],
       [ store.restrictTagToken, "tag" ],
       [ store.restrictOpenPageToken, "openpage" ],
       [ store.matchTitleToken, "title" ],
       [ store.matchURLToken, "url" ],
       [ store.restrictTypedToken, "typed" ]
     ]);
+
+    // Synchronize suggest.* prefs with autocomplete.enabled every time
+    // autocomplete.enabled is changed.
+    if (data == PREF_BRANCH + PREF_ENABLED[0]) {
+      syncEnabledPref();
+    }
   }
 
   let store = {
-    observe: function (subject, topic, data) {
-      loadPrefs();
-    },
+    observe: loadPrefs,
     QueryInterface: XPCOMUtils.generateQI([ Ci.nsIObserver ])
   };
+
+  // Synchronize suggest.* prefs with autocomplete.enabled at initialization
+  syncEnabledPref(true);
+
   loadPrefs();
   prefs.observe("", store);
 
   return Object.seal(store);
 });
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Helper functions
@@ -560,18 +605,24 @@ function Search(searchString, searchPara
 Search.prototype = {
   /**
    * Enables the desired AutoComplete behavior.
    *
    * @param type
    *        The behavior type to set.
    */
   setBehavior: function (type) {
+    type = type.toUpperCase();
     this._behavior |=
-      Ci.mozIPlacesAutoComplete["BEHAVIOR_" + type.toUpperCase()];
+      Ci.mozIPlacesAutoComplete["BEHAVIOR_" + type];
+
+    // Setting the "typed" behavior should also set the "history" behavior.
+    if (type == "TYPED") {
+      this.setBehavior("history");
+    }
   },
 
   /**
    * Determines if the specified AutoComplete behavior is set.
    *
    * @param aType
    *        The behavior type to test for.
    * @return true if the behavior is set, false otherwise.
@@ -601,22 +652,31 @@ Search.prototype = {
    * Given an array of tokens, this function determines which query should be
    * ran.  It also removes any special search tokens.
    *
    * @param tokens
    *        An array of search tokens.
    * @return the filtered list of tokens to search with.
    */
   filterTokens: function (tokens) {
+    let foundToken = false;
     // Set the proper behavior while filtering tokens.
     for (let i = tokens.length - 1; i >= 0; i--) {
       let behavior = Prefs.tokenToBehaviorMap.get(tokens[i]);
       // Don't remove the token if it didn't match, or if it's an action but
       // actions are not enabled.
       if (behavior && (behavior != "openpage" || this._enableActions)) {
+        // Don't use the suggest preferences if it is a token search and
+        // set the restrict bit to 1 (to intersect the search results).
+        if (!foundToken) {
+          foundToken = true;
+          // Do not take into account previous behavior (e.g.: history, bookmark)
+          this._behavior = 0;
+          this.setBehavior("restrict");
+        }
         this.setBehavior(behavior);
         tokens.splice(i, 1);
       }
     }
 
     // Set the right JavaScript behavior based on our preference.  Note that the
     // preference is whether or not we should filter JavaScript, and the
     // behavior is if we should search it or not.
@@ -684,19 +744,24 @@ Search.prototype = {
     // enabled, the first result is always a special result (resulting from one
     // of the queries between (1) and (6) inclusive). As such, the UI is
     // expected to auto-select the first result when actions are enabled. If the
     // first result is an inline completion result, that will also be the
     // default result and therefore be autofilled (this also happens if actions
     // are not enabled).
 
     // Get the final query, based on the tokens found in the search string.
-    let queries = [ this._adaptiveQuery,
-                    this._switchToTabQuery,
-                    this._searchQuery ];
+    let queries = [ this._adaptiveQuery ];
+
+    // "openpage" behavior is supported by the default query.
+    // _switchToTabQuery instead returns only pages not supported by history.
+    if (this.hasBehavior("openpage")) {
+      queries.push(this._switchToTabQuery);
+    }
+    queries.push(this._searchQuery);
 
     // When actions are enabled, we run a series of heuristics to determine what
     // the first result should be - which is always a special result.
     // |hasFirstResult| is used to keep track of whether we've obtained such a
     // result yet, so we can skip further heuristics and not add any additional
     // special results.
     let hasFirstResult = false;
 
@@ -1153,17 +1218,17 @@ Search.prototype = {
       row.getResultByIndex(QUERYINDEX_BOOKMARKTITLE) : null;
     let tags = row.getResultByIndex(QUERYINDEX_TAGS) || "";
     let frecency = row.getResultByIndex(QUERYINDEX_FRECENCY);
 
     // If actions are enabled and the page is open, add only the switch-to-tab
     // result.  Otherwise, add the normal result.
     let url = escapedURL;
     let action = null;
-    if (this._enableActions && openPageCount > 0) {
+    if (this._enableActions && openPageCount > 0 && this.hasBehavior("openpage")) {
       url = makeActionURL("switchtab", {url: escapedURL});
       action = "switchtab";
     }
 
     // Always prefer the bookmark title unless it is empty
     let title = bookmarkTitle || historyTitle;
 
     if (queryType == QUERYTYPE_KEYWORD) {
@@ -1186,20 +1251,20 @@ Search.prototype = {
           title = historyTitle;
         }
       }
     }
 
     // We will always prefer to show tags if we have them.
     let showTags = !!tags;
 
-    // However, we'll act as if a page is not bookmarked or tagged if the user
-    // only wants only history and not bookmarks or tags.
-    if (this.hasBehavior("history") &&
-        !(this.hasBehavior("bookmark") || this.hasBehavior("tag"))) {
+    // However, we'll act as if a page is not bookmarked if the user wants
+    // only history and not bookmarks and there are no tags.
+    if (this.hasBehavior("history") && !this.hasBehavior("bookmark") &&
+        !showTags) {
       showTags = false;
       match.style = "favicon";
     }
 
     // If we have tags and should show them, we need to add them to the title.
     if (showTags) {
       title += TITLE_TAGS_SEPARATOR + tags;
     }
@@ -1229,34 +1294,55 @@ Search.prototype = {
                               .getFaviconLinkForIcon(NetUtil.newURI(iconurl)).spec;
     }
     match.frecency = frecency;
 
     return match;
   },
 
   /**
+   * @return a string consisting of the search query to be used based on the
+   * previously set urlbar suggestion preferences.
+   */
+  get _suggestionPrefQuery() {
+    if (!this.hasBehavior("restrict") && this.hasBehavior("history") &&
+        this.hasBehavior("bookmark")) {
+      return this.hasBehavior("typed") ? defaultQuery("AND h.typed = 1")
+                                       : defaultQuery();
+    }
+    let conditions = [];
+    if (this.hasBehavior("history")) {
+      // Enforce ignoring the visit_count index, since the frecency one is much
+      // faster in this case.  ANALYZE helps the query planner to figure out the
+      // faster path, but it may not have up-to-date information yet.
+      conditions.push("+h.visit_count > 0");
+    }
+    if (this.hasBehavior("typed")) {
+      conditions.push("h.typed = 1");
+    }
+    if (this.hasBehavior("bookmark")) {
+      conditions.push("bookmarked");
+    }
+    if (this.hasBehavior("tag")) {
+      conditions.push("tags NOTNULL");
+    }
+
+    return conditions.length ? defaultQuery("AND " + conditions.join(" AND "))
+                             : defaultQuery();
+  },
+
+  /**
    * Obtains the search query to be used based on the previously set search
-   * behaviors (accessed by this.hasBehavior).
+   * preferences (accessed by this.hasBehavior).
    *
    * @return an array consisting of the correctly optimized query to search the
    *         database with and an object containing the params to bound.
    */
   get _searchQuery() {
-    // We use more optimized queries for restricted searches, so we will always
-    // return the most restrictive one to the least restrictive one if more than
-    // one token is found.
-    // Note: "openpages" behavior is supported by the default query.
-    //       _switchToTabQuery instead returns only pages not supported by
-    //       history and it is always executed.
-    let query = this.hasBehavior("tag") ? SQL_TAGS_QUERY :
-                this.hasBehavior("bookmark") ? SQL_BOOKMARK_QUERY :
-                this.hasBehavior("typed") ? SQL_TYPED_QUERY :
-                this.hasBehavior("history") ? SQL_HISTORY_QUERY :
-                SQL_DEFAULT_QUERY;
+    let query = this._suggestionPrefQuery;
 
     return [
       query,
       {
         parent: PlacesUtils.tagsFolderId,
         query_type: QUERYTYPE_FILTERED,
         matchBehavior: this._matchBehavior,
         searchBehavior: this._behavior,
@@ -1343,31 +1429,24 @@ Search.prototype = {
   get _shouldAutofill() {
     // First of all, check for the autoFill pref.
     if (!Prefs.autofill)
       return false;
 
     if (!this._searchTokens.length == 1)
       return false;
 
-    // Then, we should not try to autofill if the behavior is not the default.
-    // TODO (bug 751709): Ideally we should have a more fine-grained behavior
-    // here, but for now it's enough to just check for default behavior.
-    if (Prefs.defaultBehavior != DEFAULT_BEHAVIOR) {
-      // autoFill can only cope with history or bookmarks entries
-      // (typed or not).
-      if (!this.hasBehavior("typed") &&
-          !this.hasBehavior("history") &&
-          !this.hasBehavior("bookmark"))
-        return false;
+    // autoFill can only cope with history or bookmarks entries.
+    if (!this.hasBehavior("history") &&
+        !this.hasBehavior("bookmark"))
+      return false;
 
-      // autoFill doesn't search titles or tags.
-      if (this.hasBehavior("title") || this.hasBehavior("tags"))
-        return false;
-    }
+    // autoFill doesn't search titles or tags.
+    if (this.hasBehavior("title") || this.hasBehavior("tag"))
+      return false;
 
     // Don't try to autofill if the search term includes any whitespace.
     // This may confuse completeDefaultIndex cause the AUTOCOMPLETE_MATCH
     // tokenizer ends up trimming the search string and returning a value
     // that doesn't match it, or is even shorter.
     if (/\s/.test(this._originalSearchString))
       return false;
 
@@ -1380,17 +1459,17 @@ Search.prototype = {
   /**
    * Obtains the query to search for autoFill host results.
    *
    * @return an array consisting of the correctly optimized query to search the
    *         database with and an object containing the params to bound.
    */
   get _hostQuery() {
     let typed = Prefs.autofillTyped || this.hasBehavior("typed");
-    let bookmarked =  this.hasBehavior("bookmark");
+    let bookmarked = this.hasBehavior("bookmark") && !this.hasBehavior("history");
 
     return [
       bookmarked ? typed ? SQL_BOOKMARKED_TYPED_HOST_QUERY
                          : SQL_BOOKMARKED_HOST_QUERY
                  : typed ? SQL_TYPED_HOST_QUERY
                          : SQL_HOST_QUERY,
       {
         query_type: QUERYTYPE_AUTOFILL_HOST,
@@ -1425,28 +1504,42 @@ Search.prototype = {
   /**
    * Obtains the query to search for autoFill url results.
    *
    * @return an array consisting of the correctly optimized query to search the
    *         database with and an object containing the params to bound.
    */
   get _urlQuery()  {
     let typed = Prefs.autofillTyped || this.hasBehavior("typed");
-    let bookmarked =  this.hasBehavior("bookmark");
+    let bookmarked = this.hasBehavior("bookmark") && !this.hasBehavior("history");
+    let searchBehavior = Ci.mozIPlacesAutoComplete.BEHAVIOR_URL;
+
+    // Enable searches in typed history if autofillTyped pref or typed behavior
+    // is true.
+    if (typed) {
+      searchBehavior |= Ci.mozIPlacesAutoComplete.BEHAVIOR_HISTORY |
+                        Ci.mozIPlacesAutoComplete.BEHAVIOR_TYPED;
+    } else {
+      // Search in entire history.
+      searchBehavior |= Ci.mozIPlacesAutoComplete.BEHAVIOR_HISTORY;
+    }
+    if (bookmarked) {
+      searchBehavior |= Ci.mozIPlacesAutoComplete.BEHAVIOR_BOOKMARK;
+    }
 
     return [
       bookmarked ? typed ? SQL_BOOKMARKED_TYPED_URL_QUERY
                          : SQL_BOOKMARKED_URL_QUERY
                  : typed ? SQL_TYPED_URL_QUERY
                          : SQL_URL_QUERY,
       {
         query_type: QUERYTYPE_AUTOFILL_URL,
         searchString: this._autofillUrlSearchString,
         matchBehavior: MATCH_BEGINNING_CASE_SENSITIVE,
-        searchBehavior: Ci.mozIPlacesAutoComplete.BEHAVIOR_URL
+        searchBehavior: searchBehavior
       }
     ];
   },
 
  /**
    * Notifies the listener about results.
    *
    * @param searchOngoing
@@ -1463,16 +1556,21 @@ Search.prototype = {
   },
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// UnifiedComplete class
 //// component @mozilla.org/autocomplete/search;1?name=unifiedcomplete
 
 function UnifiedComplete() {
+  // Make sure the preferences are initialized as soon as possible.
+  // If the value of browser.urlbar.autocomplete.enabled is set to false,
+  // then all the other suggest preferences for history, bookmarks and
+  // open pages should be set to false.
+  Prefs;
 }
 
 UnifiedComplete.prototype = {
   //////////////////////////////////////////////////////////////////////////////
   //// Database handling
 
   /**
    * Promise resolved when the database initialization has completed, or null
--- a/toolkit/components/places/mozIPlacesAutoComplete.idl
+++ b/toolkit/components/places/mozIPlacesAutoComplete.idl
@@ -8,17 +8,17 @@
 
 interface nsIURI;
 
 /**
  * This interface provides some constants used by the Places AutoComplete
  * search provider as well as methods to track opened pages for AutoComplete
  * purposes.
  */
-[scriptable, uuid(3bf895a0-d6d9-4ba7-b8db-f2f0e0f32d23)]
+[scriptable, uuid(6e252399-77f9-4f11-98cc-6fa9fab96f92)]
 interface mozIPlacesAutoComplete : nsISupports
 {
   //////////////////////////////////////////////////////////////////////////////
   //// Matching Constants
 
   /**
    * Match anywhere in each searchable term.
    */
@@ -92,16 +92,22 @@ interface mozIPlacesAutoComplete : nsISu
 
   /**
    * Search for pages that have been marked as being opened, such as a tab
    * in a tabbrowser.
    */
   const long BEHAVIOR_OPENPAGE = 1 << 7;
 
   /**
+   * Use intersection between history, typed, bookmark, tag and openpage
+   * instead of union, when the restrict bit is set.
+   */
+  const long BEHAVIOR_RESTRICT = 1 << 8;
+
+  /**
    * Mark a page as being currently open.
    *
    * @note Pages will not be automatically unregistered when Private Browsing
    *       mode is entered or exited.  Therefore, consumers MUST unregister or
    *       register themselves.
    *
    * @param aURI
    *        The URI to register as an open page.
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -3268,23 +3268,27 @@ nsNavHistory::QueryToSelectClause(nsNavH
     // end time
     if (NS_SUCCEEDED(aQuery->GetHasEndTime(&hasIt)) && hasIt)
       clause.Condition("visit_date <=").Param(":end_time");
     clause.Str(" LIMIT 1)");
   }
 
   // search terms
   bool hasSearchTerms;
+  int32_t searchBehavior = mozIPlacesAutoComplete::BEHAVIOR_HISTORY |
+                           mozIPlacesAutoComplete::BEHAVIOR_BOOKMARK;
   if (NS_SUCCEEDED(aQuery->GetHasSearchTerms(&hasSearchTerms)) && hasSearchTerms) {
-    // Re-use the autocomplete_match function.  Setting the behavior to 0
-    // it can match everything and work as a nice case insensitive comparator.
+    // Re-use the autocomplete_match function.  Setting the behavior to match
+    // history or typed history or bookmarks or open pages will match almost
+    // everything.
     clause.Condition("AUTOCOMPLETE_MATCH(").Param(":search_string")
           .Str(", h.url, page_title, tags, ")
-          .Str(nsPrintfCString("0, 0, 0, 0, %d, 0)",
-                               mozIPlacesAutoComplete::MATCH_ANYWHERE_UNMODIFIED).get());
+          .Str(nsPrintfCString("1, 1, 1, 1, %d, %d)",
+                               mozIPlacesAutoComplete::MATCH_ANYWHERE_UNMODIFIED,
+                               searchBehavior).get());
     // Serching by terms implicitly exclude queries.
     excludeQueries = true;
   }
 
   // min and max visit count
   if (aQuery->MinVisits() >= 0)
     clause.Condition("h.visit_count >=").Param(":min_visits");
 
--- a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
+++ b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
@@ -23,16 +23,19 @@ function run_test() {
   run_next_test();
 }
 
 function* cleanup() {
   Services.prefs.clearUserPref("browser.urlbar.autocomplete.enabled");
   Services.prefs.clearUserPref("browser.urlbar.autoFill");
   Services.prefs.clearUserPref("browser.urlbar.autoFill.typed");
   Services.prefs.clearUserPref("browser.urlbar.autoFill.searchEngines");
+  for (let type of ["history", "bookmark", "history.onlyTyped", "openpage"]) {
+    Services.prefs.clearUserPref("browser.urlbar.suggest." + type);
+  }
   remove_all_bookmarks();
   yield promiseClearHistory();
 }
 do_register_cleanup(cleanup);
 
 /**
  * @param aSearches
  *        Array of AutoCompleteSearch names.
--- a/toolkit/components/places/tests/unifiedcomplete/test_autoFill_default_behavior.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_autoFill_default_behavior.js
@@ -6,27 +6,31 @@
  * Test autoFill for different default behaviors.
  */
 
 add_task(function* test_default_behavior_host() {
   let uri1 = NetUtil.newURI("http://typed/");
   let uri2 = NetUtil.newURI("http://visited/");
   let uri3 = NetUtil.newURI("http://bookmarked/");
   let uri4 = NetUtil.newURI("http://tpbk/");
+  let uri5 = NetUtil.newURI("http://tagged/");
 
   yield promiseAddVisits([
     { uri: uri1, title: "typed", transition: TRANSITION_TYPED },
     { uri: uri2, title: "visited" },
     { uri: uri4, title: "tpbk", transition: TRANSITION_TYPED },
   ]);
   addBookmark( { uri: uri3, title: "bookmarked" } );
   addBookmark( { uri: uri4, title: "tpbk" } );
+  addBookmark( { uri: uri5, title: "title", tags: ["foo"] } );
 
   // RESTRICT TO HISTORY.
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 1);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history.onlyTyped", false);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", false);
 
   do_log_info("Restrict history, common visit, should not autoFill");
   yield check_autocomplete({
     search: "vi",
     matches: [ { uri: uri2, title: "visited" } ],
     autofilled: "vi",
     completed: "vi"
   });
@@ -75,17 +79,17 @@ add_task(function* test_default_behavior
     search: "vi",
     matches: [ { uri: uri2, title: "visited", style: [ "autofill" ] } ],
     autofilled: "visited/",
     completed: "visited/"
   });
 
   // RESTRICT TO TYPED.
   // This should basically ignore autoFill.typed and acts as if it would be set.
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 32);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history.onlyTyped", true);
 
   // Typed behavior basically acts like history, but filters on typed.
   do_log_info("Restrict typed, common visit, autoFill.typed = false, should not autoFill");
   yield check_autocomplete({
     search: "vi",
     matches: [ ],
     autofilled: "vi",
     completed: "vi"
@@ -111,17 +115,18 @@ add_task(function* test_default_behavior
   yield check_autocomplete({
     search: "tp",
     matches: [ { uri: uri4, title: "tpbk", style: [ "autofill" ] } ],
     autofilled: "tpbk/",
     completed: "tpbk/"
   });
 
   // RESTRICT BOOKMARKS.
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 2);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", false);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
   Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", true);
 
   do_log_info("Restrict bookmarks, common visit, should not autoFill");
   yield check_autocomplete({
     search: "vi",
     matches: [ ],
     autofilled: "vi",
     completed: "vi"
@@ -158,16 +163,34 @@ add_task(function* test_default_behavior
   do_log_info("Restrict bookmarks, bookmark, autofill.typed = false, should autoFill");
   yield check_autocomplete({
     search: "bo",
     matches: [ { uri: uri3, title: "bookmarked", style: [ "autofill" ] } ],
     autofilled: "bookmarked/",
     completed: "bookmarked/"
   });
 
+  // Don't autofill because it's a title.
+  do_log_info("Restrict bookmarks, title, autofill.typed = false, should not autoFill");
+  yield check_autocomplete({
+    search: "# ta",
+    matches: [ ],
+    autofilled: "# ta",
+    completed: "# ta"
+  });
+
+  // Don't autofill because it's a tag.
+  do_log_info("Restrict bookmarks, tag, autofill.typed = false, should not autoFill");
+  yield check_autocomplete({
+    search: "+ ta",
+    matches: [ { uri: uri5, title: "title", tags: [ "foo" ], style: [ "tag" ] } ],
+    autofilled: "+ ta",
+    completed: "+ ta"
+  });
+
   yield cleanup();
 });
 
 add_task(function* test_default_behavior_url() {
   let uri1 = NetUtil.newURI("http://typed/ty/");
   let uri2 = NetUtil.newURI("http://visited/vi/");
   let uri3 = NetUtil.newURI("http://bookmarked/bo/");
   let uri4 = NetUtil.newURI("http://tpbk/tp/");
@@ -176,17 +199,19 @@ add_task(function* test_default_behavior
     { uri: uri1, title: "typed", transition: TRANSITION_TYPED },
     { uri: uri2, title: "visited" },
     { uri: uri4, title: "tpbk", transition: TRANSITION_TYPED },
   ]);
   addBookmark( { uri: uri3, title: "bookmarked" } );
   addBookmark( { uri: uri4, title: "tpbk" } );
 
   // RESTRICT TO HISTORY.
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 1);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history.onlyTyped", false);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", false);
   Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", true);
   Services.prefs.setBoolPref("browser.urlbar.autoFill.searchEngines", false);
 
   do_log_info("URL: Restrict history, common visit, should not autoFill");
   yield check_autocomplete({
     search: "visited/v",
     matches: [ { uri: uri2, title: "visited" } ],
     autofilled: "visited/v",
@@ -215,17 +240,18 @@ add_task(function* test_default_behavior
   yield check_autocomplete({
     search: "tpbk/t",
     matches: [ { uri: uri4, title: "tpbk/tp/", style: [ "autofill" ] } ],
     autofilled: "tpbk/tp/",
     completed: "http://tpbk/tp/"
   });
 
   // RESTRICT BOOKMARKS.
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 2);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", false);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
 
   do_log_info("URL: Restrict bookmarks, common visit, should not autoFill");
   yield check_autocomplete({
     search: "visited/v",
     matches: [ ],
     autofilled: "visited/v",
     completed: "visited/v"
   });
--- a/toolkit/components/places/tests/unifiedcomplete/test_autocomplete_functional.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_autocomplete_functional.js
@@ -1,17 +1,19 @@
 /* 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/. */
 
 // Functional tests for inline autocomplete
 
+const PREF_AUTOCOMPLETE_ENABLED = "browser.urlbar.autocomplete.enabled";
+
 add_task(function* test_disabling_autocomplete() {
   do_log_info("Check disabling autocomplete disables autofill");
-  Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", false);
+  Services.prefs.setBoolPref(PREF_AUTOCOMPLETE_ENABLED, false);
   yield promiseAddVisits({ uri: NetUtil.newURI("http://visit.mozilla.org"),
                            transition: TRANSITION_TYPED });
   yield check_autocomplete({
     search: "vis",
     autofilled: "vis",
     completed: "vis"
   });
   yield cleanup();
@@ -140,8 +142,28 @@ add_task(function* test_complete_fragmen
   yield promiseAddVisits(NetUtil.newURI("http://smokey.mozilla.org/foo?bacon=delicious#bar"));
   yield check_autocomplete({
     search: "smokey.mozilla.org/foo?bacon=delicious#bar",
     autofilled: "smokey.mozilla.org/foo?bacon=delicious#bar",
     completed: "http://smokey.mozilla.org/foo?bacon=delicious#bar",
   });
   yield cleanup();
 });
+
+add_task(function* test_autocomplete_enabled_pref() {
+  Services.prefs.setBoolPref(PREF_AUTOCOMPLETE_ENABLED, false);
+  let types = ["history", "bookmark", "openpage"];
+  for (type of types) {
+    do_check_eq(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), false,
+                "suggest." + type + "pref should be false");
+  }
+  Services.prefs.setBoolPref(PREF_AUTOCOMPLETE_ENABLED, true);
+  for (type of types) {
+    do_check_eq(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), true,
+                "suggest." + type + "pref should be true");
+  }
+
+  // Clear prefs.
+  Services.prefs.clearUserPref(PREF_AUTOCOMPLETE_ENABLED);
+  for (type of types) {
+    Services.prefs.clearUserPref("browser.urlbar.suggest." + type);
+  }
+});
--- a/toolkit/components/places/tests/unifiedcomplete/test_empty_search.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_empty_search.js
@@ -9,86 +9,85 @@
 
 add_task(function* test_javascript_match() {
   let uri1 = NetUtil.newURI("http://t.foo/0");
   let uri2 = NetUtil.newURI("http://t.foo/1");
   let uri3 = NetUtil.newURI("http://t.foo/2");
   let uri4 = NetUtil.newURI("http://t.foo/3");
   let uri5 = NetUtil.newURI("http://t.foo/4");
   let uri6 = NetUtil.newURI("http://t.foo/5");
+  let uri7 = NetUtil.newURI("http://t.foo/6");
 
   yield promiseAddVisits([ { uri: uri1, title: "title" },
                            { uri: uri2, title: "title" },
                            { uri: uri3, title: "title",
                              transition: TRANSITION_TYPED},
                            { uri: uri4, title: "title",
                              transition: TRANSITION_TYPED },
                            { uri: uri6, title: "title",
-                             transition: TRANSITION_TYPED } ]);
+                             transition: TRANSITION_TYPED },
+                           { uri: uri7, title: "title" } ]);
 
   addBookmark({ uri: uri2,
                 title: "title" });
   addBookmark({ uri: uri4,
                 title: "title" });
   addBookmark({ uri: uri5,
                 title: "title" });
   addBookmark({ uri: uri6,
                 title: "title" });
 
-  // Now remove page 6 from history, so it is an unvisited, typed bookmark.
+  addOpenPages(uri7, 1);
+
+  // Now remove page 6 from history, so it is an unvisited bookmark.
   PlacesUtils.history.removePage(uri6);
 
   do_log_info("Match everything");
   yield check_autocomplete({
     search: "foo",
+    searchParam: "enable-actions",
     matches: [ { uri: uri1, title: "title" },
                { uri: uri2, title: "title", style: ["bookmark"] },
                { uri: uri3, title: "title" },
                { uri: uri4, title: "title", style: ["bookmark"] },
                { uri: uri5, title: "title", style: ["bookmark"] },
-               { uri: uri6, title: "title", style: ["bookmark"] } ]
+               { uri: uri6, title: "title", style: ["bookmark"] },
+               { uri: makeActionURI("switchtab", {url: "http://t.foo/6"}), title: "title", style: [ "action,switchtab" ] }, ]
   });
 
   do_log_info("Match only typed history");
   yield check_autocomplete({
     search: "foo ^ ~",
     matches: [ { uri: uri3, title: "title" },
                { uri: uri4, title: "title" } ]
   });
 
   do_log_info("Drop-down empty search matches only typed history");
   yield check_autocomplete({
     search: "",
     matches: [ { uri: uri3, title: "title" },
                { uri: uri4, title: "title" } ]
   });
 
-  do_log_info("Drop-down empty search matches everything");
-  Services.prefs.setIntPref("browser.urlbar.default.behavior.emptyRestriction", 0);
+  do_log_info("Drop-down empty search matches only bookmarks");
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", false);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
   yield check_autocomplete({
     search: "",
-    matches: [ { uri: uri1, title: "title" },
-               { uri: uri2, title: "title", style: ["bookmark"] },
-               { uri: uri3, title: "title" },
+    matches: [ { uri: uri2, title: "title", style: ["bookmark"] },
                { uri: uri4, title: "title", style: ["bookmark"] },
                { uri: uri5, title: "title", style: ["bookmark"] },
                { uri: uri6, title: "title", style: ["bookmark"] } ]
   });
 
-  do_log_info("Drop-down empty search matches only typed");
-  Services.prefs.setIntPref("browser.urlbar.default.behavior.emptyRestriction", 32);
+  do_log_info("Drop-down empty search matches only open tabs");
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", false);
   yield check_autocomplete({
     search: "",
-    matches: [ { uri: uri3, title: "title" },
-               { uri: uri4, title: "title", style: ["bookmark"] },
-               { uri: uri6, title: "title", style: ["bookmark"] } ]
+    searchParam: "enable-actions",
+    matches: [ { uri: makeActionURI("switchtab", {url: "http://t.foo/6"}), title: "title", style: [ "action,switchtab" ] }, ]
   });
 
-  do_log_info("Drop-down empty search matches only typed history");
-  Services.prefs.clearUserPref("browser.urlbar.default.behavior.emptyRestriction");
-  yield check_autocomplete({
-    search: "",
-    matches: [ { uri: uri3, title: "title" },
-               { uri: uri4, title: "title" } ]
-  });
+  Services.prefs.clearUserPref("browser.urlbar.suggest.history");
+  Services.prefs.clearUserPref("browser.urlbar.suggest.bookmark");
 
   yield cleanup();
 });
--- a/toolkit/components/places/tests/unifiedcomplete/test_special_search.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_special_search.js
@@ -5,16 +5,22 @@
 /**
  * Test for bug 395161 that allows special searches that restrict results to
  * history/bookmark/tagged items and title/url matches.
  *
  * Test 485122 by making sure results don't have tags when restricting result
  * to just history either by default behavior or dynamic query restrict.
  */
 
+function setSuggestPrefsToFalse() {
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", false);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history.onlyTyped", false);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", false);
+}
+
 add_task(function* test_special_searches() {
   let uri1 = NetUtil.newURI("http://url/");
   let uri2 = NetUtil.newURI("http://url/2");
   let uri3 = NetUtil.newURI("http://foo.bar/");
   let uri4 = NetUtil.newURI("http://foo.bar/2");
   let uri5 = NetUtil.newURI("http://url/star");
   let uri6 = NetUtil.newURI("http://url/star/2");
   let uri7 = NetUtil.newURI("http://foo.bar/star");
@@ -42,30 +48,30 @@ add_task(function* test_special_searches
   do_log_info("History restrict");
   yield check_autocomplete({
     search: "^",
     matches: [ { uri: uri1, title: "title" },
                { uri: uri2, title: "foo.bar" },
                { uri: uri3, title: "title" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri6, title: "foo.bar" },
-               { uri: uri11, title: "title" } ]
+               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("Star restrict");
   yield check_autocomplete({
     search: "*",
     matches: [ { uri: uri5, title: "title", style: [ "bookmark" ] },
                { uri: uri6, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri7, title: "title", style: [ "bookmark" ] },
                { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri9, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
                { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] },
                { uri: uri11, title: "title", tags: [ "foo.bar"], style: [ "tag" ] },
-               { uri: uri12, title: "foo.bar", tags: ["foo.bar"], style: [ "tag" ] } ]
+               { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("Tag restrict");
   yield check_autocomplete({
     search: "+",
     matches: [ { uri: uri9, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
                { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
@@ -75,59 +81,59 @@ add_task(function* test_special_searches
   // Test specials as any word position
   do_log_info("Special as first word");
   yield check_autocomplete({
     search: "^ foo bar",
     matches: [ { uri: uri2, title: "foo.bar" },
                { uri: uri3, title: "title" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri6, title: "foo.bar" },
-               { uri: uri11, title: "title" } ]
+               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("Special as middle word");
   yield check_autocomplete({
     search: "foo ^ bar",
     matches: [ { uri: uri2, title: "foo.bar" },
                { uri: uri3, title: "title" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri6, title: "foo.bar" },
-               { uri: uri11, title: "title" } ]
+               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("Special as last word");
   yield check_autocomplete({
     search: "foo bar ^",
     matches: [ { uri: uri2, title: "foo.bar" },
                { uri: uri3, title: "title" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri6, title: "foo.bar" },
-               { uri: uri11, title: "title" } ]
+               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   // Test restricting and matching searches with a term
   do_log_info("foo ^ -> history");
   yield check_autocomplete({
     search: "foo ^",
     matches: [ { uri: uri2, title: "foo.bar" },
                { uri: uri3, title: "title" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri6, title: "foo.bar" },
-               { uri: uri11, title: "title" } ]
+               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("foo | -> history (change pref)");
   changeRestrict("history", "|");
   yield check_autocomplete({
     search: "foo |",
     matches: [ { uri: uri2, title: "foo.bar" },
                { uri: uri3, title: "title" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri6, title: "foo.bar" },
-               { uri: uri11, title: "title" } ]
+               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("foo * -> is star");
   resetRestrict("history");
   yield check_autocomplete({
     search: "foo *",
     matches: [ { uri: uri6, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri7, title: "title", style: [ "bookmark" ] },
@@ -249,38 +255,38 @@ add_task(function* test_special_searches
   });
 
   do_log_info("foo ^ # -> history, in title");
   yield check_autocomplete({
     search: "foo ^ #",
     matches: [ { uri: uri2, title: "foo.bar" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri6, title: "foo.bar" },
-               { uri: uri11, title: "title" } ]
+               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("foo ^ @ -> history, in url");
   yield check_autocomplete({
     search: "foo ^ @",
     matches: [ { uri: uri3, title: "title" },
                { uri: uri4, title: "foo.bar" },
-               { uri: uri11, title: "title" } ]
+               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("foo ^ + -> history, is tag");
   yield check_autocomplete({
     search: "foo ^ +",
     matches: [ { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("foo ^ ~ -> history, is typed");
   yield check_autocomplete({
     search: "foo ^ ~",
     matches: [ { uri: uri4, title: "foo.bar" },
-               { uri: uri11, title: "title" } ]
+               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("foo * # -> is star, in title");
   yield check_autocomplete({
     search: "foo * #",
     matches: [ { uri: uri6, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri9, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
@@ -357,67 +363,83 @@ add_task(function* test_special_searches
     search: "foo + ~",
     matches: [ { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   // Disable autoFill for the next tests, see test_autoFill_default_behavior.js
   // for specific tests.
   Services.prefs.setBoolPref("browser.urlbar.autoFill", false);
 
-  // Test default usage by setting certain bits of default.behavior to 1
+  // Test default usage by setting certain browser.urlbar.suggest.* prefs
   do_log_info("foo -> default history");
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 1);
+  setSuggestPrefsToFalse();
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
   yield check_autocomplete({
     search: "foo",
     matches: [ { uri: uri2, title: "foo.bar" },
                { uri: uri3, title: "title" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri6, title: "foo.bar" },
-               { uri: uri11, title: "title" } ]
+               { uri: uri11, title: "title", tags: ["foo.bar"], style: [ "tag" ] } ]
   });
 
   do_log_info("foo -> default history, is star");
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 3);
+  setSuggestPrefsToFalse();
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
   yield check_autocomplete({
     search: "foo",
-    matches: [ { uri: uri6, title: "foo.bar", style: [ "bookmark" ] },
-               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
+    matches: [ { uri: uri2, title: "foo.bar" },
+               { uri: uri3, title: "title" },
+               { uri: uri4, title: "foo.bar" },
+               { uri: uri6, title: "foo.bar", style: [ "bookmark" ] },
+               { uri: uri7, title: "title", style: [ "bookmark" ] },
+               { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
+               { uri: uri9, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
+               { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] },
+               { uri: uri11, title: "title", tags: [ "foo.bar"], style: [ "tag" ] },
+               { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
   do_log_info("foo -> default history, is star, is typed");
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 35);
-  yield check_autocomplete({
-    search: "foo",
-    matches: [ { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
-  });
-
-  do_log_info("foo -> default history, is star, in url");
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 19);
+  setSuggestPrefsToFalse();
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history.onlyTyped", true);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
   yield check_autocomplete({
     search: "foo",
-    matches: [ { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
+    matches: [ { uri: uri4, title: "foo.bar" },
+               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
-  // Change the default to be less restrictive to make sure we find more
-  do_log_info("foo -> default is star, in url");
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 18);
+  do_log_info("foo -> is star");
+  setSuggestPrefsToFalse();
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history", false);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
   yield check_autocomplete({
     search: "foo",
-    matches: [ { uri: uri7, title: "title", style: [ "bookmark" ] },
+    matches: [ { uri: uri6, title: "foo.bar", style: [ "bookmark" ] },
+               { uri: uri7, title: "title", style: [ "bookmark" ] },
                { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
+               { uri: uri9, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
+               { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
                { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] } ]
   });
 
-  do_log_info("foo -> default in url");
-  Services.prefs.setIntPref("browser.urlbar.default.behavior", 16);
+  do_log_info("foo -> is star, is typed");
+  setSuggestPrefsToFalse();
+  // only typed should be ignored
+  Services.prefs.setBoolPref("browser.urlbar.suggest.history.onlyTyped", true);
+  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
   yield check_autocomplete({
     search: "foo",
-    matches: [ { uri: uri3, title: "title" },
-               { uri: uri4, title: "foo.bar" },
+    matches: [ { uri: uri6, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri7, title: "title", style: [ "bookmark" ] },
                { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
+               { uri: uri9, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
+               { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
-               { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] } ]
+               { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] }  ]
   });
 
   yield cleanup();
 });
--- a/toolkit/components/places/tests/unit/test_adaptive_bug527311.js
+++ b/toolkit/components/places/tests/unit/test_adaptive_bug527311.js
@@ -1,31 +1,38 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et: */
 /* 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/. */
 
 const TEST_URL = "http://adapt.mozilla.org/";
 const SEARCH_STRING = "adapt";
+const SUGGEST_TYPES = ["history", "bookmark", "openpage"];
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
          getService(Ci.nsINavBookmarksService);
 let os = Cc["@mozilla.org/observer-service;1"].
          getService(Ci.nsIObserverService);
 let ps = Cc["@mozilla.org/preferences-service;1"].
          getService(Ci.nsIPrefBranch);
 
 const PLACES_AUTOCOMPLETE_FEEDBACK_UPDATED_TOPIC =
   "places-autocomplete-feedback-updated";
 
+function cleanup() {
+  for (let type of SUGGEST_TYPES) {
+    ps.clearUserPref("browser.urlbar.suggest." + type);
+  }
+}
+
 function AutoCompleteInput(aSearches) {
   this.searches = aSearches;
 }
 AutoCompleteInput.prototype = {
   constructor: AutoCompleteInput,
   searches: null,
   minResultsForPopup: 0,
   timeout: 10,
@@ -78,16 +85,17 @@ function check_results() {
   controller.input = input;
 
   input.onSearchComplete = function() {
     do_check_eq(controller.searchStatus,
                 Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH);
     do_check_eq(controller.matchCount, 0);
 
     remove_all_bookmarks();
+    cleanup();
     do_test_finished();
  };
 
   controller.startSearch(SEARCH_STRING);
 }
 
 
 function addAdaptiveFeedback(aUrl, aSearch, aCallback) {
@@ -117,13 +125,16 @@ function addAdaptiveFeedback(aUrl, aSear
 
 function run_test() {
   do_test_pending();
 
   // Add a bookmark to our url.
   bs.insertBookmark(bs.unfiledBookmarksFolder, uri(TEST_URL),                   
                     bs.DEFAULT_INDEX, "test_book");
   // We want to search only history.
-  ps.setIntPref("browser.urlbar.default.behavior",
-                Ci.mozIPlacesAutoComplete.BEHAVIOR_HISTORY);
+  for (let type of SUGGEST_TYPES) {
+    type == "history" ? ps.setBoolPref("browser.urlbar.suggest." + type, true)
+                      : ps.setBoolPref("browser.urlbar.suggest." + type, false);
+  }
+
   // Add an adaptive entry.
   addAdaptiveFeedback(TEST_URL, SEARCH_STRING, check_results);
 }
--- a/toolkit/components/places/tests/unit/test_frecency.js
+++ b/toolkit/components/places/tests/unit/test_frecency.js
@@ -276,19 +276,24 @@ function run_test()
   run_next_test();
 }
 
 add_task(function test_frecency()
 {
   // always search in history + bookmarks, no matter what the default is
   var prefs = Cc["@mozilla.org/preferences-service;1"].
               getService(Ci.nsIPrefBranch);
-  prefs.setIntPref("browser.urlbar.search.sources", 3);
-  prefs.setIntPref("browser.urlbar.default.behavior", 0);
+
+  prefs.setBoolPref("browser.urlbar.suggest.history", true);
+  prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
+  prefs.setBoolPref("browser.urlbar.suggest.openpage", false);
   for (let [, test] in Iterator(tests)) {
     remove_all_bookmarks();
     yield promiseClearHistory();
 
     deferEnsureResults = Promise.defer();
     yield test();
     yield deferEnsureResults.promise;
   }
+  for (let type of ["history", "bookmark", "openpage"]) {
+    prefs.clearUserPref("browser.urlbar.suggest." + type);
+  }
 });