From 934a94d74be79bb411cf6a2eb78ccc54bc5ce68e Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Fri, 5 Jun 2020 15:41:29 +0000 Subject: [PATCH] Bug 1616899 - Add search suggestions to eBay. r=mikedeboer Differential Revision: https://phabricator.services.mozilla.com/D78468 --- .../extensions/ebay/_locales/at/messages.json | 5 +- .../extensions/ebay/_locales/au/messages.json | 5 +- .../extensions/ebay/_locales/be/messages.json | 3 ++ .../extensions/ebay/_locales/ca/messages.json | 5 +- .../extensions/ebay/_locales/ch/messages.json | 5 +- .../extensions/ebay/_locales/de/messages.json | 5 +- .../extensions/ebay/_locales/en/messages.json | 5 +- .../extensions/ebay/_locales/es/messages.json | 5 +- .../extensions/ebay/_locales/fr/messages.json | 5 +- .../extensions/ebay/_locales/ie/messages.json | 5 +- .../extensions/ebay/_locales/it/messages.json | 5 +- .../extensions/ebay/_locales/nl/messages.json | 5 +- .../extensions/ebay/_locales/uk/messages.json | 5 +- .../search/extensions/ebay/manifest.json | 8 +-- .../search/test/browser/browser_eBay.js | 22 +++++++++ .../searchconfigs/head_searchconfig.js | 49 +++++++++++-------- .../tests/xpcshell/searchconfigs/test_ebay.js | 15 +++++- 17 files changed, 121 insertions(+), 36 deletions(-) diff --git a/browser/components/search/extensions/ebay/_locales/at/messages.json b/browser/components/search/extensions/ebay/_locales/at/messages.json index d809af32227f..59db1d059fc3 100644 --- a/browser/components/search/extensions/ebay/_locales/at/messages.json +++ b/browser/components/search/extensions/ebay/_locales/at/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/au/messages.json b/browser/components/search/extensions/ebay/_locales/au/messages.json index c93d5fb943a8..96b461414427 100644 --- a/browser/components/search/extensions/ebay/_locales/au/messages.json +++ b/browser/components/search/extensions/ebay/_locales/au/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/be/messages.json b/browser/components/search/extensions/ebay/_locales/be/messages.json index 2d729ac2deb1..9041850de8d8 100644 --- a/browser/components/search/extensions/ebay/_locales/be/messages.json +++ b/browser/components/search/extensions/ebay/_locales/be/messages.json @@ -13,5 +13,8 @@ }, "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}" } } diff --git a/browser/components/search/extensions/ebay/_locales/ca/messages.json b/browser/components/search/extensions/ebay/_locales/ca/messages.json index 0d8bb59e47de..02a6f1c48429 100644 --- a/browser/components/search/extensions/ebay/_locales/ca/messages.json +++ b/browser/components/search/extensions/ebay/_locales/ca/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/ch/messages.json b/browser/components/search/extensions/ebay/_locales/ch/messages.json index 9c18d642c774..b605ed339853 100644 --- a/browser/components/search/extensions/ebay/_locales/ch/messages.json +++ b/browser/components/search/extensions/ebay/_locales/ch/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/de/messages.json b/browser/components/search/extensions/ebay/_locales/de/messages.json index 751622edffc0..5b4562f0a89c 100644 --- a/browser/components/search/extensions/ebay/_locales/de/messages.json +++ b/browser/components/search/extensions/ebay/_locales/de/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/en/messages.json b/browser/components/search/extensions/ebay/_locales/en/messages.json index 460802e08ea3..467165ee5d65 100644 --- a/browser/components/search/extensions/ebay/_locales/en/messages.json +++ b/browser/components/search/extensions/ebay/_locales/en/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/es/messages.json b/browser/components/search/extensions/ebay/_locales/es/messages.json index 96ad19ba5c23..11ee15005578 100644 --- a/browser/components/search/extensions/ebay/_locales/es/messages.json +++ b/browser/components/search/extensions/ebay/_locales/es/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/fr/messages.json b/browser/components/search/extensions/ebay/_locales/fr/messages.json index 20487bfe104f..079e5d1804e0 100644 --- a/browser/components/search/extensions/ebay/_locales/fr/messages.json +++ b/browser/components/search/extensions/ebay/_locales/fr/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/ie/messages.json b/browser/components/search/extensions/ebay/_locales/ie/messages.json index c5cc1e1c0efc..8cc312d7cfa7 100644 --- a/browser/components/search/extensions/ebay/_locales/ie/messages.json +++ b/browser/components/search/extensions/ebay/_locales/ie/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/it/messages.json b/browser/components/search/extensions/ebay/_locales/it/messages.json index f013f6edc97f..27d4a33a4ed0 100644 --- a/browser/components/search/extensions/ebay/_locales/it/messages.json +++ b/browser/components/search/extensions/ebay/_locales/it/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/nl/messages.json b/browser/components/search/extensions/ebay/_locales/nl/messages.json index 5685b6f201af..a5655edfa3d8 100644 --- a/browser/components/search/extensions/ebay/_locales/nl/messages.json +++ b/browser/components/search/extensions/ebay/_locales/nl/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/_locales/uk/messages.json b/browser/components/search/extensions/ebay/_locales/uk/messages.json index 4dfbe91c133d..6e4d382ea990 100644 --- a/browser/components/search/extensions/ebay/_locales/uk/messages.json +++ b/browser/components/search/extensions/ebay/_locales/uk/messages.json @@ -13,5 +13,8 @@ }, "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 +} diff --git a/browser/components/search/extensions/ebay/manifest.json b/browser/components/search/extensions/ebay/manifest.json index b83fce4abfb2..e8a4a3e7516e 100644 --- a/browser/components/search/extensions/ebay/manifest.json +++ b/browser/components/search/extensions/ebay/manifest.json @@ -2,7 +2,7 @@ "name": "__MSG_extensionName__", "description": "__MSG_extensionDescription__", "manifest_version": 2, - "version": "1.0", + "version": "1.1", "applications": { "gecko": { "id": "ebay@search.mozilla.org" @@ -21,7 +21,9 @@ "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 +} diff --git a/browser/components/search/test/browser/browser_eBay.js b/browser/components/search/test/browser/browser_eBay.js index eb2c3c4bb33b..c2099e885e02 100644 --- a/browser/components/search/test/browser/browser_eBay.js +++ b/browser/components/search/test/browser/browser_eBay.js @@ -62,6 +62,28 @@ add_task(async function test() { }, ], }, + { + 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, + }, + ], + }, ], }, }; diff --git a/toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js b/toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js index 51fafbd328bc..295962c0782b 100644 --- a/toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js +++ b/toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js @@ -531,26 +531,35 @@ class SearchConfigTest { 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` + ); } } diff --git a/toolkit/components/search/tests/xpcshell/searchconfigs/test_ebay.js b/toolkit/components/search/tests/xpcshell/searchconfigs/test_ebay.js index 865acc59629e..eb9d2d408ce7 100644 --- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_ebay.js +++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_ebay.js @@ -69,6 +69,7 @@ const test = new SearchConfigTest({ ], }, 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. @@ -85,6 +86,7 @@ const test = new SearchConfigTest({ }, ], searchUrlEnd: "1553-53471-19255-0/1", + suggestUrlCode: "sId=23", }, { domain: "ebay.at", @@ -96,6 +98,7 @@ const test = new SearchConfigTest({ }, ], searchUrlEnd: "5221-53469-19255-0/1", + suggestUrlCode: "sId=16", }, { domain: "ebay.ca", @@ -124,6 +127,7 @@ const test = new SearchConfigTest({ }, ], searchUrlEnd: "706-53473-19255-0/1", + suggestUrlCode: "sId=2", }, { domain: "ebay.ch", @@ -151,6 +155,7 @@ const test = new SearchConfigTest({ }, ], searchUrlEnd: "5222-53480-19255-0/1", + suggestUrlCode: "sId=193", }, { domain: "ebay.com", @@ -162,6 +167,7 @@ const test = new SearchConfigTest({ ], excluded: [{ regions: ["au", "be", "ca", "ch", "gb", "ie", "nl"] }], searchUrlEnd: "711-53200-19255-0/1", + suggestUrlCode: "sId=0", }, { domain: "ebay.com.au", @@ -173,6 +179,7 @@ const test = new SearchConfigTest({ }, ], searchUrlEnd: "705-53470-19255-0/1", + suggestUrlCode: "sId=15", }, { domain: "ebay.ie", @@ -187,6 +194,7 @@ const test = new SearchConfigTest({ }, ], searchUrlEnd: "5282-53468-19255-0/1", + suggestUrlCode: "sId=205", }, { domain: "ebay.co.uk", @@ -202,6 +210,7 @@ const test = new SearchConfigTest({ ], excluded: [{ regions: ["au", "ie"] }], searchUrlEnd: "710-53481-19255-0/1", + suggestUrlCode: "sId=3", }, { domain: "ebay.de", @@ -213,6 +222,7 @@ const test = new SearchConfigTest({ ], excluded: [{ regions: ["at", "ch"] }], searchUrlEnd: "707-53477-19255-0/1", + suggestUrlCode: "sId=77", }, { domain: "ebay.es", @@ -225,6 +235,7 @@ const test = new SearchConfigTest({ }, ], searchUrlEnd: "1185-53479-19255-0/1", + suggestUrlCode: "sId=186", }, { domain: "ebay.fr", @@ -236,6 +247,7 @@ const test = new SearchConfigTest({ ], excluded: [{ regions: ["be", "ca", "ch"] }], searchUrlEnd: "709-53476-19255-0/1", + suggestUrlCode: "sId=71", }, { domain: "ebay.it", @@ -246,6 +258,7 @@ const test = new SearchConfigTest({ }, ], searchUrlEnd: "724-53478-19255-0/1", + suggestUrlCode: "sId=101", }, { domain: "ebay.nl", @@ -261,9 +274,9 @@ const test = new SearchConfigTest({ ], excluded: [{ regions: ["be"] }], searchUrlEnd: "1346-53482-19255-0/1", + suggestUrlCode: "sId=146", }, ], - noSuggestionsURL: true, }); add_task(async function setup() {