Bug 1475989 - add support for loadPath blocking r=mikedeboer
authorMichael Kaply <mozilla@kaply.com>
Wed, 10 Oct 2018 17:11:37 +0000
changeset 499746 ba17ddb6432e1c67c860994697a565f9a663ecec
parent 499745 71a04ddae0fad8b796e63f482269e825b98fd686
child 499747 04459ddd517a051f4dd0c69c6177de1a61921bc9
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)
reviewersmikedeboer
bugs1475989
milestone64.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 1475989 - add support for loadPath blocking r=mikedeboer Differential Revision: https://phabricator.services.mozilla.com/D7620
toolkit/components/search/nsSearchService.js
toolkit/components/search/tests/xpcshell/data/search_blacklist.json
toolkit/components/search/tests/xpcshell/data/search_ignorelist.json
toolkit/components/search/tests/xpcshell/test_blacklist.js
toolkit/components/search/tests/xpcshell/test_ignorelist.js
toolkit/components/search/tests/xpcshell/test_json_cache_blacklist.js
toolkit/components/search/tests/xpcshell/test_json_cache_ignorelist.js
toolkit/components/search/tests/xpcshell/xpcshell.ini
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -3178,33 +3178,41 @@ SearchService.prototype = {
         LOG("batchTask: Invalidating engine cache");
         this._buildCache();
       };
       this._batchTask = new DeferredTask(task, CACHE_INVALIDATION_DELAY);
     }
     return this._batchTask;
   },
 
-  _blackList: [
-    "blacklist=true",
+  _submissionURLIgnoreList: [
+    "ignore=true",
     "hspart=lvs",
     "form=CONBDF",
     "clid=2308146",
     "fr=mcafee",
     "PC=MC0",
-    "secure.webofsearch.com",
-    "secure.startpageweb.com",
-    "secure.webstartsearch.com",
-    "secure.startwebsearch.com",
+  ],
+
+  _loadPathIgnoreList: [
+    "[other]addEngineWithDetails:searchignore@mozilla.com",
+    "[https]opensearch.startpageweb.com/bing-search.xml",
+    "[https]opensearch.startwebsearch.com/bing-search.xml",
+    "[https]opensearch.webstartsearch.com/bing-search.xml",
+    "[https]opensearch.webofsearch.com/bing-search.xml",
   ],
 
   _addEngineToStore: function SRCH_SVC_addEngineToStore(aEngine) {
     let url = aEngine._getURLOfType("text/html").getSubmission("dummy", aEngine).uri.spec.toLowerCase();
-    if (this._blackList.some(code => url.includes(code.toLowerCase()))) {
-      LOG("_addEngineToStore: Ignoring blacklisted engine");
+    if (this._submissionURLIgnoreList.some(code => url.includes(code.toLowerCase()))) {
+      LOG("_addEngineToStore: Ignoring engine");
+      return;
+    }
+    if (this._loadPathIgnoreList.includes(aEngine._loadPath)) {
+      LOG("_addEngineToStore: Ignoring engine");
       return;
     }
 
     LOG("_addEngineToStore: Adding engine: \"" + aEngine.name + "\"");
 
     // See if there is an existing engine with the same name. However, if this
     // engine is updating another engine, it's allowed to have the same name.
     var hasSameNameAsUpdate = (aEngine._engineToUpdate &&
rename from toolkit/components/search/tests/xpcshell/data/search_blacklist.json
rename to toolkit/components/search/tests/xpcshell/data/search_ignorelist.json
--- a/toolkit/components/search/tests/xpcshell/data/search_blacklist.json
+++ b/toolkit/components/search/tests/xpcshell/data/search_ignorelist.json
@@ -27,17 +27,17 @@
           "rels": [
           ],
           "params": [
             {
               "name": "q",
               "value": "{searchTerms}"
             },
             {
-              "name": "blacklist",
+              "name": "ignore",
               "value": "true"
             },
             {
               "name": "channel",
               "value": "fflb",
               "purpose": "keyword"
             },
             {
rename from toolkit/components/search/tests/xpcshell/test_blacklist.js
rename to toolkit/components/search/tests/xpcshell/test_ignorelist.js
--- a/toolkit/components/search/tests/xpcshell/test_blacklist.js
+++ b/toolkit/components/search/tests/xpcshell/test_ignorelist.js
@@ -1,29 +1,39 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
-const kSearchEngineID1 = "blacklist_test_engine1";
-const kSearchEngineID2 = "blacklist_test_engine2";
-const kSearchEngineURL1 = "http://example.com/?search={searchTerms}&blacklist=true";
-const kSearchEngineURL2 = "http://example.com/?search={searchTerms}&BLACKLIST=TRUE";
+const kSearchEngineID1 = "ignorelist_test_engine1";
+const kSearchEngineID2 = "ignorelist_test_engine2";
+const kSearchEngineID3 = "ignorelist_test_engine3";
+const kSearchEngineURL1 = "http://example.com/?search={searchTerms}&ignore=true";
+const kSearchEngineURL2 = "http://example.com/?search={searchTerms}&IGNORE=TRUE";
+const kSearchEngineURL3 = "http://example.com/?search={searchTerms}";
+const kExtensionID = "searchignore@mozilla.com";
 
-add_task(async function test_blacklistEngineLowerCase() {
+add_task(async function test_ignorelistEngineLowerCase() {
   Assert.ok(!Services.search.isInitialized);
 
   await asyncInit();
 
   Services.search.addEngineWithDetails(kSearchEngineID1, "", "", "", "get",
                                        kSearchEngineURL1);
 
-  // A blacklisted engine shouldn't be available at all
+  // An ignored engine shouldn't be available at all
   let engine = Services.search.getEngineByName(kSearchEngineID1);
   Assert.equal(engine, null, "Engine should not exist");
 
   Services.search.addEngineWithDetails(kSearchEngineID2, "", "", "", "get",
                                        kSearchEngineURL2);
 
-  // A blacklisted engine shouldn't be available at all
+  // An ignored engine shouldn't be available at all
   engine = Services.search.getEngineByName(kSearchEngineID2);
   Assert.equal(engine, null, "Engine should not exist");
+
+  Services.search.addEngineWithDetails(kSearchEngineID3, "", "", "", "get",
+                                       kSearchEngineURL3, kExtensionID);
+
+  // An ignored engine shouldn't be available at all
+  engine = Services.search.getEngineByName(kSearchEngineID3);
+  Assert.equal(engine, null, "Engine should not exist");
 });
rename from toolkit/components/search/tests/xpcshell/test_json_cache_blacklist.js
rename to toolkit/components/search/tests/xpcshell/test_json_cache_ignorelist.js
--- a/toolkit/components/search/tests/xpcshell/test_json_cache_blacklist.js
+++ b/toolkit/components/search/tests/xpcshell/test_json_cache_ignorelist.js
@@ -8,17 +8,17 @@
 "use strict";
 
 var cacheTemplate, appPluginsPath, profPlugins;
 
 /**
  * Test reading from search.json.mozlz4
  */
 function run_test() {
-  let cacheTemplateFile = do_get_file("data/search_blacklist.json");
+  let cacheTemplateFile = do_get_file("data/search_ignorelist.json");
   cacheTemplate = readJSONFile(cacheTemplateFile);
   cacheTemplate.buildID = getAppInfo().platformBuildID;
 
   let engineFile = gProfD.clone();
   engineFile.append("searchplugins");
   engineFile.append("test-search-engine.xml");
   engineFile.parent.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
 
--- a/toolkit/components/search/tests/xpcshell/xpcshell.ini
+++ b/toolkit/components/search/tests/xpcshell/xpcshell.ini
@@ -27,28 +27,28 @@ support-files =
   data/list.json
   data/search.json
   data/searchSuggestions.sjs
   data/searchTest.jar
 
 [test_nocache.js]
 [test_645970.js]
 [test_big_icon.js]
-[test_blacklist.js]
 [test_bug930456.js]
 [test_bug930456_child.js]
 [test_engine_set_alias.js]
 [test_hasEngineWithURL.js]
 [test_identifiers.js]
+[test_ignorelist.js]
 [test_invalid_engine_from_dir.js]
 [test_init_async_multiple.js]
 [test_init_async_multiple_then_sync.js]
 [test_json_cache.js]
-[test_json_cache_blacklist.js]
-support-files = data/search_blacklist.json
+[test_json_cache_ignorelist.js]
+support-files = data/search_ignorelist.json
 [test_list_json_locale.js]
 [test_list_json_searchdefault.js]
 [test_list_json_searchdefault_distro.js]
 [test_list_json_searchorder.js]
 [test_location.js]
 [test_location_error.js]
 [test_location_malformed_json.js]
 [test_location_sync.js]