1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const kSearchEngineID1 = "ignorelist_test_engine1";
const kSearchEngineID2 = "ignorelist_test_engine2";
const kSearchEngineID3 = "ignorelist_test_engine3";
const kSearchEngineURL1 =
"https://example.com/?search={searchTerms}&ignore=true";
const kSearchEngineURL2 =
"https://example.com/?search={searchTerms}&IGNORE=TRUE";
const kSearchEngineURL3 = "https://example.com/?search={searchTerms}";
const kExtensionID = "searchignore@mozilla.com";
add_task(async function setup() {
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_ignoreList() {
await setupRemoteSettings();
Assert.ok(
!Services.search.isInitialized,
"Search service should not be initialized to begin with."
);
let updatePromise = SearchTestUtils.promiseSearchNotification(
"settings-update-complete"
);
await SearchTestUtils.installSearchExtension({
name: kSearchEngineID1,
search_url: kSearchEngineURL1,
});
await updatePromise;
let engine = Services.search.getEngineByName(kSearchEngineID1);
Assert.equal(
engine,
null,
"Engine with ignored search params should not exist"
);
await SearchTestUtils.installSearchExtension({
name: kSearchEngineID2,
search_url: kSearchEngineURL2,
});
// An ignored engine shouldn't be available at all
engine = Services.search.getEngineByName(kSearchEngineID2);
Assert.equal(
engine,
null,
"Engine with ignored search params of a different case should not exist"
);
await SearchTestUtils.installSearchExtension({
id: kExtensionID,
name: kSearchEngineID3,
search_url: kSearchEngineURL3,
});
// An ignored engine shouldn't be available at all
engine = Services.search.getEngineByName(kSearchEngineID3);
Assert.equal(
engine,
null,
"Engine with ignored extension id should not exist"
);
});
|