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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that search suggestions from SearchSuggestionController.jsm operate
* correctly in private mode.
*/
"use strict";
const { SearchSuggestionController } = ChromeUtils.importESModule(
"resource://gre/modules/SearchSuggestionController.sys.mjs"
);
let engine;
add_task(async function setup() {
Services.prefs.setBoolPref("browser.search.suggest.enabled", true);
let server = useHttpServer();
server.registerContentType("sjs", "sjs");
await AddonTestUtils.promiseStartupManager();
const engineData = {
baseURL: gDataUrl,
name: "GET suggestion engine",
method: "GET",
};
engine = await SearchTestUtils.promiseNewSearchEngine({
url: `${gDataUrl}engineMaker.sjs?${JSON.stringify(engineData)}`,
});
});
add_task(async function test_suggestions_in_private_mode_enabled() {
Services.prefs.setBoolPref("browser.search.suggest.enabled.private", true);
let controller = new SearchSuggestionController();
controller.maxLocalResults = 0;
controller.maxRemoteResults = 1;
let result = await controller.fetch("mo", true, engine);
Assert.equal(result.remote.length, 1);
});
add_task(async function test_suggestions_in_private_mode_disabled() {
Services.prefs.setBoolPref("browser.search.suggest.enabled.private", false);
let controller = new SearchSuggestionController();
controller.maxLocalResults = 0;
controller.maxRemoteResults = 1;
let result = await controller.fetch("mo", true, engine);
Assert.equal(result.remote.length, 0);
});
|