Bug 1616899 - Add search suggestions to eBay. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Fri, 05 Jun 2020 15:41:29 +0000
changeset 534163 cdf7aeb1e18179f12b32136166a890d7bfc64861
parent 534162 8a842264000abd7a68075a03394e70e5af43046e
child 534164 01507268c72f1806fab6217671cad2ce0dd8e548
push id37483
push userapavel@mozilla.com
push dateFri, 05 Jun 2020 21:40:11 +0000
treeherdermozilla-central@dadc7312128e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1616899
milestone79.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 1616899 - Add search suggestions to eBay. r=mikedeboer Differential Revision: https://phabricator.services.mozilla.com/D78468
browser/components/search/extensions/ebay/_locales/at/messages.json
browser/components/search/extensions/ebay/_locales/au/messages.json
browser/components/search/extensions/ebay/_locales/be/messages.json
browser/components/search/extensions/ebay/_locales/ca/messages.json
browser/components/search/extensions/ebay/_locales/ch/messages.json
browser/components/search/extensions/ebay/_locales/de/messages.json
browser/components/search/extensions/ebay/_locales/en/messages.json
browser/components/search/extensions/ebay/_locales/es/messages.json
browser/components/search/extensions/ebay/_locales/fr/messages.json
browser/components/search/extensions/ebay/_locales/ie/messages.json
browser/components/search/extensions/ebay/_locales/it/messages.json
browser/components/search/extensions/ebay/_locales/nl/messages.json
browser/components/search/extensions/ebay/_locales/uk/messages.json
browser/components/search/extensions/ebay/manifest.json
browser/components/search/test/browser/browser_eBay.js
toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js
toolkit/components/search/tests/xpcshell/searchconfigs/test_ebay.js
--- a/browser/components/search/extensions/ebay/_locales/at/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/at/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/5221-53469-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.at/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.at/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=16&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/au/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/au/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/705-53470-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.com.au/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.com.au/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=15&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/be/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/be/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/1553-53471-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.befr.ebay.be/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.befr.ebay.be/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=23&fmt=osr&kwd={searchTerms}"
   }
 }
--- a/browser/components/search/extensions/ebay/_locales/ca/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/ca/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/706-53473-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.ca/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.ca/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=2&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/ch/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/ch/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/5222-53480-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.ch/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.ch/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=193&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/de/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/de/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/707-53477-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.de/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.de/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=77&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/en/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/en/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/711-53200-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.com/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.com/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=0&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/es/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/es/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/1185-53479-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.es/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.es/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=186&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/fr/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/fr/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/709-53476-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.fr/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.fr/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=71&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/ie/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/ie/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/5282-53468-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.ie/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.ie/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=205&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/it/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/it/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/724-53478-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.it/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.it/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=101&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/nl/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/nl/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/1346-53482-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.nl/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.nl/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=146&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/_locales/uk/messages.json
+++ b/browser/components/search/extensions/ebay/_locales/uk/messages.json
@@ -8,10 +8,13 @@
   "searchUrl": {
     "message": "https://rover.ebay.com/rover/1/710-53481-19255-0/1"
   },
   "searchForm": {
     "message": "https://www.ebay.co.uk/"
   },
   "searchUrlGetParams": {
     "message": "ff3=4&toolid=20004&campid=5338192028&customid=&mpre=https://www.ebay.co.uk/sch/{searchTerms}"
+  },
+  "suggestUrlGetParams": {
+    "message": "sId=3&fmt=osr&kwd={searchTerms}"
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/extensions/ebay/manifest.json
+++ b/browser/components/search/extensions/ebay/manifest.json
@@ -1,13 +1,13 @@
 {
   "name": "__MSG_extensionName__",
   "description": "__MSG_extensionDescription__",
   "manifest_version": 2,
-  "version": "1.0",
+  "version": "1.1",
   "applications": {
     "gecko": {
       "id": "ebay@search.mozilla.org"
     }
   },
   "hidden": true,
   "default_locale": "en",
   "icons": {
@@ -16,12 +16,14 @@
   "web_accessible_resources": [
     "favicon.ico"
   ],
   "chrome_settings_overrides": {
     "search_provider": {
       "name": "__MSG_extensionName__",
       "search_url": "__MSG_searchUrl__",
       "search_form": "__MSG_searchForm__",
-      "search_url_get_params": "__MSG_searchUrlGetParams__"
+      "search_url_get_params": "__MSG_searchUrlGetParams__",
+      "suggest_url": "https://autosug.ebay.com/autosug",
+      "suggest_url_get_params": "__MSG_suggestUrlGetParams__"
     }
   }
-}
\ No newline at end of file
+}
--- a/browser/components/search/test/browser/browser_eBay.js
+++ b/browser/components/search/test/browser/browser_eBay.js
@@ -57,14 +57,36 @@ add_task(async function test() {
             },
             {
               name: "mpre",
               value: "https://www.ebay.com/sch/{searchTerms}",
               purpose: undefined,
             },
           ],
         },
+        {
+          type: "application/x-suggestions+json",
+          method: "GET",
+          template: "https://autosug.ebay.com/autosug",
+          params: [
+            {
+              name: "sId",
+              value: "0",
+              purpose: undefined,
+            },
+            {
+              name: "fmt",
+              value: "osr",
+              purpose: undefined,
+            },
+            {
+              name: "kwd",
+              value: "{searchTerms}",
+              purpose: undefined,
+            },
+          ],
+        },
       ],
     },
   };
 
   isSubObjectOf(EXPECTED_ENGINE, engine, "eBay");
 });
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js
@@ -526,36 +526,45 @@ class SearchConfigTest {
 
     const searchForm = new URL(engine.searchForm);
     this.assertOk(
       searchForm.host.endsWith(rules.domain),
       `Should have the correct search form domain ${location}.
        Got "${searchForm.host}", expected to end with "${rules.domain}".`
     );
 
-    for (const urlType of [URLTYPE_SUGGEST_JSON, URLTYPE_SEARCH_HTML]) {
-      const submission = engine.getSubmission("test", urlType);
-      if (
-        urlType == URLTYPE_SUGGEST_JSON &&
-        (this._config.noSuggestionsURL || rules.noSuggestionsURL)
-      ) {
-        this.assertOk(!submission, "Should not have a submission url");
-      } else if (this._config.searchUrlBase) {
-        this.assertEqual(
-          submission.uri.prePath + submission.uri.filePath,
-          this._config.searchUrlBase + rules.searchUrlEnd,
-          `Should have the correct domain for type: ${urlType} ${location}.`
-        );
-      } else {
-        this.assertOk(
-          submission.uri.host.endsWith(rules.domain),
-          `Should have the correct domain for type: ${urlType} ${location}.
-           Got "${submission.uri.host}", expected to end with "${rules.domain}".`
-        );
-      }
+    let submission = engine.getSubmission("test", URLTYPE_SEARCH_HTML);
+
+    if (this._config.searchUrlBase) {
+      this.assertEqual(
+        submission.uri.prePath + submission.uri.filePath,
+        this._config.searchUrlBase + rules.searchUrlEnd,
+        `Should have the correct domain for type: ${URLTYPE_SEARCH_HTML} ${location}.`
+      );
+    } else {
+      this.assertOk(
+        submission.uri.host.endsWith(rules.domain),
+        `Should have the correct domain for type: ${URLTYPE_SEARCH_HTML} ${location}.
+         Got "${submission.uri.host}", expected to end with "${rules.domain}".`
+      );
+    }
+
+    submission = engine.getSubmission("test", URLTYPE_SUGGEST_JSON);
+    if (this._config.noSuggestionsURL || rules.noSuggestionsURL) {
+      this.assertOk(!submission, "Should not have a submission url");
+    } else if (this._config.suggestionUrlBase) {
+      this.assertEqual(
+        submission.uri.prePath + submission.uri.filePath,
+        this._config.suggestionUrlBase,
+        `Should have the correct domain for type: ${URLTYPE_SUGGEST_JSON} ${location}.`
+      );
+      this.assertOk(
+        submission.uri.query.includes(rules.suggestUrlCode),
+        `Should have the code in the uri`
+      );
     }
   }
 
   /**
    * Asserts whether the engine is using the correct codes or not.
    *
    * @param {string} location
    *   Debug string with locale + region information.
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_ebay.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_ebay.js
@@ -64,43 +64,46 @@ const test = new SearchConfigTest({
         regions: ["au", "be", "ca", "ch", "gb", "ie", "nl", "us"],
         locales: {
           matches: ["en-US"],
         },
       },
     ],
   },
   searchUrlBase: "https://rover.ebay.com/rover/1/",
+  suggestionUrlBase: "https://autosug.ebay.com/autosug",
   details: [
     {
       // Note: These should be based on region, but we don't currently enforce that.
       // Note: the order here is important. A region/locale match higher up in the
       // list will override a region/locale match lower down.
       domain: "befr.ebay.be",
       telemetryId: "ebay-be",
       included: [
         {
           regions: ["be"],
           locales: {
             matches: ["br", "unknown", "en-US", "fr", "fy-NL", "nl", "wo"],
           },
         },
       ],
       searchUrlEnd: "1553-53471-19255-0/1",
+      suggestUrlCode: "sId=23",
     },
     {
       domain: "ebay.at",
       telemetryId: "ebay-at",
       included: [
         {
           regions: ["at"],
           locales: { matches: ["de", "dsb", "hsb"] },
         },
       ],
       searchUrlEnd: "5221-53469-19255-0/1",
+      suggestUrlCode: "sId=16",
     },
     {
       domain: "ebay.ca",
       telemetryId: "ebay-ca",
       included: [
         {
           locales: { matches: DOMAIN_LOCALES["ebay-ca"] },
         },
@@ -119,16 +122,17 @@ const test = new SearchConfigTest({
               ...DOMAIN_LOCALES["ebay-it"],
               ...DOMAIN_LOCALES["ebay-nl"],
               ...DOMAIN_LOCALES["ebay-uk"],
             ],
           },
         },
       ],
       searchUrlEnd: "706-53473-19255-0/1",
+      suggestUrlCode: "sId=2",
     },
     {
       domain: "ebay.ch",
       telemetryId: "ebay-ch",
       included: [
         {
           locales: { matches: DOMAIN_LOCALES["ebay-ch"] },
         },
@@ -146,129 +150,138 @@ const test = new SearchConfigTest({
               ...DOMAIN_LOCALES["ebay-it"],
               ...DOMAIN_LOCALES["ebay-nl"],
               ...DOMAIN_LOCALES["ebay-uk"],
             ],
           },
         },
       ],
       searchUrlEnd: "5222-53480-19255-0/1",
+      suggestUrlCode: "sId=193",
     },
     {
       domain: "ebay.com",
       telemetryId: "ebay",
       included: [
         {
           locales: { matches: ["unknown", "en-US"] },
         },
       ],
       excluded: [{ regions: ["au", "be", "ca", "ch", "gb", "ie", "nl"] }],
       searchUrlEnd: "711-53200-19255-0/1",
+      suggestUrlCode: "sId=0",
     },
     {
       domain: "ebay.com.au",
       telemetryId: "ebay-au",
       included: [
         {
           regions: ["au"],
           locales: { matches: ["cy", "unknown", "en-GB", "en-US", "gd"] },
         },
       ],
       searchUrlEnd: "705-53470-19255-0/1",
+      suggestUrlCode: "sId=15",
     },
     {
       domain: "ebay.ie",
       telemetryId: "ebay-ie",
       included: [
         {
           locales: { matches: DOMAIN_LOCALES["ebay-ie"] },
         },
         {
           regions: ["ie"],
           locales: { matches: ["cy", "unknown", "en-GB", "en-US", "gd"] },
         },
       ],
       searchUrlEnd: "5282-53468-19255-0/1",
+      suggestUrlCode: "sId=205",
     },
     {
       domain: "ebay.co.uk",
       telemetryId: "ebay-uk",
       included: [
         {
           locales: { matches: DOMAIN_LOCALES["ebay-uk"] },
         },
         {
           locales: { matches: ["unknown", "en-US"] },
           regions: ["gb"],
         },
       ],
       excluded: [{ regions: ["au", "ie"] }],
       searchUrlEnd: "710-53481-19255-0/1",
+      suggestUrlCode: "sId=3",
     },
     {
       domain: "ebay.de",
       telemetryId: "ebay-de",
       included: [
         {
           locales: { matches: DOMAIN_LOCALES["ebay-de"] },
         },
       ],
       excluded: [{ regions: ["at", "ch"] }],
       searchUrlEnd: "707-53477-19255-0/1",
+      suggestUrlCode: "sId=77",
     },
     {
       domain: "ebay.es",
       telemetryId: "ebay-es",
       included: [
         {
           locales: {
             matches: DOMAIN_LOCALES["ebay-es"],
           },
         },
       ],
       searchUrlEnd: "1185-53479-19255-0/1",
+      suggestUrlCode: "sId=186",
     },
     {
       domain: "ebay.fr",
       telemetryId: "ebay-fr",
       included: [
         {
           locales: { matches: ["br", "fr", "wo"] },
         },
       ],
       excluded: [{ regions: ["be", "ca", "ch"] }],
       searchUrlEnd: "709-53476-19255-0/1",
+      suggestUrlCode: "sId=71",
     },
     {
       domain: "ebay.it",
       telemetryId: "ebay-it",
       included: [
         {
           locales: { matches: DOMAIN_LOCALES["ebay-it"] },
         },
       ],
       searchUrlEnd: "724-53478-19255-0/1",
+      suggestUrlCode: "sId=101",
     },
     {
       domain: "ebay.nl",
       telemetryId: "ebay-nl",
       included: [
         {
           locales: { matches: DOMAIN_LOCALES["ebay-nl"] },
         },
         {
           locales: { matches: ["unknown", "en-US"] },
           regions: ["nl"],
         },
       ],
       excluded: [{ regions: ["be"] }],
       searchUrlEnd: "1346-53482-19255-0/1",
+      suggestUrlCode: "sId=146",
     },
   ],
-  noSuggestionsURL: true,
 });
 
 add_task(async function setup() {
   await test.setup();
 });
 
 add_task(async function test_searchConfig_ebay() {
   await test.run(true);