Bug 1499743 - Change the url and search restriction characters in the Address Bar. r=adw a=jcristau
authorMarco Bonardo <mbonardo@mozilla.com>
Thu, 08 Nov 2018 18:29:33 +0100
changeset 501147 aca73ccfac914d9659470c4c257ceb049b5603b6
parent 501146 1c5b308487dcd3b785d5f910ea4b736e8aad0bf1
child 501148 9d0a1d23a7644e2e066ca1913854ad14d74af35b
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw, jcristau
bugs1499743
milestone64.0
Bug 1499743 - Change the url and search restriction characters in the Address Bar. r=adw a=jcristau
browser/base/content/test/urlbar/browser_urlbarStopSearchOnSelection.js
browser/base/content/test/urlbar/head.js
browser/components/urlbar/UrlbarTokenizer.jsm
browser/components/urlbar/tests/unit/test_tokenizer.js
toolkit/components/places/UnifiedComplete.js
toolkit/components/places/tests/unifiedcomplete/test_search_suggestions.js
toolkit/components/places/tests/unifiedcomplete/test_special_search.js
--- a/browser/base/content/test/urlbar/browser_urlbarStopSearchOnSelection.js
+++ b/browser/base/content/test/urlbar/browser_urlbarStopSearchOnSelection.js
@@ -29,19 +29,18 @@ add_task(async function init() {
     await PlacesUtils.history.clear();
     // Make sure the popup is closed for the next test.
     gURLBar.blur();
     Assert.ok(!gURLBar.popup.popupOpen, "popup should be closed");
   });
 });
 
 add_task(async function mainTest() {
-  // Trigger an initial search.  Use the "$" token to restrict matches to search
-  // suggestions.
-  await promiseAutocompleteResultPopup("$ test", window);
+  // Trigger an initial search.  Restrict matches to search suggestions.
+  await promiseAutocompleteResultPopup("? test", window);
   await promiseSuggestionsPresent("Waiting for initial suggestions");
 
   // Now synthesize typing a character.  promiseAutocompleteResultPopup doesn't
   // work in this case because it causes the popup to close and re-open with the
   // new input text.
   await new Promise(r => EventUtils.synthesizeKey("x", {}, window, r));
 
   // At this point, a new search starts, the autocomplete's _invalidate is
--- a/browser/base/content/test/urlbar/head.js
+++ b/browser/base/content/test/urlbar/head.js
@@ -1,22 +1,19 @@
 /* eslint-env mozilla/frame-script */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-ChromeUtils.defineModuleGetter(this, "PlacesUtils",
-  "resource://gre/modules/PlacesUtils.jsm");
-ChromeUtils.defineModuleGetter(this, "PlacesTestUtils",
-  "resource://testing-common/PlacesTestUtils.jsm");
-ChromeUtils.defineModuleGetter(this, "Preferences",
-  "resource://gre/modules/Preferences.jsm");
-ChromeUtils.defineModuleGetter(this, "HttpServer",
-  "resource://testing-common/httpd.js");
-ChromeUtils.defineModuleGetter(this, "SearchTestUtils",
-  "resource://testing-common/SearchTestUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, {
+  HttpServer: "resource://testing-common/httpd.js",
+  PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
+  PlacesTestUtils: "resource://testing-common/PlacesTestUtils.jsm",
+  Preferences: "resource://gre/modules/Preferences.jsm",
+  SearchTestUtils: "resource://testing-common/SearchTestUtils.jsm",
+});
 
 SearchTestUtils.init(Assert, registerCleanupFunction);
 
 /**
  * Waits for the next top-level document load in the current browser.  The URI
  * of the document is compared against aExpectedURL.  The load is then stopped
  * before it actually starts.
  *
--- a/browser/components/urlbar/UrlbarTokenizer.jsm
+++ b/browser/components/urlbar/UrlbarTokenizer.jsm
@@ -175,19 +175,19 @@ var UrlbarTokenizer = {
 // provided their meaning cannot be confused, for example # could be present
 // in a valid url, and thus it should not be interpreted as a restriction.
 UrlbarTokenizer.CHAR_TO_TYPE_MAP = new Map([
   ["^", UrlbarTokenizer.TYPE.RESTRICT_HISTORY],
   ["*", UrlbarTokenizer.TYPE.RESTRICT_BOOKMARK],
   ["+", UrlbarTokenizer.TYPE.RESTRICT_TAG],
   ["%", UrlbarTokenizer.TYPE.RESTRICT_OPENPAGE],
   ["~", UrlbarTokenizer.TYPE.RESTRICT_TYPED],
-  ["$", UrlbarTokenizer.TYPE.RESTRICT_SEARCH],
+  ["?", UrlbarTokenizer.TYPE.RESTRICT_SEARCH],
   ["#", UrlbarTokenizer.TYPE.RESTRICT_TITLE],
-  ["@", UrlbarTokenizer.TYPE.RESTRICT_URL],
+  ["$", UrlbarTokenizer.TYPE.RESTRICT_URL],
 ]);
 
 /**
  * Given a search string, splits it into string tokens.
  * @param {string} searchString
  *        The search string to split
  * @returns {array} An array of string tokens.
  */
--- a/browser/components/urlbar/tests/unit/test_tokenizer.js
+++ b/browser/components/urlbar/tests/unit/test_tokenizer.js
@@ -48,20 +48,20 @@ add_task(async function test_tokenizer()
     { desc: "double boundary restriction char",
       searchString: "*test#",
       expectedTokens: [
         { value: "*", type: UrlbarTokenizer.TYPE.RESTRICT_BOOKMARK },
         { value: "test#", type: UrlbarTokenizer.TYPE.TEXT },
       ],
     },
     { desc: "double non-combinable restriction char, single char string",
-      searchString: "t*$",
+      searchString: "t*?",
       expectedTokens: [
         { value: "t*", type: UrlbarTokenizer.TYPE.TEXT },
-        { value: "$", type: UrlbarTokenizer.TYPE.RESTRICT_SEARCH },
+        { value: "?", type: UrlbarTokenizer.TYPE.RESTRICT_SEARCH },
       ],
     },
     { desc: "only boundary restriction chars",
       searchString: "*#",
       expectedTokens: [
         { value: "*", type: UrlbarTokenizer.TYPE.RESTRICT_BOOKMARK },
         { value: "#", type: UrlbarTokenizer.TYPE.RESTRICT_TITLE },
       ],
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -82,19 +82,19 @@ const QUERYINDEX_FRECENCY      = 10;
 // the search to visited history, bookmarked, tagged pages; or force a match on
 // just the title text or url.
 const TOKEN_TO_BEHAVIOR_MAP = new Map([
   ["^", "history"],
   ["*", "bookmark"],
   ["+", "tag"],
   ["%", "openpage"],
   ["~", "typed"],
-  ["$", "searches"],
+  ["?", "searches"],
   ["#", "title"],
-  ["@", "url"],
+  ["$", "url"],
 ]);
 
 // If a URL starts with one of these prefixes, then we don't provide search
 // suggestions for it.
 const DISALLOWED_URLLIKE_PREFIXES = [
   "http", "https", "ftp",
 ];
 
--- a/toolkit/components/places/tests/unifiedcomplete/test_search_suggestions.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_search_suggestions.js
@@ -1,16 +1,16 @@
 ChromeUtils.import("resource://gre/modules/FormHistory.jsm");
 
 const ENGINE_NAME = "engine-suggestions.xml";
 // This is fixed to match the port number in engine-suggestions.xml.
 const SERVER_PORT = 9000;
 const SUGGEST_PREF = "browser.urlbar.suggest.searches";
 const SUGGEST_ENABLED_PREF = "browser.search.suggest.enabled";
-const SUGGEST_RESTRICT_TOKEN = "$";
+const SUGGEST_RESTRICT_TOKEN = "?";
 
 var suggestionsFn;
 var previousSuggestionsFn;
 
 function setSuggestionsFn(fn) {
   previousSuggestionsFn = suggestionsFn;
   suggestionsFn = fn;
 }
--- a/toolkit/components/places/tests/unifiedcomplete/test_special_search.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_special_search.js
@@ -142,19 +142,19 @@ add_task(async function test_special_sea
                { uri: uri6, title: "foo.bar", 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" ] } ],
   });
 
-  info("foo @ -> in url");
+  info("foo $ -> in url");
   await check_autocomplete({
-    search: "foo @",
+    search: "foo $",
     matches: [ { uri: uri3, title: "title" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri7, title: "title", style: [ "bookmark" ] },
                { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
                { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] } ],
   });
 
@@ -186,19 +186,19 @@ add_task(async function test_special_sea
   await check_autocomplete({
     search: "foo ^ #",
     matches: [ { uri: uri2, title: "foo.bar" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri6, title: "foo.bar" },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ],
   });
 
-  info("foo ^ @ -> history, in url");
+  info("foo ^ $ -> history, in url");
   await check_autocomplete({
-    search: "foo ^ @",
+    search: "foo ^ $",
     matches: [ { uri: uri3, title: "title" },
                { uri: uri4, title: "foo.bar" },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ],
   });
 
   info("foo ^ + -> history, is tag");
   await check_autocomplete({
     search: "foo ^ +",
@@ -218,19 +218,19 @@ add_task(async function test_special_sea
     matches: [ { uri: uri6, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri9, title: "title", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
                { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
                { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] } ],
   });
 
-  info("foo * @ -> is star, in url");
+  info("foo * $ -> is star, in url");
   await check_autocomplete({
-    search: "foo * @",
+    search: "foo * $",
     matches: [ { uri: uri7, title: "title", style: [ "bookmark" ] },
                { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
                { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] } ],
   });
 
   info("foo * + -> same as +");
   await check_autocomplete({
@@ -242,19 +242,19 @@ add_task(async function test_special_sea
   });
 
   info("foo * ~ -> is star, is typed");
   await check_autocomplete({
     search: "foo * ~",
     matches: [ { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] } ],
   });
 
-  info("foo # @ -> in title, in url");
+  info("foo # $ -> in title, in url");
   await check_autocomplete({
-    search: "foo # @",
+    search: "foo # $",
     matches: [ { uri: uri4, title: "foo.bar" },
                { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
                { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] } ],
   });
 
   info("foo # + -> in title, is tag");
   await check_autocomplete({
@@ -267,26 +267,26 @@ add_task(async function test_special_sea
 
   info("foo # ~ -> in title, is typed");
   await check_autocomplete({
     search: "foo # ~",
     matches: [ { uri: uri4, title: "foo.bar" },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ],
   });
 
-  info("foo @ + -> in url, is tag");
+  info("foo $ + -> in url, is tag");
   await check_autocomplete({
-    search: "foo @ +",
+    search: "foo $ +",
     matches: [ { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] },
                { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "tag" ] } ],
   });
 
-  info("foo @ ~ -> in url, is typed");
+  info("foo $ ~ -> in url, is typed");
   await check_autocomplete({
-    search: "foo @ ~",
+    search: "foo $ ~",
     matches: [ { uri: uri4, title: "foo.bar" },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ],
   });
 
   info("foo + ~ -> is tag, is typed");
   await check_autocomplete({
     search: "foo + ~",
     matches: [ { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "tag" ] } ],