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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// When the input is empty and the view is opened, keying down through the
// results and then out of the results should restore the empty input.
"use strict";
add_task(async function test() {
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.suggest.quickactions", false]],
});
for (let i = 0; i < 5; i++) {
await PlacesTestUtils.addVisits("http://example.com/");
}
// Update Top Sites to make sure the last Top Site is a URL. Otherwise, it
// would be a search shortcut and thus would not fill the Urlbar when
// selected.
await updateTopSites(sites => {
return (
sites &&
sites[sites.length - 1] &&
sites[sites.length - 1].url == "http://example.com/"
);
});
registerCleanupFunction(async function () {
await PlacesUtils.history.clear();
});
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "",
fireInputEvent: true,
});
Assert.equal(
UrlbarTestUtils.getSelectedRowIndex(window),
-1,
"Nothing selected"
);
let resultCount = UrlbarTestUtils.getResultCount(window);
Assert.greater(resultCount, 0, "At least one result");
for (let i = 0; i < resultCount; i++) {
EventUtils.synthesizeKey("KEY_ArrowDown");
}
Assert.equal(
UrlbarTestUtils.getSelectedRowIndex(window),
resultCount - 1,
"Last result selected"
);
Assert.notEqual(gURLBar.value, "", "Input should not be empty");
EventUtils.synthesizeKey("KEY_ArrowDown");
Assert.equal(
UrlbarTestUtils.getSelectedRowIndex(window),
-1,
"Nothing selected"
);
Assert.equal(gURLBar.value, "", "Input should be empty");
});
|