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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
add_setup(async function () {
await gCUITestUtils.addSearchBar();
await clearSearchbarHistory();
await SearchTestUtils.installSearchExtension(
{
id: "test",
name: "test",
suggest_url:
"https://example.com/browser/browser/components/search/test/browser/searchSuggestionEngine.sjs",
suggest_url_get_params: "query={searchTerms}",
},
{ setAsDefault: true }
);
registerCleanupFunction(async () => {
await clearSearchbarHistory();
gCUITestUtils.removeSearchBar();
});
});
async function check_results(input, expected) {
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: "about:blank",
},
async browser => {
let popup = await searchInSearchbar(input);
const listItemElems = popup.richlistbox.querySelectorAll(
".autocomplete-richlistitem"
);
Assert.deepEqual(
Array.from(listItemElems)
.filter(e => !e.collapsed)
.map(e => e.getAttribute("title")),
expected,
"Should have received the expected suggestions"
);
// Now visit the search to put an item in form history.
let p = BrowserTestUtils.browserLoaded(browser);
EventUtils.synthesizeKey("KEY_Enter");
await p;
}
);
}
add_task(async function test_utf8_results() {
await check_results("。", ["。foo", "。bar"]);
// The first run added the entry into form history, check that is correct
// as well.
await check_results("。", ["。", "。foo", "。bar"]);
});
|