зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1475989 - add support for loadPath blocking r=mikedeboer
Differential Revision: https://phabricator.services.mozilla.com/D7620 --HG-- rename : toolkit/components/search/tests/xpcshell/data/search_blacklist.json => toolkit/components/search/tests/xpcshell/data/search_ignorelist.json rename : toolkit/components/search/tests/xpcshell/test_blacklist.js => toolkit/components/search/tests/xpcshell/test_ignorelist.js rename : toolkit/components/search/tests/xpcshell/test_json_cache_blacklist.js => toolkit/components/search/tests/xpcshell/test_json_cache_ignorelist.js extra : moz-landing-system : lando
This commit is contained in:
Родитель
bcd61b77db
Коммит
bab6fc0886
|
@ -3183,23 +3183,31 @@ SearchService.prototype = {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "blacklist",
|
||||
"name": "ignore",
|
||||
"value": "true"
|
||||
},
|
||||
{
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
"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();
|
||||
|
@ -16,14 +19,21 @@ add_task(async function test_blacklistEngineLowerCase() {
|
|||
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");
|
||||
});
|
|
@ -13,7 +13,7 @@ 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;
|
||||
|
|
@ -32,18 +32,18 @@ support-files =
|
|||
[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]
|
||||
|
|
Загрузка…
Ссылка в новой задаче