Bug 1162830 - unified auto-complete tests now check what the default item is. r=mak
authorMark Hammond <mhammond@skippinet.com.au>
Thu, 28 May 2015 17:21:58 +1000
changeset 246026 e8c888dc33c1097d965685c11f97ceefb8713004
parent 246025 e67ddc64b010aadfcfcd54e63f841bbc7e0b6882
child 246027 4c78329ad9704563485ed14f4a7e6979c090d299
push id60333
push userryanvm@gmail.com
push dateThu, 28 May 2015 14:20:47 +0000
treeherdermozilla-inbound@8225a3b75df6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1162830
milestone41.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 1162830 - unified auto-complete tests now check what the default item is. r=mak
toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
toolkit/components/places/tests/unifiedcomplete/test_empty_search.js
toolkit/components/places/tests/unifiedcomplete/test_searchEngine_alias.js
toolkit/components/places/tests/unifiedcomplete/test_searchEngine_current.js
toolkit/components/places/tests/unifiedcomplete/test_tabmatches.js
toolkit/components/places/tests/unifiedcomplete/test_visiturl.js
--- a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
+++ b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
@@ -92,16 +92,44 @@ AutoCompleteInput.prototype = {
   onSearchComplete: function () {},
 
   onTextEntered: function() false,
   onTextReverted: function() false,
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompleteInput])
 }
 
+// A helper for check_autocomplete to check a specific match against data from
+// the controller.
+function _check_autocomplete_matches(match, controllerInfo) {
+  let { uri, title, tags, searchEngine, style } = match;
+  let { controllerValue, controllerComment, controllerStyle } = controllerInfo;
+  if (tags)
+    title += " \u2013 " + tags.sort().join(", ");
+  if (searchEngine)
+    title += TITLE_SEARCH_ENGINE_SEPARATOR + searchEngine;
+  if (style)
+    style = style.sort();
+  else
+    style = ["favicon"];
+
+  do_print("Checking against expected '" + uri.spec + "', '" + title + "'...");
+  // Got a match on both uri and title?
+  if (stripPrefix(uri.spec) != stripPrefix(controllerValue) || title != controllerComment) {
+    return false;
+  }
+  let actualStyle = controllerStyle.split(/\s+/).sort();
+  if (style)
+    Assert.equal(actualStyle.toString(), style.toString(), "Match should have expected style");
+  if (uri.spec.startsWith("moz-action:")) {
+    Assert.ok(actualStyle.indexOf("action") != -1, "moz-action results should always have 'action' in their style");
+  }
+  return true;
+}
+
 function* check_autocomplete(test) {
   // At this point frecency could still be updating due to latest pages
   // updates.
   // This is not a problem in real life, but autocomplete tests should
   // return reliable resultsets, thus we have to wait.
   yield PlacesTestUtils.promiseAsyncUpdates();
 
   // Make an AutoCompleteInput that uses our searches and confirms results.
@@ -138,61 +166,60 @@ function* check_autocomplete(test) {
     expectedSearches++;
   }
   do_print("Searching for: '" + test.search + "'");
   controller.startSearch(test.search);
   yield deferred.promise;
 
   Assert.equal(numSearchesStarted, expectedSearches, "All searches started");
 
-  // Check to see the expected uris and titles match up (in any order)
+  // Check to see the expected uris and titles match up. If 'enable-actions'
+  // is specified, we check that the first specified match is the first
+  // controller value (as this is the "special" always selected item), but the
+  // rest can match in any order.
+  // If 'enable-actions' is not specified, they can match in any order.
   if (test.matches) {
     // Do not modify the test original matches.
     let matches = test.matches.slice();
 
-    for (let i = 0; i < controller.matchCount; i++) {
-      let value = controller.getValueAt(i);
-      let comment = controller.getCommentAt(i);
-      do_print("Looking for '" + value + "', '" + comment + "' in expected results...");
+    let firstIndexToCheck = 0;
+    if (test.searchParam && test.searchParam == "enable-actions") {
+      firstIndexToCheck = 1;
+      do_print("Checking first match is first autocomplete entry")
+      let controllerValue = controller.getValueAt(0);
+      let controllerComment = controller.getCommentAt(0);
+      let controllerStyle = controller.getStyleAt(0);
+      do_print("First match is '" + controllerValue + "', '" + controllerComment + "");
+      let controllerInfo = { controllerValue, controllerComment, controllerStyle };
+      Assert.ok(_check_autocomplete_matches(matches[0], controllerInfo), "first item is correct");
+      do_print("Checking rest of the matches");
+    }
+
+    for (let i = firstIndexToCheck; i < controller.matchCount; i++) {
+      let controllerValue = controller.getValueAt(i);
+      let controllerComment = controller.getCommentAt(i);
+      let controllerStyle = controller.getStyleAt(i);
+      let controllerInfo = { controllerValue, controllerComment, controllerStyle };
+      do_print("Looking for '" + controllerValue + "', '" + controllerComment + "' in expected results...");
       let j;
-      for (j = 0; j < matches.length; j++) {
+      for (j = firstIndexToCheck; j < matches.length; j++) {
         // Skip processed expected results
         if (matches[j] == undefined)
           continue;
-
-        let { uri, title, tags, searchEngine, style } = matches[j];
-        if (tags)
-          title += " \u2013 " + tags.sort().join(", ");
-        if (searchEngine)
-          title += TITLE_SEARCH_ENGINE_SEPARATOR + searchEngine;
-        if (style)
-          style = style.sort();
-        else
-          style = ["favicon"];
-
-        do_print("Checking against expected '" + uri.spec + "', '" + title + "'...");
-        // Got a match on both uri and title?
-        if (stripPrefix(uri.spec) == stripPrefix(value) && title == comment) {
+        if (_check_autocomplete_matches(matches[j], controllerInfo)) {
           do_print("Got a match at index " + j + "!");
-          let actualStyle = controller.getStyleAt(i).split(/\s+/).sort();
-          if (style)
-            Assert.equal(actualStyle.toString(), style.toString(), "Match should have expected style");
-
           // Make it undefined so we don't process it again
           matches[j] = undefined;
-          if (uri.spec.startsWith("moz-action:")) {
-            Assert.ok(actualStyle.indexOf("action") != -1, "moz-action results should always have 'action' in their style");
-          }
           break;
         }
       }
 
       // We didn't hit the break, so we must have not found it
       if (j == matches.length)
-        do_throw("Didn't find the current result ('" + value + "', '" + comment + "') in matches");
+        do_throw("Didn't find the current result ('" + controllerValue + "', '" + controllerComment + "') in matches");
     }
 
     Assert.equal(controller.matchCount, matches.length,
                  "Got as many results as expected");
 
     // If we expect results, make sure we got matches.
     do_check_eq(controller.searchStatus, matches.length ?
                 Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH :
@@ -297,16 +324,60 @@ function stripPrefix(spec)
   return spec;
 }
 
 function makeActionURI(action, params) {
   let url = "moz-action:" + action + "," + JSON.stringify(params);
   return NetUtil.newURI(url);
 }
 
+// Creates a full "match" entry for a search result, suitable for passing as
+// an entry to check_autocomplete.
+function makeSearchMatch(input, extra = {}) {
+  // Note that counter-intuitively, the order the object properties are defined
+  // in the object passed to makeActionURI is important for check_autocomplete
+  // to match them :(
+  let params = {
+    engineName: extra.engineName || "MozSearch",
+    input,
+    searchQuery: extra.searchQuery || input,
+    alias: extra.alias, // may be undefined which is expected.
+  }
+  return {
+    uri: makeActionURI("searchengine", params),
+    title: params.engineName,
+    style: [ "action", "searchengine" ],
+  }
+}
+
+// Creates a full "match" entry for a search result, suitable for passing as
+// an entry to check_autocomplete.
+function makeVisitMatch(input, url, extra = {}) {
+  // Note that counter-intuitively, the order the object properties are defined
+  // in the object passed to makeActionURI is important for check_autocomplete
+  // to match them :(
+  let params = {
+    url,
+    input,
+  }
+  return {
+    uri: makeActionURI("visiturl", params),
+    title: extra.title || url,
+    style: [ "action", "visiturl" ],
+  }
+}
+
+function makeSwitchToTabMatch(url, extra = {}) {
+  return {
+    uri: makeActionURI("switchtab", {url}),
+    title: extra.title || url,
+    style: [ "action", "switchtab" ],
+  }
+}
+
 // Ensure we have a default search engine and the keyword.enabled preference
 // set.
 add_task(function ensure_search_engine() {
   // keyword.enabled is necessary for the tests to see keyword searches.
   Services.prefs.setBoolPref("keyword.enabled", true);
 
   // Remove any existing engines before adding ours.
   for (let engine of Services.search.getEngines()) {
--- a/toolkit/components/places/tests/unifiedcomplete/test_empty_search.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_empty_search.js
@@ -38,24 +38,24 @@ add_task(function* test_javascript_match
 
   // Now remove page 6 from history, so it is an unvisited bookmark.
   PlacesUtils.history.removePage(uri6);
 
   do_print("Match everything");
   yield check_autocomplete({
     search: "foo",
     searchParam: "enable-actions",
-    matches: [ { uri: uri1, title: "title" },
+    matches: [ makeSearchMatch("foo"),
+               { 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: makeActionURI("switchtab", {url: "http://t.foo/6"}), title: "title", style: [ "action,switchtab" ] },
-               { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "foo", searchQuery: "foo"}), title: "MozSearch", style: [ "action", "searchengine" ] },
+               makeSwitchToTabMatch("http://t.foo/6", { title: "title" }),
              ]
   });
 
   // Note the next few tests do *not* get a search result as enable-actions
   // isn't specified.
   do_print("Match only typed history");
   yield check_autocomplete({
     search: "foo ^ ~",
@@ -82,18 +82,18 @@ add_task(function* test_javascript_match
   });
 
   do_print("Drop-down empty search matches only open tabs");
   Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", false);
   yield check_autocomplete({
     search: "",
     searchParam: "enable-actions",
     matches: [
-               { uri: makeActionURI("switchtab", {url: "http://t.foo/6"}), title: "title", style: [ "action,switchtab" ] },
-               { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "", searchQuery: ""}), title: "MozSearch", style: [ "action", "searchengine" ] },
+               makeSearchMatch(""),
+               makeSwitchToTabMatch("http://t.foo/6", { 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_searchEngine_alias.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_alias.js
@@ -7,25 +7,25 @@ add_task(function*() {
   // Here we add another engine with a search alias.
   Services.search.addEngineWithDetails("AliasedMozSearch", "", "doit", "",
                                        "GET", "http://s.example.com/search");
 
 
   yield check_autocomplete({
     search: "doit",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "doit", searchQuery: "doit"}), title: "MozSearch", style: [ "action", "searchengine" ] }, ]
+    matches: [ makeSearchMatch("doit") ]
   });
 
   yield check_autocomplete({
     search: "doit mozilla",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "AliasedMozSearch", input: "doit mozilla", searchQuery: "mozilla", alias: "doit"}), title: "AliasedMozSearch", style: [ "action", "searchengine" ] }, ]
+    matches: [ makeSearchMatch("doit mozilla", { engineName: "AliasedMozSearch", searchQuery: "mozilla", alias: "doit" }) ]
   });
 
   yield check_autocomplete({
     search: "doit mozzarella mozilla",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "AliasedMozSearch", input: "doit mozzarella mozilla", searchQuery: "mozzarella mozilla", alias: "doit"}), title: "AliasedMozSearch", style: [ "action", "searchengine" ] }, ]
+    matches: [ makeSearchMatch("doit mozzarella mozilla", { engineName: "AliasedMozSearch", searchQuery: "mozzarella mozilla", alias: "doit" }) ]
   });
 
   yield cleanup();
 });
--- a/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_current.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_current.js
@@ -7,39 +7,39 @@ add_task(function*() {
   // Here we add another engine with a search alias.
   Services.search.addEngineWithDetails("AliasedMozSearch", "", "doit", "",
                                        "GET", "http://s.example.com/search");
 
   do_print("search engine");
   yield check_autocomplete({
     search: "mozilla",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "mozilla", searchQuery: "mozilla"}), title: "MozSearch", style: [ "action", "searchengine" ] }, ]
+    matches: [ makeSearchMatch("mozilla") ]
   });
 
   do_print("search engine, uri-like input");
   yield check_autocomplete({
     search: "http:///",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "http:///", searchQuery: "http:///"}), title: "MozSearch", style: [ "action", "searchengine" ] }, ]
+    matches: [ makeSearchMatch("http:///") ]
   });
 
   do_print("search engine, multiple words");
   yield check_autocomplete({
     search: "mozzarella cheese",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "mozzarella cheese", searchQuery: "mozzarella cheese"}), title: "MozSearch", style: [ "action", "searchengine" ] }, ]
+    matches: [ makeSearchMatch("mozzarella cheese") ]
   });
 
   do_print("search engine, after current engine has changed");
   Services.search.addEngineWithDetails("MozSearch2", "", "", "", "GET",
                                        "http://s.example.com/search2");
   engine = Services.search.getEngineByName("MozSearch2");
   notEqual(Services.search.currentEngine, engine, "New engine shouldn't be the current engine yet");
   Services.search.currentEngine = engine;
   yield check_autocomplete({
     search: "mozilla",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch2", input: "mozilla", searchQuery: "mozilla"}), title: "MozSearch2", style: [ "action", "searchengine" ] }, ]
+    matches: [ makeSearchMatch("mozilla", { engineName: "MozSearch2" }) ]
   });
 
   yield cleanup();
 });
--- a/toolkit/components/places/tests/unifiedcomplete/test_tabmatches.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_tabmatches.js
@@ -19,54 +19,54 @@ add_task(function* test_tab_matches() {
   // Pages that cannot be registered in history.
   addOpenPages(uri3, 1);
   addOpenPages(uri4, 1);
 
   do_print("two results, normal result is a tab match");
   yield check_autocomplete({
     search: "abc.com",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("visiturl", {url: "http://abc.com/", input: "abc.com"}), title: "http://abc.com/", style: [ "action", "visiturl" ] },
-               { uri: makeActionURI("switchtab", {url: "http://abc.com/"}), title: "ABC rocks", style: [ "action", "switchtab" ] } ]
+    matches: [ makeVisitMatch("abc.com", "http://abc.com/"),
+               makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }) ]
   });
 
   do_print("three results, one tab match");
   yield check_autocomplete({
     search: "abc",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "abc", searchQuery: "abc"}), title: "MozSearch", style: [ "action", "searchengine" ] },
-               { uri: makeActionURI("switchtab", {url: "http://abc.com/"}), title: "ABC rocks", style: [ "action", "switchtab" ] },
+    matches: [ makeSearchMatch("abc"),
+               makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
                { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
   });
 
   do_print("three results, both normal results are tab matches");
   addOpenPages(uri2, 1);
   yield check_autocomplete({
     search: "abc",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "abc", searchQuery: "abc"}), title: "MozSearch", style: [ "action", "searchengine" ] },
-               { uri: makeActionURI("switchtab", {url: "http://abc.com/"}), title: "ABC rocks", style: [ "action", "switchtab" ] },
-               { uri: makeActionURI("switchtab", {url: "http://xyz.net/"}), title: "xyz.net - we're better than ABC", style: [ "action", "switchtab" ] } ]
+    matches: [ makeSearchMatch("abc"),
+               makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
+               makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }) ]
   });
 
   do_print("three results, both normal results are tab matches, one has multiple tabs");
   addOpenPages(uri2, 5);
   yield check_autocomplete({
     search: "abc",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "abc", searchQuery: "abc"}), title: "MozSearch", style: [ "action", "searchengine" ] },
-               { uri: makeActionURI("switchtab", {url: "http://abc.com/"}), title: "ABC rocks", style: [ "action", "switchtab" ] },
-               { uri: makeActionURI("switchtab", {url: "http://xyz.net/"}), title: "xyz.net - we're better than ABC", style: [ "action", "switchtab" ] } ]
+    matches: [ makeSearchMatch("abc"),
+               makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
+               makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }) ]
   });
 
   do_print("three results, no tab matches (disable-private-actions)");
   yield check_autocomplete({
     search: "abc",
     searchParam: "enable-actions disable-private-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "abc", searchQuery: "abc"}), title: "MozSearch", style: [ "action", "searchengine" ] },
+    matches: [ makeSearchMatch("abc"),
                { uri: uri1, title: "ABC rocks", style: [ "favicon" ] },
                { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
   });
 
   do_print("two results (actions disabled)");
   yield check_autocomplete({
     search: "abc",
     searchParam: "",
@@ -75,50 +75,50 @@ add_task(function* test_tab_matches() {
   });
 
   do_print("three results, no tab matches");
   removeOpenPages(uri1, 1);
   removeOpenPages(uri2, 6);
   yield check_autocomplete({
     search: "abc",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "abc", searchQuery: "abc"}), title: "MozSearch", style: [ "action", "searchengine" ] },
+    matches: [ makeSearchMatch("abc"),
                { uri: uri1, title: "ABC rocks", style: [ "favicon" ] },
                { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
   });
 
   do_print("tab match search with restriction character");
   addOpenPages(uri1, 1);
   yield check_autocomplete({
     search: gTabRestrictChar + " abc",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: gTabRestrictChar + " abc", searchQuery: gTabRestrictChar + " abc"}), title: "MozSearch", style: [ "action", "searchengine" ] },
-               { uri: makeActionURI("switchtab", {url: "http://abc.com/"}), title: "ABC rocks", style: [ "action", "switchtab" ] } ]
+    matches: [ makeSearchMatch(gTabRestrictChar + " abc"),
+               makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }) ]
   });
 
   do_print("tab match with not-addable pages");
   yield check_autocomplete({
     search: "mozilla",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "mozilla", searchQuery: "mozilla"}), title: "MozSearch", style: [ "action", "searchengine" ] },
-               { uri: makeActionURI("switchtab", {url: "about:mozilla"}), title: "about:mozilla", style: [ "action", "switchtab" ] } ]
+    matches: [ makeSearchMatch("mozilla"),
+               makeSwitchToTabMatch("about:mozilla") ]
   });
 
   do_print("tab match with not-addable pages and restriction character");
   yield check_autocomplete({
     search: gTabRestrictChar + " mozilla",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: gTabRestrictChar + " mozilla", searchQuery: gTabRestrictChar + " mozilla"}), title: "MozSearch", style: [ "action", "searchengine" ] },
-               { uri: makeActionURI("switchtab", {url: "about:mozilla"}), title: "about:mozilla", style: [ "action", "switchtab" ] } ]
+    matches: [ makeSearchMatch(gTabRestrictChar + " mozilla"),
+               makeSwitchToTabMatch("about:mozilla") ]
   });
 
   do_print("tab match with not-addable pages and only restriction character");
   yield check_autocomplete({
     search: gTabRestrictChar,
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: gTabRestrictChar, searchQuery: gTabRestrictChar}), title: "MozSearch", style: [ "action", "searchengine" ] },
-               { uri: makeActionURI("switchtab", {url: "http://abc.com/"}), title: "ABC rocks", style: [ "action", "switchtab" ] },
-               { uri: makeActionURI("switchtab", {url: "about:mozilla"}), title: "about:mozilla", style: [ "action", "switchtab" ] },
-               { uri: makeActionURI("switchtab", {url: "data:text/html,test"}), title: "data:text/html,test", style: [ "action", "switchtab" ] } ]
+    matches: [ makeSearchMatch(gTabRestrictChar),
+               makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
+               makeSwitchToTabMatch("about:mozilla"),
+               makeSwitchToTabMatch("data:text/html,test") ]
   });
 
   yield cleanup();
 });
--- a/toolkit/components/places/tests/unifiedcomplete/test_visiturl.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_visiturl.js
@@ -28,37 +28,37 @@ add_task(function*() {
   // host lookups.
   do_print("visit url, host matching visited host but not visited url");
   yield PlacesTestUtils.addVisits([
     { uri: NetUtil.newURI("http://mozilla.org/wine/"), title: "Mozilla Wine", transition: TRANSITION_TYPED },
   ]);
   yield check_autocomplete({
     search: "mozilla.org/rum",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("visiturl", {url: "http://mozilla.org/rum", input: "mozilla.org/rum"}), title: "http://mozilla.org/rum", style: [ "action", "visiturl" ] } ]
+    matches: [ makeVisitMatch("mozilla.org/rum", "http://mozilla.org/rum") ]
   });
 
   // And hosts with no dot in them are special, due to requiring whitelisting.
   do_print("visit url, host matching visited host but not visited url, non-whitelisted host");
   yield PlacesTestUtils.addVisits([
     { uri: NetUtil.newURI("http://mozilla/bourbon/"), title: "Mozilla Bourbon", transition: TRANSITION_TYPED },
   ]);
   yield check_autocomplete({
     search: "mozilla/rum",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "mozilla/rum", searchQuery: "mozilla/rum"}), title: "MozSearch", style: [ "action", "searchengine" ] } ]
+    matches: [ makeSearchMatch("mozilla/rum") ]
   });
 
   // ipv4 and ipv6 literal addresses should offer to visit.
   do_print("visit url, ipv4 literal");
   yield check_autocomplete({
     search: "127.0.0.1",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("visiturl", {url: "http://127.0.0.1/", input: "127.0.0.1"}), title: "http://127.0.0.1/", style: ["action", "visiturl"] } ]
+    matches: [ makeVisitMatch("127.0.0.1", "http://127.0.0.1/") ]
   });
 
   do_print("visit url, ipv6 literal");
   yield check_autocomplete({
     search: "[2001:db8::1]",
     searchParam: "enable-actions",
-    matches: [ { uri: makeActionURI("visiturl", {url: "http://[2001:db8::1]/", input: "[2001:db8::1]"}), title: "http://[2001:db8::1]/", style: ["action", "visiturl"] } ]
+    matches: [ makeVisitMatch("[2001:db8::1]", "http://[2001:db8::1]/") ]
   });
 });