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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// Functional tests for inline autocomplete
add_task(async function setup() {
registerCleanupFunction(async () => {
Services.prefs.clearUserPref("browser.urlbar.suggest.searches");
Services.prefs.clearUserPref("browser.urlbar.suggest.quickactions");
});
Services.prefs.setBoolPref("browser.urlbar.suggest.searches", false);
Services.prefs.setBoolPref("browser.urlbar.suggest.quickactions", false);
});
add_task(async function test_urls_order() {
info("Add urls, check for correct order");
let places = [
{ uri: Services.io.newURI("http://visit1.mozilla.org") },
{ uri: Services.io.newURI("http://visit2.mozilla.org") },
];
await PlacesTestUtils.addVisits(places);
let context = createContext("vis", { isPrivate: false });
await check_results({
context,
autofilled: "visit2.mozilla.org/",
completed: "http://visit2.mozilla.org/",
hasAutofillTitle: true,
matches: [
makeVisitResult(context, {
uri: "http://visit2.mozilla.org/",
title: "test visit for http://visit2.mozilla.org/",
heuristic: true,
}),
makeVisitResult(context, {
uri: "http://visit1.mozilla.org/",
title: "test visit for http://visit1.mozilla.org/",
}),
],
});
await cleanupPlaces();
});
add_task(async function test_bookmark_first() {
info("With a bookmark and history, the query result should be the bookmark");
await PlacesTestUtils.addBookmarkWithDetails({
uri: Services.io.newURI("http://bookmark1.mozilla.org/"),
});
await PlacesTestUtils.addVisits(
Services.io.newURI("http://bookmark1.mozilla.org/foo")
);
let context = createContext("bookmark", { isPrivate: false });
await check_results({
context,
autofilled: "bookmark1.mozilla.org/",
completed: "http://bookmark1.mozilla.org/",
hasAutofillTitle: true,
matches: [
makeVisitResult(context, {
uri: "http://bookmark1.mozilla.org/",
title: "A bookmark",
heuristic: true,
}),
makeVisitResult(context, {
uri: "http://bookmark1.mozilla.org/foo",
title: "test visit for http://bookmark1.mozilla.org/foo",
}),
],
});
await cleanupPlaces();
});
add_task(async function test_complete_querystring() {
info("Check to make sure we autocomplete after ?");
await PlacesTestUtils.addVisits(
Services.io.newURI("http://smokey.mozilla.org/foo?bacon=delicious")
);
let context = createContext("smokey.mozilla.org/foo?", { isPrivate: false });
await check_results({
context,
autofilled: "smokey.mozilla.org/foo?bacon=delicious",
completed: "http://smokey.mozilla.org/foo?bacon=delicious",
hasAutofillTitle: true,
matches: [
makeVisitResult(context, {
uri: "http://smokey.mozilla.org/foo?bacon=delicious",
title: "test visit for http://smokey.mozilla.org/foo?bacon=delicious",
heuristic: true,
}),
],
});
await cleanupPlaces();
});
add_task(async function test_complete_fragment() {
info("Check to make sure we autocomplete after #");
await PlacesTestUtils.addVisits(
Services.io.newURI("http://smokey.mozilla.org/foo?bacon=delicious#bar")
);
let context = createContext("smokey.mozilla.org/foo?bacon=delicious#bar", {
isPrivate: false,
});
await check_results({
context,
autofilled: "smokey.mozilla.org/foo?bacon=delicious#bar",
completed: "http://smokey.mozilla.org/foo?bacon=delicious#bar",
hasAutofillTitle: true,
matches: [
makeVisitResult(context, {
uri: "http://smokey.mozilla.org/foo?bacon=delicious#bar",
title:
"test visit for http://smokey.mozilla.org/foo?bacon=delicious#bar",
heuristic: true,
}),
],
});
await cleanupPlaces();
});
|