Bug 1117153 - Added 'keyword' param for location bar searches triggered by search engine keyword. r=gavin
authorChris <chrishood@eagles.ewu.edu>
Sun, 04 Jan 2015 17:14:26 -0800
changeset 248239 41656484aab8a49d3d3fdd9967bd8a2fa9575e35
parent 248238 da12e372ed3334c91bd71dd377dc2403d90c2108
child 248240 5ab0b9577eae72356c629e9d2178b740fd302306
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs1117153
milestone37.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 1117153 - Added 'keyword' param for location bar searches triggered by search engine keyword. r=gavin
browser/base/content/browser.js
browser/components/search/test/browser_amazon_behavior.js
browser/components/search/test/browser_bing_behavior.js
browser/components/search/test/browser_eBay_behavior.js
browser/components/search/test/browser_google_behavior.js
browser/components/search/test/browser_yahoo_behavior.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2077,17 +2077,17 @@ function getShortcutOrURIAndPostData(aUR
   let offset = aURL.indexOf(" ");
   if (offset > 0) {
     keyword = aURL.substr(0, offset);
     param = aURL.substr(offset + 1);
   }
 
   let engine = Services.search.getEngineByAlias(keyword);
   if (engine) {
-    let submission = engine.getSubmission(param);
+    let submission = engine.getSubmission(param, null, "keyword");
     postData = submission.postData;
     aCallback({ postData: submission.postData, url: submission.uri.spec,
                 mayInheritPrincipal: mayInheritPrincipal });
     return;
   }
 
   [shortcutURL, postData] =
     PlacesUtils.getURLAndPostDataForKeyword(keyword);
--- a/browser/components/search/test/browser_amazon_behavior.js
+++ b/browser/components/search/test/browser_amazon_behavior.js
@@ -11,16 +11,17 @@ const BROWSER_SEARCH_PREF = "browser.sea
 
 
 function test() {
   let engine = Services.search.getEngineByName("Amazon.com");
   ok(engine, "Amazon is installed");
 
   let previouslySelectedEngine = Services.search.currentEngine;
   Services.search.currentEngine = engine;
+  engine.alias = "a";
 
   let base = "http://www.amazon.com/exec/obidos/external-search/?field-keywords=foo&mode=blended&tag=mozilla-20&sourceid=Mozilla-search";
   let url;
 
   // Test search URLs (including purposes).
   url = engine.getSubmission("foo").uri.spec;
   is(url, base, "Check search URL for 'foo'");
 
@@ -42,16 +43,25 @@ function test() {
       searchURL: base,
       run: function () {
         gURLBar.value = "? foo";
         gURLBar.focus();
         EventUtils.synthesizeKey("VK_RETURN", {});
       }
     },
     {
+      name: "keyword search",
+      searchURL: base,
+      run: function () {
+        gURLBar.value = "a foo";
+        gURLBar.focus();
+        EventUtils.synthesizeKey("VK_RETURN", {});
+      }
+    },
+    {
       name: "search bar search",
       searchURL: base,
       run: function () {
         let sb = BrowserSearch.searchBar;
         sb.focus();
         sb.value = "foo";
         registerCleanupFunction(function () {
           sb.value = "";
@@ -134,16 +144,17 @@ function test() {
 
       req.cancel(Components.results.NS_ERROR_FAILURE);
 
       executeSoon(nextTest);
     }
   }
 
   registerCleanupFunction(function () {
+    engine.alias = undefined;
     gBrowser.removeProgressListener(listener);
     gBrowser.removeTab(tab);
     Services.search.currentEngine = previouslySelectedEngine;
   });
 
   tab.linkedBrowser.addEventListener("load", function load() {
     tab.linkedBrowser.removeEventListener("load", load, true);
     gBrowser.addProgressListener(listener);
--- a/browser/components/search/test/browser_bing_behavior.js
+++ b/browser/components/search/test/browser_bing_behavior.js
@@ -11,17 +11,18 @@ const BROWSER_SEARCH_PREF = "browser.sea
 
 
 function test() {
   let engine = Services.search.getEngineByName("Bing");
   ok(engine, "Bing is installed");
 
   let previouslySelectedEngine = Services.search.currentEngine;
   Services.search.currentEngine = engine;
-
+  engine.alias = "b";
+  
   let base = "http://www.bing.com/search?q=foo&pc=MOZI";
   let url;
 
   // Test search URLs (including purposes).
   url = engine.getSubmission("foo").uri.spec;
   is(url, base, "Check search URL for 'foo'");
 
   waitForExplicitFinish();
@@ -42,16 +43,25 @@ function test() {
       searchURL: base + "&form=MOZLBR",
       run: function () {
         gURLBar.value = "? foo";
         gURLBar.focus();
         EventUtils.synthesizeKey("VK_RETURN", {});
       }
     },
     {
+      name: "keyword search with alias",
+      searchURL: base + "&form=MOZLBR",
+      run: function () {
+        gURLBar.value = "b foo";
+        gURLBar.focus();
+        EventUtils.synthesizeKey("VK_RETURN", {});
+      }
+    },
+    {
       name: "search bar search",
       searchURL: base + "&form=MOZSBR",
       run: function () {
         let sb = BrowserSearch.searchBar;
         sb.focus();
         sb.value = "foo";
         registerCleanupFunction(function () {
           sb.value = "";
@@ -134,16 +144,17 @@ function test() {
 
       req.cancel(Components.results.NS_ERROR_FAILURE);
 
       executeSoon(nextTest);
     }
   }
 
   registerCleanupFunction(function () {
+    engine.alias = undefined;
     gBrowser.removeProgressListener(listener);
     gBrowser.removeTab(tab);
     Services.search.currentEngine = previouslySelectedEngine;
   });
 
   tab.linkedBrowser.addEventListener("load", function load() {
     tab.linkedBrowser.removeEventListener("load", load, true);
     gBrowser.addProgressListener(listener);
--- a/browser/components/search/test/browser_eBay_behavior.js
+++ b/browser/components/search/test/browser_eBay_behavior.js
@@ -11,16 +11,17 @@ const BROWSER_SEARCH_PREF = "browser.sea
 
 
 function test() {
   let engine = Services.search.getEngineByName("eBay");
   ok(engine, "eBay is installed");
 
   let previouslySelectedEngine = Services.search.currentEngine;
   Services.search.currentEngine = engine;
+  engine.alias = 'e';
 
   let base = "http://rover.ebay.com/rover/1/711-47294-18009-3/4?mfe=search&mpre=http://www.ebay.com/sch/i.html?_nkw=foo";
   let url;
 
   // Test search URLs (including purposes).
   url = engine.getSubmission("foo").uri.spec;
   is(url, base, "Check search URL for 'foo'");
 
@@ -42,16 +43,25 @@ function test() {
       searchURL: base,
       run: function () {
         gURLBar.value = "? foo";
         gURLBar.focus();
         EventUtils.synthesizeKey("VK_RETURN", {});
       }
     },
     {
+      name: "keyword search",
+      searchURL: base,
+      run: function () {
+        gURLBar.value = "e foo";
+        gURLBar.focus();
+        EventUtils.synthesizeKey("VK_RETURN", {});
+      }
+    },
+    {
       name: "search bar search",
       searchURL: base,
       run: function () {
         let sb = BrowserSearch.searchBar;
         sb.focus();
         sb.value = "foo";
         registerCleanupFunction(function () {
           sb.value = "";
@@ -134,16 +144,17 @@ function test() {
 
       req.cancel(Components.results.NS_ERROR_FAILURE);
 
       executeSoon(nextTest);
     }
   }
 
   registerCleanupFunction(function () {
+    engine.alias = undefined;
     gBrowser.removeProgressListener(listener);
     gBrowser.removeTab(tab);
     Services.search.currentEngine = previouslySelectedEngine;
   });
 
   tab.linkedBrowser.addEventListener("load", function load() {
     tab.linkedBrowser.removeEventListener("load", load, true);
     gBrowser.addProgressListener(listener);
--- a/browser/components/search/test/browser_google_behavior.js
+++ b/browser/components/search/test/browser_google_behavior.js
@@ -8,16 +8,17 @@
 "use strict";
 
 function test() {
   let engine = Services.search.getEngineByName("Google");
   ok(engine, "Google is installed");
 
   let previouslySelectedEngine = Services.search.currentEngine;
   Services.search.currentEngine = engine;
+  engine.alias = "g";
 
   let base = "https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8";
 
   let url;
 
   // Test search URLs (including purposes).
   url = engine.getSubmission("foo").uri.spec;
   is(url, base, "Check search URL for 'foo'");
@@ -40,16 +41,25 @@ function test() {
       searchURL: base,
       run: function () {
         gURLBar.value = "? foo";
         gURLBar.focus();
         EventUtils.synthesizeKey("VK_RETURN", {});
       }
     },
     {
+      name: "keyword search",
+      searchURL: base,
+      run: function () {
+        gURLBar.value = "g foo";
+        gURLBar.focus();
+        EventUtils.synthesizeKey("VK_RETURN", {});
+      }
+    },
+    {
       name: "search bar search",
       searchURL: base,
       run: function () {
         let sb = BrowserSearch.searchBar;
         sb.focus();
         sb.value = "foo";
         registerCleanupFunction(function () {
           sb.value = "";
@@ -132,16 +142,17 @@ function test() {
 
       req.cancel(Components.results.NS_ERROR_FAILURE);
 
       executeSoon(nextTest);
     }
   }
 
   registerCleanupFunction(function () {
+    engine.alias = undefined;
     gBrowser.removeProgressListener(listener);
     gBrowser.removeTab(tab);
     Services.search.currentEngine = previouslySelectedEngine;
   });
 
   tab.linkedBrowser.addEventListener("load", function load() {
     tab.linkedBrowser.removeEventListener("load", load, true);
     gBrowser.addProgressListener(listener);
--- a/browser/components/search/test/browser_yahoo_behavior.js
+++ b/browser/components/search/test/browser_yahoo_behavior.js
@@ -11,16 +11,17 @@ const BROWSER_SEARCH_PREF = "browser.sea
 
 
 function test() {
   let engine = Services.search.getEngineByName("Yahoo");
   ok(engine, "Yahoo is installed");
 
   let previouslySelectedEngine = Services.search.currentEngine;
   Services.search.currentEngine = engine;
+  engine.alias = "y";
 
   let base = "https://search.yahoo.com/yhs/search?p=foo&ei=UTF-8&hspart=mozilla&hsimp=yhs-001";
   let url;
 
   // Test search URLs (including purposes).
   url = engine.getSubmission("foo").uri.spec;
   is(url, base, "Check search URL for 'foo'");
 
@@ -42,16 +43,25 @@ function test() {
       searchURL: base,
       run: function () {
         gURLBar.value = "? foo";
         gURLBar.focus();
         EventUtils.synthesizeKey("VK_RETURN", {});
       }
     },
     {
+      name: "keyword search",
+      searchURL: base,
+      run: function () {
+        gURLBar.value = "y foo";
+        gURLBar.focus();
+        EventUtils.synthesizeKey("VK_RETURN", {});
+      }
+    },
+    {
       name: "search bar search",
       searchURL: base,
       run: function () {
         let sb = BrowserSearch.searchBar;
         sb.focus();
         sb.value = "foo";
         registerCleanupFunction(function () {
           sb.value = "";
@@ -134,16 +144,17 @@ function test() {
 
       req.cancel(Components.results.NS_ERROR_FAILURE);
 
       executeSoon(nextTest);
     }
   }
 
   registerCleanupFunction(function () {
+    engine.alias = undefined;
     gBrowser.removeProgressListener(listener);
     gBrowser.removeTab(tab);
     Services.search.currentEngine = previouslySelectedEngine;
   });
 
   tab.linkedBrowser.addEventListener("load", function load() {
     tab.linkedBrowser.removeEventListener("load", load, true);
     gBrowser.addProgressListener(listener);