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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/*
* Tests that User Engines can be installed correctly.
*/
"use strict";
add_setup(async function () {
Services.fog.initializeFOG();
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});
add_task(async function test_user_engine() {
let promiseEngineAdded = SearchTestUtils.promiseSearchNotification(
SearchUtils.MODIFIED_TYPE.ADDED,
SearchUtils.TOPIC_ENGINE_MODIFIED
);
await Services.search.addUserEngine(
"user",
"https://example.com/user?q={searchTerms}",
"u"
);
await promiseEngineAdded;
let engine = Services.search.getEngineByName("user");
Assert.ok(engine, "Should have installed the engine.");
Assert.equal(engine.name, "user", "Should have the correct name");
Assert.equal(engine.description, null, "Should not have a description");
Assert.deepEqual(engine.aliases, ["u"], "Should have the correct alias");
let submission = engine.getSubmission("foo");
Assert.equal(
submission.uri.spec,
"https://example.com/user?q=foo",
"Should have the correct search url"
);
submission = engine.getSubmission("foo", SearchUtils.URL_TYPE.SUGGEST_JSON);
Assert.equal(submission, null, "Should not have a suggest url");
Services.search.defaultEngine = engine;
await assertGleanDefaultEngine({
normal: {
engineId: "other-user",
displayName: "user",
loadPath: "[user]",
submissionUrl: "blank:",
verified: "verified",
},
});
});
|