Bug 1559686 - Reimplement the inputHistory feature in the Quantum Bar. r=adw
authorMarco Bonardo <mbonardo@mozilla.com> <mbonardo@mozilla.com>
Thu, 20 Jun 2019 18:21:01 +0000
changeset 479707 c8b11404e7a11df5e546030ae5c03729560b64ca
parent 479706 cc3c2ca06c275e5936152c364c76092a8db32f6b
child 479708 f7e5ef31a50b7b9080f28a53150f16b393d448db
push id36180
push usershindli@mozilla.com
push dateFri, 21 Jun 2019 09:33:06 +0000
treeherdermozilla-central@b8c319d5968f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1559686
milestone69.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 1559686 - Reimplement the inputHistory feature in the Quantum Bar. r=adw Differential Revision: https://phabricator.services.mozilla.com/D35364
browser/components/urlbar/UrlbarInput.jsm
browser/components/urlbar/UrlbarUtils.jsm
browser/components/urlbar/tests/browser/browser.ini
browser/components/urlbar/tests/browser/browser_inputHistory.js
browser/components/urlbar/tests/legacy/browser.ini
toolkit/components/places/nsINavHistoryService.idl
toolkit/components/places/nsNavHistory.cpp
toolkit/components/places/nsNavHistory.h
toolkit/components/places/tests/unifiedcomplete/test_adaptive.js
toolkit/components/places/tests/unifiedcomplete/test_adaptive_behaviors.js
toolkit/components/places/tests/unifiedcomplete/test_adaptive_limited.js
toolkit/components/places/tests/unifiedcomplete/xpcshell.ini
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -519,16 +519,23 @@ class UrlbarInput {
                                                   where);
         return;
       }
     }
 
     if (!url) {
       throw new Error(`Invalid url for result ${JSON.stringify(result)}`);
     }
+
+    if (!this.isPrivate && !result.heuristic) {
+      // This should not interrupt the load anyway.
+      UrlbarUtils.addToInputHistory(url, this._lastSearchString)
+                 .catch(Cu.reportError);
+    }
+
     this._loadURL(url, where, openParams, {
       source: result.source,
       type: result.type,
     });
   }
 
   /**
    * Called by the view when moving through results with the keyboard, and when
--- a/browser/components/urlbar/UrlbarUtils.jsm
+++ b/browser/components/urlbar/UrlbarUtils.jsm
@@ -367,16 +367,29 @@ var UrlbarUtils = {
       if (scheme != "javascript") {
         break;
       }
 
       pasteData = pasteData.substring(pasteData.indexOf(":") + 1);
     }
     return pasteData;
   },
+
+  async addToInputHistory(url, input) {
+    await PlacesUtils.withConnectionWrapper("addToInputHistory", db => {
+      // use_count will asymptotically approach the max of 10.
+      return db.executeCached(`
+        INSERT OR REPLACE INTO moz_inputhistory
+        SELECT h.id, IFNULL(i.input, :input), IFNULL(i.use_count, 0) * .9 + 1
+        FROM moz_places h
+        LEFT JOIN moz_inputhistory i ON i.place_id = h.id AND i.input = :input
+        WHERE url_hash = hash(:url) AND url = :url
+      `, {url, input});
+    });
+  },
 };
 
 XPCOMUtils.defineLazyGetter(UrlbarUtils.ICON, "DEFAULT", () => {
   return PlacesUtils.favicons.defaultFavicon.spec;
 });
 
 /**
  * UrlbarQueryContext defines a user's autocomplete input from within the urlbar.
--- a/browser/components/urlbar/tests/browser/browser.ini
+++ b/browser/components/urlbar/tests/browser/browser.ini
@@ -42,16 +42,17 @@ support-files =
 [browser_caret_navigation.js]
 [browser_customizeMode.js]
 [browser_deleteAllText.js]
 [browser_doubleClickSelectsAll.js]
 [browser_downArrowKeySearch.js]
 [browser_dragdropURL.js]
 [browser_dropmarker.js]
 [browser_ime_composition.js]
+[browser_inputHistory.js]
 [browser_keepStateAcrossTabSwitches.js]
 [browser_keywordBookmarklets.js]
 [browser_keyword_override.js]
 [browser_keywordSearch.js]
 [browser_keywordSearch_postData.js]
 uses-unsafe-cpows = true
 support-files =
   POSTSearchEngine.xml
new file mode 100644
--- /dev/null
+++ b/browser/components/urlbar/tests/browser/browser_inputHistory.js
@@ -0,0 +1,307 @@
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * This tests the urlbar adaptive behavior powered by input history.
+ */
+
+"use strict";
+
+async function bumpScore(uri, searchString, counts, useMouseClick = false) {
+  if (counts.visits) {
+    let visits = new Array(counts.visits).fill(uri);
+    await PlacesTestUtils.addVisits(visits);
+  }
+  if (counts.picks) {
+    for (let i = 0; i < counts.picks; ++i) {
+      await promiseAutocompleteResultPopup(searchString);
+      let promise = BrowserTestUtils.waitForDocLoadAndStopIt(uri, gBrowser.selectedBrowser);
+      // Look for the expected uri.
+      while (gURLBar.value != uri) {
+        EventUtils.synthesizeKey("KEY_ArrowDown");
+      }
+      if (useMouseClick) {
+        let element = UrlbarTestUtils.getSelectedElement(window);
+        EventUtils.synthesizeMouseAtCenter(element, {});
+      } else {
+        EventUtils.synthesizeKey("KEY_Enter");
+      }
+      await promise;
+    }
+  }
+  await PlacesTestUtils.promiseAsyncUpdates();
+}
+
+async function decayInputHistory() {
+  PlacesUtils.history.decayFrecency();
+  await PlacesTestUtils.promiseAsyncUpdates();
+}
+
+add_task(async function setup() {
+  await SpecialPowers.pushPrefEnv({set: [
+    // We don't want autofill to influence this test.
+    ["browser.urlbar.autoFill", false],
+  ]});
+  registerCleanupFunction(async () => {
+    await PlacesUtils.history.clear();
+    await PlacesUtils.bookmarks.eraseEverything();
+  });
+});
+
+add_task(async function test_adaptive_no_search_terms() {
+  let url1 = "http://site.tld/1";
+  let url2 = "http://site.tld/2";
+
+  info("Same visit count, different picks");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "site", {visits: 3, picks: 3});
+  await bumpScore(url2, "site", {visits: 3, picks: 1});
+  await promiseAutocompleteResultPopup("");
+  let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
+  Assert.equal(result.url, url1, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url2, "Check second result");
+
+  info("Same visit count, different picks, invert");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "site", {visits: 3, picks: 1});
+  await bumpScore(url2, "site", {visits: 3, picks: 3});
+  await promiseAutocompleteResultPopup("");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
+  Assert.equal(result.url, url2, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url1, "Check second result");
+
+  info("Different visit count, same picks");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "site", {visits: 3, picks: 3});
+  await bumpScore(url2, "site", {visits: 1, picks: 3});
+  await promiseAutocompleteResultPopup("");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
+  Assert.equal(result.url, url1, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url2, "Check second result");
+
+  info("Different visit count, same picks, invert");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "site", {visits: 1, picks: 3});
+  await bumpScore(url2, "site", {visits: 3, picks: 3});
+  await promiseAutocompleteResultPopup("");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
+  Assert.equal(result.url, url2, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url1, "Check second result");
+});
+
+add_task(async function test_adaptive_with_search_terms() {
+  let url1 = "http://site.tld/1";
+  let url2 = "http://site.tld/2";
+
+  info("Same visit count, same picks, one partial match, one exact match");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "si", {visits: 3, picks: 3});
+  await bumpScore(url2, "site", {visits: 3, picks: 3});
+  await promiseAutocompleteResultPopup("si");
+  let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url1, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 2);
+  Assert.equal(result.url, url2, "Check second result");
+
+  info("Same visit count, same picks, one partial match, one exact match, invert");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "site", {visits: 3, picks: 3});
+  await bumpScore(url2, "si", {visits: 3, picks: 3});
+  await promiseAutocompleteResultPopup("si");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url2, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 2);
+  Assert.equal(result.url, url1, "Check second result");
+
+  info("Same visit count, different picks, both exact match");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "si", {visits: 3, picks: 3});
+  await bumpScore(url2, "si", {visits: 3, picks: 1});
+  await promiseAutocompleteResultPopup("si");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url1, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 2);
+  Assert.equal(result.url, url2, "Check second result");
+
+  info("Same visit count, different picks, both exact match, invert");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "si", {visits: 3, picks: 1});
+  await bumpScore(url2, "si", {visits: 3, picks: 3});
+  await promiseAutocompleteResultPopup("si");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url2, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 2);
+  Assert.equal(result.url, url1, "Check second result");
+
+  info("Same visit count, different picks, both partial match");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "site", {visits: 3, picks: 3});
+  await bumpScore(url2, "site", {visits: 3, picks: 1});
+  await promiseAutocompleteResultPopup("si");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url1, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 2);
+  Assert.equal(result.url, url2, "Check second result");
+
+  info("Same visit count, different picks, both partial match, invert");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "site", {visits: 3, picks: 1});
+  await bumpScore(url2, "site", {visits: 3, picks: 3});
+  await promiseAutocompleteResultPopup("si");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url2, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 2);
+  Assert.equal(result.url, url1, "Check second result");
+});
+
+add_task(async function test_adaptive_with_decay() {
+  let url1 = "http://site.tld/1";
+  let url2 = "http://site.tld/2";
+
+  info("Same visit count, same picks, both exact match, decay first");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "si", {visits: 3, picks: 3});
+  await decayInputHistory();
+  await bumpScore(url2, "si", {visits: 3, picks: 3});
+  await promiseAutocompleteResultPopup("si");
+  let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url2, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 2);
+  Assert.equal(result.url, url1, "Check second result");
+
+  info("Same visit count, same picks, both exact match, decay second");
+  await PlacesUtils.history.clear();
+  await bumpScore(url2, "si", {visits: 3, picks: 3});
+  await decayInputHistory();
+  await bumpScore(url1, "si", {visits: 3, picks: 3});
+  await promiseAutocompleteResultPopup("si");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url1, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 2);
+  Assert.equal(result.url, url2, "Check second result");
+});
+
+
+add_task(async function test_adaptive_limited() {
+  let url1 = "http://site.tld/1";
+  let url2 = "http://site.tld/2";
+
+  info("Same visit count, same picks, both exact match, decay first");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "si", {visits: 3, picks: 3});
+  await decayInputHistory();
+  await bumpScore(url2, "si", {visits: 3, picks: 3});
+  await promiseAutocompleteResultPopup("si");
+  let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url2, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 2);
+  Assert.equal(result.url, url1, "Check second result");
+
+  info("Same visit count, same picks, both exact match, decay second");
+  await PlacesUtils.history.clear();
+  await bumpScore(url2, "si", {visits: 3, picks: 3});
+  await decayInputHistory();
+  await bumpScore(url1, "si", {visits: 3, picks: 3});
+  await promiseAutocompleteResultPopup("si");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url1, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 2);
+  Assert.equal(result.url, url2, "Check second result");
+});
+
+add_task(async function test_adaptive_limited() {
+  info("Adaptive results should be added at the top up to maxRichResults / 4, then enqueued");
+  await PlacesUtils.history.clear();
+  await PlacesUtils.bookmarks.eraseEverything();
+
+  // Add as many adaptive results as maxRichResults.
+  let n = UrlbarPrefs.get("maxRichResults");
+  let urls = Array(n).fill(0).map((e, i) => "http://site.tld/" + i);
+  for (let url of urls) {
+    await bumpScore(url, "site", {visits: 1, picks: 1});
+  }
+
+  // Add a matching bookmark with an higher frecency.
+  let url = "http://site.bookmark.tld/";
+  await PlacesTestUtils.addVisits(url);
+  let bm = await PlacesUtils.bookmarks.insert({
+    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
+    title: "test_site_book",
+    url,
+  });
+
+  let expectedBookmarkIndex = Math.floor(n / 4) + 2;
+  await promiseAutocompleteResultPopup("site");
+  let result = await UrlbarTestUtils.getDetailsOfResultAt(window, expectedBookmarkIndex);
+  Assert.equal(result.url, url, "Check bookmarked result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, n - 1);
+  Assert.equal(UrlbarTestUtils.getResultCount(window), n,
+               "Check all the results are filled");
+  Assert.ok(result.url.startsWith("http://site.tld"),
+            "Check last adaptive result");
+  await PlacesUtils.bookmarks.remove(bm);
+});
+
+add_task(async function test_adaptive_behaviors() {
+  info("Check adaptive results are not provided regardless of the requested behavior");
+  await PlacesUtils.history.clear();
+  await PlacesUtils.bookmarks.eraseEverything();
+
+  // Add an adaptive entry.
+  await bumpScore("http://site.tld/1", "site", {visits: 1, picks: 1});
+
+  let url = "http://bookmarked.site.tld/1";
+  let bm = await PlacesUtils.bookmarks.insert({
+    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
+    title: "test_book",
+    url,
+  });
+
+  await SpecialPowers.pushPrefEnv({set: [
+    // Search only bookmarks.
+    ["browser.urlbar.suggest.bookmarks", true],
+    ["browser.urlbar.suggest.history", false],
+  ]});
+  await promiseAutocompleteResultPopup("site");
+  let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url, "Check bookmarked result");
+
+  Assert.equal(UrlbarTestUtils.getResultCount(window), 2,
+               "Check there are no unexpected results");
+
+  await PlacesUtils.bookmarks.remove(bm);
+  await SpecialPowers.popPrefEnv();
+});
+
+add_task(async function test_adaptive_mouse() {
+  info("Check adaptive results are updated on mouse picks");
+  await PlacesUtils.history.clear();
+
+  let url1 = "http://site.tld/1";
+  let url2 = "http://site.tld/2";
+
+  info("Same visit count, different picks");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "site", {visits: 3, picks: 3}, true);
+  await bumpScore(url2, "site", {visits: 3, picks: 1}, true);
+  await promiseAutocompleteResultPopup("");
+  let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
+  Assert.equal(result.url, url1, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url2, "Check second result");
+
+  info("Same visit count, different picks, invert");
+  await PlacesUtils.history.clear();
+  await bumpScore(url1, "site", {visits: 3, picks: 1}, true);
+  await bumpScore(url2, "site", {visits: 3, picks: 3}, true);
+  await promiseAutocompleteResultPopup("");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
+  Assert.equal(result.url, url2, "Check first result");
+  result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+  Assert.equal(result.url, url1, "Check second result");
+});
--- a/browser/components/urlbar/tests/legacy/browser.ini
+++ b/browser/components/urlbar/tests/legacy/browser.ini
@@ -52,16 +52,17 @@ skip-if = os != "mac" # Mac only feature
 [../browser/browser_autoFill_preserve.js]
 [../browser/browser_autoFill_trimURLs.js]
 [../browser/browser_autoFill_typed.js]
 [../browser/browser_autoFill_undo.js]
 [../browser/browser_autocomplete_tag_star_visibility.js]
 [../browser/browser_canonizeURL.js]
 [../browser/browser_dragdropURL.js]
 [../browser/browser_ime_composition.js]
+[../browser/browser_inputHistory.js]
 [../browser/browser_keywordBookmarklets.js]
 [../browser/browser_keepStateAcrossTabSwitches.js]
 [../browser/browser_keyword_override.js]
 [../browser/browser_keywordSearch.js]
 [../browser/browser_keywordSearch_postData.js]
 uses-unsafe-cpows = true
 support-files =
   ../browser/POSTSearchEngine.xml
--- a/toolkit/components/places/nsINavHistoryService.idl
+++ b/toolkit/components/places/nsINavHistoryService.idl
@@ -1319,9 +1319,15 @@ interface nsINavHistoryService : nsISupp
   readonly attribute nsIAsyncShutdownClient shutdownClient;
 
   /**
    * Hook for internal clients who need to perform actions just before the
    * connection gets closed.
    * May be null if it's too late to get one.
    */
   readonly attribute nsIAsyncShutdownClient connectionShutdownClient;
+
+  /**
+   * Asynchronously recalculates frecency for all pages where frecency < 0, then
+   * decays frecency and inputhistory values.
+   */
+   void decayFrecency();
 };
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -2296,23 +2296,24 @@ nsNavHistory::Observe(nsISupports* aSubj
     NS_ENSURE_SUCCESS(rv, rv);
   }
 #endif
   else if (strcmp(aTopic, TOPIC_PREF_CHANGED) == 0) {
     LoadPrefs();
   }
 
   else if (strcmp(aTopic, TOPIC_IDLE_DAILY) == 0) {
-    (void)FixAndDecayFrecency();
+    (void)DecayFrecency();
   }
 
   return NS_OK;
 }
 
-nsresult nsNavHistory::FixAndDecayFrecency() {
+NS_IMETHODIMP
+nsNavHistory::DecayFrecency() {
   float decayRate =
       Preferences::GetFloat(PREF_FREC_DECAY_RATE, PREF_FREC_DECAY_RATE_DEF);
   if (decayRate > 1.0f) {
     MOZ_ASSERT(false, "The frecency decay rate should not be greater than 1.0");
     decayRate = PREF_FREC_DECAY_RATE_DEF;
   }
 
   RefPtr<FixAndDecayFrecencyRunnable> runnable =
--- a/toolkit/components/places/nsNavHistory.h
+++ b/toolkit/components/places/nsNavHistory.h
@@ -434,26 +434,16 @@ class nsNavHistory final : public nsSupp
   // used by GetHistoryService
   static nsNavHistory* gHistoryService;
 
  protected:
   // Database handle.
   RefPtr<mozilla::places::Database> mDB;
 
   /**
-   * Recalculates frecency for all pages where frecency < 0, then decays
-   * frecency and inputhistory values. Pages can invalidate frecencies:
-   *  * After a "clear private data"
-   *  * After removing visits
-   *  * After migrating from older versions
-   * This method runs on idle-daily.
-   */
-  nsresult FixAndDecayFrecency();
-
-  /**
    * Loads all of the preferences that we use into member variables.
    *
    * @note If mPrefBranch is nullptr, this does nothing.
    */
   void LoadPrefs();
 
   /**
    * Calculates and returns value for mCachedNow.
deleted file mode 100644
--- a/toolkit/components/places/tests/unifiedcomplete/test_adaptive.js
+++ /dev/null
@@ -1,370 +0,0 @@
-/* -*- 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/. */
-
-/**
- * Test for bug 395739 to make sure the feedback to the search results in those
- * entries getting better ranks. Additionally, exact matches should be ranked
- * higher. Because the interactions among adaptive rank and visit counts is not
- * well defined, this test holds one of the two values constant when modifying
- * the other.
- *
- * This also tests bug 395735 for the instrumentation feedback mechanism.
- *
- * Bug 411293 is tested to make sure the drop down strongly prefers previously
- * typed pages that have been selected and are moved to the top with adaptive
- * learning.
- */
-
-/**
- * Checks that autocomplete results are ordered correctly.
- */
-function ensure_results(expected, searchTerm, callback) {
-  let controller = Cc["@mozilla.org/autocomplete/controller;1"].
-                   getService(Ci.nsIAutoCompleteController);
-
-  // Make an AutoCompleteInput that uses our searches
-  // and confirms results on search complete.
-  let input = new AutoCompleteInput(["unifiedcomplete"]);
-
-  controller.input = input;
-
-  input.onSearchComplete = function() {
-    Assert.equal(controller.searchStatus,
-                 Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH,
-                 "The search should be complete");
-    Assert.equal(controller.matchCount, expected.length,
-                 "All the expected results should have been found");
-    for (let i = 0; i < controller.matchCount; i++) {
-      print("Testing for '" + expected[i].uri.spec + "' got '" + controller.getValueAt(i) + "'");
-      Assert.equal(controller.getValueAt(i), expected[i].uri.spec);
-      Assert.equal(controller.getStyleAt(i), expected[i].style);
-    }
-
-    callback();
-  };
-
-  controller.startSearch(searchTerm);
-}
-
-/**
- * Asynchronous task that bumps up the rank for an uri.
- */
-async function task_setCountRank(aURI, aCount, aRank, aSearch, aBookmark) {
-  // Bump up the visit count for the uri.
-  let visits = [];
-  for (let i = 0; i < aCount; i++) {
-    visits.push({ uri: aURI, visitDate: d1, transition: TRANSITION_TYPED });
-  }
-  await PlacesTestUtils.addVisits(visits);
-
-  // Make a nsIAutoCompleteController and friends for instrumentation feedback.
-  let thing = {
-    QueryInterface: ChromeUtils.generateQI([Ci.nsIAutoCompleteInput,
-                                            Ci.nsIAutoCompletePopup,
-                                            Ci.nsIAutoCompleteController]),
-    get popup() {
-      return thing;
-    },
-    get controller() {
-      return thing;
-    },
-    popupOpen: true,
-    selectedIndex: 0,
-    getValueAt() {
-      return aURI.spec;
-    },
-    searchString: aSearch,
-  };
-
-  // Bump up the instrumentation feedback.
-  for (let i = 0; i < aRank; i++) {
-    Services.obs.notifyObservers(thing, "autocomplete-will-enter-text");
-  }
-
-  // If this is supposed to be a bookmark, add it.
-  if (aBookmark) {
-    await PlacesUtils.bookmarks.insert({
-      parentGuid: PlacesUtils.bookmarks.unfiledGuid,
-      title: "test_book",
-      url: aURI,
-    });
-
-    // And add the tag if we need to.
-    if (aBookmark == "tag") {
-      PlacesUtils.tagging.tagURI(aURI, ["test_tag"]);
-    }
-  }
-}
-
-/**
- * Decay the adaptive entries by sending the daily idle topic.
- */
-function doAdaptiveDecay() {
-  for (let i = 0; i < 10; i++) {
-    PlacesUtils.history.QueryInterface(Ci.nsIObserver)
-                       .observe(null, "idle-daily", null);
-  }
-}
-
-var uri1 = uri("http://site.tld/1");
-var uri2 = uri("http://site.tld/2");
-
-// d1 is some date for the page visit
-var d1 = new Date(Date.now() - 1000 * 60 * 60) * 1000;
-// c1 is larger (should show up higher) than c2
-var c1 = 10;
-var c2 = 1;
-// s1 is a partial match of s2
-var s0 = "";
-var s1 = "si";
-var s2 = "site";
-
-var observer;
-
-function promiseResultsCompleted() {
-  return new Promise(resolve => {
-    observer = {
-      results: null,
-      search: null,
-      runCount: -1,
-      observe(aSubject, aTopic, aData) {
-        if (--this.runCount > 0)
-          return;
-        ensure_results(this.results, this.search, resolve);
-        Services.obs.removeObserver(observer, PlacesUtils.TOPIC_FEEDBACK_UPDATED);
-      },
-    };
-    Services.obs.addObserver(observer, PlacesUtils.TOPIC_FEEDBACK_UPDATED);
-  });
-}
-
-/**
- * Make the result object for a given URI that will be passed to ensure_results.
- */
-function makeResult(aURI, aStyle = "favicon") {
-  return {
-    uri: aURI,
-    style: aStyle,
-  };
-}
-
-var tests = [
-  // Test things without a search term.
-  async function() {
-    print("Test 0 same count, diff rank, same term; no search");
-    observer.results = [
-      makeResult(uri1),
-      makeResult(uri2),
-    ];
-    observer.search = s0;
-    observer.runCount = c1 + c2;
-    await task_setCountRank(uri1, c1, c1, s2);
-    await task_setCountRank(uri2, c1, c2, s2);
-  },
-  async function() {
-    print("Test 1 same count, diff rank, same term; no search");
-    observer.results = [
-      makeResult(uri2),
-      makeResult(uri1),
-    ];
-    observer.search = s0;
-    observer.runCount = c1 + c2;
-    await task_setCountRank(uri1, c1, c2, s2);
-    await task_setCountRank(uri2, c1, c1, s2);
-  },
-  async function() {
-    print("Test 2 diff count, same rank, same term; no search");
-    observer.results = [
-      makeResult(uri1),
-      makeResult(uri2),
-    ];
-    observer.search = s0;
-    observer.runCount = c1 + c1;
-    await task_setCountRank(uri1, c1, c1, s2);
-    await task_setCountRank(uri2, c2, c1, s2);
-  },
-  async function() {
-    print("Test 3 diff count, same rank, same term; no search");
-    observer.results = [
-      makeResult(uri2),
-      makeResult(uri1),
-    ];
-    observer.search = s0;
-    observer.runCount = c1 + c1;
-    await task_setCountRank(uri1, c2, c1, s2);
-    await task_setCountRank(uri2, c1, c1, s2);
-  },
-
-  // Test things with a search term (exact match one, partial other).
-  async function() {
-    print("Test 4 same count, same rank, diff term; one exact/one partial search");
-    observer.results = [
-      makeResult(uri1),
-      makeResult(uri2),
-    ];
-    observer.search = s1;
-    observer.runCount = c1 + c1;
-    await task_setCountRank(uri1, c1, c1, s1);
-    await task_setCountRank(uri2, c1, c1, s2);
-  },
-  async function() {
-    print("Test 5 same count, same rank, diff term; one exact/one partial search");
-    observer.results = [
-      makeResult(uri2),
-      makeResult(uri1),
-    ];
-    observer.search = s1;
-    observer.runCount = c1 + c1;
-    await task_setCountRank(uri1, c1, c1, s2);
-    await task_setCountRank(uri2, c1, c1, s1);
-  },
-
-  // Test things with a search term (exact match both).
-  async function() {
-    print("Test 6 same count, diff rank, same term; both exact search");
-    observer.results = [
-      makeResult(uri1),
-      makeResult(uri2),
-    ];
-    observer.search = s1;
-    observer.runCount = c1 + c2;
-    await task_setCountRank(uri1, c1, c1, s1);
-    await task_setCountRank(uri2, c1, c2, s1);
-  },
-  async function() {
-    print("Test 7 same count, diff rank, same term; both exact search");
-    observer.results = [
-      makeResult(uri2),
-      makeResult(uri1),
-    ];
-    observer.search = s1;
-    observer.runCount = c1 + c2;
-    await task_setCountRank(uri1, c1, c2, s1);
-    await task_setCountRank(uri2, c1, c1, s1);
-  },
-
-  // Test things with a search term (partial match both).
-  async function() {
-    print("Test 8 same count, diff rank, same term; both partial search");
-    observer.results = [
-      makeResult(uri1),
-      makeResult(uri2),
-    ];
-    observer.search = s1;
-    observer.runCount = c1 + c2;
-    await task_setCountRank(uri1, c1, c1, s2);
-    await task_setCountRank(uri2, c1, c2, s2);
-  },
-  async function() {
-    print("Test 9 same count, diff rank, same term; both partial search");
-    observer.results = [
-      makeResult(uri2),
-      makeResult(uri1),
-    ];
-    observer.search = s1;
-    observer.runCount = c1 + c2;
-    await task_setCountRank(uri1, c1, c2, s2);
-    await task_setCountRank(uri2, c1, c1, s2);
-  },
-  async function() {
-    print("Test 10 same count, same rank, same term, decay first; exact match");
-    observer.results = [
-      makeResult(uri2),
-      makeResult(uri1),
-    ];
-    observer.search = s1;
-    observer.runCount = c1 + c1;
-    await task_setCountRank(uri1, c1, c1, s1);
-    doAdaptiveDecay();
-    await task_setCountRank(uri2, c1, c1, s1);
-  },
-  async function() {
-    print("Test 11 same count, same rank, same term, decay second; exact match");
-    observer.results = [
-      makeResult(uri1),
-      makeResult(uri2),
-    ];
-    observer.search = s1;
-    observer.runCount = c1 + c1;
-    await task_setCountRank(uri2, c1, c1, s1);
-    doAdaptiveDecay();
-    await task_setCountRank(uri1, c1, c1, s1);
-  },
-  // Test that bookmarks are hidden if the preferences are set right.
-  async function() {
-    print("Test 12 same count, diff rank, same term; no search; history only");
-    Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
-    Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", false);
-    Services.prefs.setBoolPref("browser.urlbar.suggest.openpage", false);
-    observer.results = [
-      makeResult(uri1),
-      makeResult(uri2),
-    ];
-    observer.search = s0;
-    observer.runCount = c1 + c2;
-    await task_setCountRank(uri1, c1, c1, s2, "bookmark");
-    await task_setCountRank(uri2, c1, c2, s2);
-  },
-  // Test that tags are shown if the preferences are set right.
-  async function() {
-    print("Test 13 same count, diff rank, same term; no search; history only with tag");
-    Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
-    Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", false);
-    Services.prefs.setBoolPref("browser.urlbar.suggest.openpage", false);
-    observer.results = [
-      makeResult(uri1, "tag"),
-      makeResult(uri2),
-    ];
-    observer.search = s0;
-    observer.runCount = c1 + c2;
-    await task_setCountRank(uri1, c1, c1, s2, "tag");
-    await task_setCountRank(uri2, c1, c2, s2);
-  },
-  // Test that many results are all shown if no other results are available.
-  async function() {
-    print("Test 14 -  many results");
-    let n = 10;
-    observer.results = Array(n).fill(0).map(
-      (e, i) => makeResult(Services.io.newURI("http://site.tld/" + i))
-    );
-    observer.search = s2;
-    observer.runCount = n * (n + 1) / 2;
-    let c = n;
-    for (let result of observer.results) {
-      task_setCountRank(result.uri, c, c, s2);
-      c--;
-    }
-  },
-];
-
-/**
- * Test adaptive autocomplete.
- */
-add_task(async function test_adaptive() {
-  // Disable autoFill for this test.
-  Services.prefs.setBoolPref("browser.urlbar.autoFill", false);
-
-  registerCleanupFunction(async function() {
-    await PlacesUtils.bookmarks.eraseEverything();
-    await PlacesUtils.history.clear();
-  });
-
-  for (let test of tests) {
-    // Cleanup.
-    await PlacesUtils.bookmarks.eraseEverything();
-
-    let types = ["history", "bookmark", "openpage"];
-    for (let type of types) {
-      Services.prefs.clearUserPref("browser.urlbar.suggest." + type);
-    }
-
-    await PlacesUtils.history.clear();
-
-    let resultsCompletedPromise = promiseResultsCompleted();
-    await test();
-    await resultsCompletedPromise;
-  }
-});
deleted file mode 100644
--- a/toolkit/components/places/tests/unifiedcomplete/test_adaptive_behaviors.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- 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/. */
-
-// Test for Bug 527311
-// Addressbar suggests adaptive results regardless of the requested behavior.
-
-const TEST_URL = "http://adapt.mozilla.org/";
-const SEARCH_STRING = "adapt";
-const SUGGEST_TYPES = ["history", "bookmark", "openpage"];
-
-add_task(async function test_adaptive_search_specific() {
-  Services.prefs.setBoolPref("browser.urlbar.autoFill", false);
-
-  // Add a bookmark to our url.
-  await PlacesUtils.bookmarks.insert({
-    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
-    title: "test_book",
-    url: TEST_URL,
-  });
-  registerCleanupFunction(async function() {
-    await PlacesUtils.bookmarks.eraseEverything();
-  });
-
-  // We want to search only history.
-  for (let type of SUGGEST_TYPES) {
-    type == "history" ? Services.prefs.setBoolPref("browser.urlbar.suggest." + type, true)
-                      : Services.prefs.setBoolPref("browser.urlbar.suggest." + type, false);
-  }
-
-  // Add an adaptive entry.
-  await addAdaptiveFeedback(TEST_URL, SEARCH_STRING);
-
-  await check_autocomplete({
-    search: SEARCH_STRING,
-    matches: [],
-  });
-});
deleted file mode 100644
--- a/toolkit/components/places/tests/unifiedcomplete/test_adaptive_limited.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Test that top adaptive results are limited, remaining ones are enqueued.
-
-add_task(async function() {
-  Services.prefs.setBoolPref("browser.urlbar.autoFill", false);
-
-  let n = 10;
-  let uris = Array(n).fill(0).map((e, i) => "http://site.tld/" + i);
-
-  // Add a bookmark to one url.
-  let bm = await PlacesUtils.bookmarks.insert({
-    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
-    title: "test_book",
-    url: uris.shift(),
-  });
-
-  // Make remaining ones adaptive results.
-  for (let uri of uris) {
-    await PlacesTestUtils.addVisits(uri);
-    await addAdaptiveFeedback(uri, "book");
-  }
-
-  registerCleanupFunction(async function() {
-    await PlacesUtils.bookmarks.eraseEverything();
-    await PlacesUtils.history.clear();
-  });
-
-  let matches = uris.map(uri => ({ uri: Services.io.newURI(uri),
-                                   title: "test visit for " + uri }));
-  let book_index = Math.ceil(Services.prefs.getIntPref("browser.urlbar.maxRichResults", 10) / 4);
-  matches.splice(book_index, 0, { uri: Services.io.newURI(bm.url.href),
-                                  title: "test_book", "style": ["bookmark"] });
-
-  await check_autocomplete({
-    search: "book",
-    matches,
-    checkSorting: true,
-  });
-});
--- a/toolkit/components/places/tests/unifiedcomplete/xpcshell.ini
+++ b/toolkit/components/places/tests/unifiedcomplete/xpcshell.ini
@@ -9,19 +9,16 @@ support-files =
   !/toolkit/components/places/tests/favicons/favicon-normal16.png
   autofill_tasks.js
 
 [test_416211.js]
 [test_416214.js]
 [test_417798.js]
 [test_418257.js]
 [test_422277.js]
-[test_adaptive.js]
-[test_adaptive_behaviors.js]
-[test_adaptive_limited.js]
 [test_autocomplete_functional.js]
 [test_autocomplete_stopSearch_no_throw.js]
 [test_autofill_about_urls.js]
 [test_autofill_origins.js]
 [test_autofill_search_engine_aliases.js]
 [test_autofill_search_engines.js]
 [test_autofill_urls.js]
 [test_avoid_middle_complete.js]