Bug 1553873 - Add tests to ensure the Baidu search engine is sending the correct codes with the urls. r=daleharvey,a=test-only
authorMark Banner <standard8@mozilla.com>
Fri, 31 May 2019 08:52:55 +0000
changeset 536622 22d87bbc303279e88bc87934996893a122a29171
parent 536621 451c443ad93d89bc6f505824a8fbda602c328ef7
child 536623 8aeedae78bb1b4d6c3bf24eba6ce4d3d522d727f
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaleharvey, test-only
bugs1553873
milestone68.0
Bug 1553873 - Add tests to ensure the Baidu search engine is sending the correct codes with the urls. r=daleharvey,a=test-only Depends on D32296 Differential Revision: https://phabricator.services.mozilla.com/D32344
toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js
toolkit/components/search/tests/xpcshell/searchconfigs/test_baidu.js
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js
@@ -336,17 +336,17 @@ class SearchConfigTest {
 
     const location = `in region:${region}, locale:${locale}`;
 
     for (const rule of details) {
       this._assertCorrectDomains(location, engine, rule);
       if (rule.codes) {
         this._assertCorrectCodes(location, engine, rule);
       }
-      if (rule.searchUrlCode || rule.searchFormUrlCode) {
+      if (rule.searchUrlCode || rule.searchFormUrlCode || rule.suggestUrlCode) {
         this._assertCorrectUrlCode(location, engine, rule);
       }
       if (rule.aliases) {
         this.assertDeepEqual(engine._internalAliases,
           rule.aliases, "Should have the correct aliases for the engine");
       }
     }
   }
@@ -417,23 +417,28 @@ class SearchConfigTest {
    *   The engine being tested.
    * @param {object} rules
    *   Rules to test.
    */
   _assertCorrectUrlCode(location, engine, rule) {
     if (rule.searchUrlCode) {
       const submission = engine.getSubmission("test", URLTYPE_SEARCH_HTML);
       this.assertOk(submission.uri.query.split("&").includes(rule.searchUrlCode),
-        `Expected "${rule.searchUrlCode}" in "${submission.uri.spec}"`);
+        `Expected "${rule.searchUrlCode}" in search url "${submission.uri.spec}"`);
     }
     if (rule.searchFormUrlCode) {
       const uri = engine.searchForm;
       this.assertOk(uri.includes(rule.searchFormUrlCode),
         `Expected "${rule.searchFormUrlCode}" in "${uri}"`);
     }
+    if (rule.suggestUrlCode) {
+      const submission = engine.getSubmission("test", URLTYPE_SUGGEST_JSON);
+      this.assertOk(submission.uri.query.split("&").includes(rule.suggestUrlCode),
+        `Expected "${rule.suggestUrlCode}" in suggestion url "${submission.uri.spec}"`);
+    }
   }
 
   /**
    * Helper functions which avoid outputting test results when there are no
    * failures. These help the tests to run faster, and avoid clogging up the
    * python test runner process.
    */
   assertOk(value, message) {
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_baidu.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_baidu.js
@@ -21,16 +21,18 @@ const test = new SearchConfigTest({
       locales: {
         matches: ["zh-CN"],
       },
     }],
   },
   details: [{
     included: [{}],
     domain: "baidu.com",
+    searchUrlCode: "tn=monline_7_dg",
+    suggestUrlCode: "tn=monline_7_dg",
   }],
 });
 
 add_task(async function setup() {
   await test.setup();
 });
 
 add_task(async function test_searchConfig_baidu() {