| ... |
... |
@@ -10,6 +10,10 @@ |
|
10
|
10
|
|
|
11
|
11
|
"use strict";
|
|
12
|
12
|
|
|
|
13
|
+const { SearchService } = ChromeUtils.importESModule(
|
|
|
14
|
+ "moz-src:///toolkit/components/search/SearchService.sys.mjs"
|
|
|
15
|
+);
|
|
|
16
|
+
|
|
13
|
17
|
const expectedURLs = {
|
|
14
|
18
|
ddg: "https://duckduckgo.com/?q=test",
|
|
15
|
19
|
"ddg-noai": "https://noai.duckduckgo.com/?q=test",
|
| ... |
... |
@@ -23,24 +27,23 @@ const expectedURLs = { |
|
23
|
27
|
const defaultEngine = "ddg";
|
|
24
|
28
|
|
|
25
|
29
|
add_setup(async function setup() {
|
|
26
|
|
- await Services.search.init();
|
|
|
30
|
+ await SearchService.init();
|
|
27
|
31
|
});
|
|
28
|
32
|
|
|
29
|
33
|
add_task(async function test_listEngines() {
|
|
30
|
|
- const { engines } =
|
|
31
|
|
- await Services.search.wrappedJSObject._fetchEngineSelectorEngines();
|
|
|
34
|
+ const { engines } = await SearchService._fetchEngineSelectorEngines();
|
|
32
|
35
|
const foundIdentifiers = engines.map(e => e.identifier);
|
|
33
|
36
|
Assert.deepEqual(foundIdentifiers, Object.keys(expectedURLs));
|
|
34
|
37
|
});
|
|
35
|
38
|
|
|
36
|
39
|
add_task(async function test_default() {
|
|
37
|
40
|
Assert.equal(
|
|
38
|
|
- (await Services.search.getDefault()).id,
|
|
|
41
|
+ (await SearchService.getDefault()).id,
|
|
39
|
42
|
defaultEngine,
|
|
40
|
43
|
`${defaultEngine} is our default search engine in normal mode.`
|
|
41
|
44
|
);
|
|
42
|
45
|
Assert.equal(
|
|
43
|
|
- (await Services.search.getDefaultPrivate()).id,
|
|
|
46
|
+ (await SearchService.getDefaultPrivate()).id,
|
|
44
|
47
|
defaultEngine,
|
|
45
|
48
|
`${defaultEngine} is our default search engine in PBM.`
|
|
46
|
49
|
);
|
| ... |
... |
@@ -48,7 +51,7 @@ add_task(async function test_default() { |
|
48
|
51
|
|
|
49
|
52
|
add_task(function test_checkSearchURLs() {
|
|
50
|
53
|
for (const [id, url] of Object.entries(expectedURLs)) {
|
|
51
|
|
- const engine = Services.search.getEngineById(id);
|
|
|
54
|
+ const engine = SearchService.getEngineById(id);
|
|
52
|
55
|
const foundUrl = engine.getSubmission("test").uri.spec;
|
|
53
|
56
|
Assert.equal(foundUrl, url, `The URL of ${engine.name} is not altered.`);
|
|
54
|
57
|
}
|
| ... |
... |
@@ -56,7 +59,7 @@ add_task(function test_checkSearchURLs() { |
|
56
|
59
|
|
|
57
|
60
|
add_task(async function test_iconsDoesNotFail() {
|
|
58
|
61
|
for (const id of Object.keys(expectedURLs)) {
|
|
59
|
|
- const engine = Services.search.getEngineById(id);
|
|
|
62
|
+ const engine = SearchService.getEngineById(id);
|
|
60
|
63
|
// No need to assert anything, as in case of error this method should throw.
|
|
61
|
64
|
await engine.getIconURL();
|
|
62
|
65
|
}
|