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
|
add_task(function* test_enabled() {
// Test for bug 471903 to make sure searching in autocomplete can be turned on
// and off. Also test bug 463535 for pref changing search.
let uri = NetUtil.newURI("http://url/0");
yield PlacesTestUtils.addVisits([ { uri: uri, title: "title" } ]);
do_print("plain search");
yield check_autocomplete({
search: "url",
matches: [ { uri: uri, title: "title" } ]
});
do_print("search disabled");
Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", false);
yield check_autocomplete({
search: "url",
matches: [ ]
});
do_print("resume normal search");
Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", true);
yield check_autocomplete({
search: "url",
matches: [ { uri: uri, title: "title" } ]
});
yield cleanup();
});
add_task(function* test_sync_enabled() {
// Initialize unified complete.
Cc["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"]
.getService(Ci.mozIPlacesAutoComplete);
let types = [ "history", "bookmark", "openpage", "searches" ];
// Test the service keeps browser.urlbar.autocomplete.enabled synchronized
// with browser.urlbar.suggest prefs.
for (let type of types) {
Services.prefs.setBoolPref("browser.urlbar.suggest." + type, true);
}
Assert.equal(Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled"), true);
// Disable autocomplete and check all the suggest prefs are set to false.
Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", false);
for (let type of types) {
Assert.equal(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), false);
}
// Setting even a single suggest pref to true should enable autocomplete.
Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
for (let type of types.filter(t => t != "history")) {
Assert.equal(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), false);
}
Assert.equal(Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled"), true);
// Disable autocoplete again, then re-enable it and check suggest prefs
// have been reset.
Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", false);
Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", true);
for (let type of types.filter(t => t != "history")) {
if (type == "searches") {
Assert.equal(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), false);
} else {
Assert.equal(Services.prefs.getBoolPref("browser.urlbar.suggest." + type), true);
}
}
});
|