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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that searching history works for both encoded or decoded strings.
add_task(async function test() {
const decoded = "日本";
const TEST_URL = TEST_BASE_URL + "?" + decoded;
registerCleanupFunction(async () => {
await PlacesUtils.history.clear();
});
// Visit url in a new tab, going through normal urlbar workflow.
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
let promise = PlacesTestUtils.waitForNotification("page-visited", visits => {
Assert.equal(
visits.length,
1,
"Was notified for the right number of visits."
);
let { url, transitionType } = visits[0];
return (
url == encodeURI(TEST_URL) &&
transitionType == PlacesUtils.history.TRANSITIONS.TYPED
);
});
gURLBar.focus();
gURLBar.value = TEST_URL;
info("Visiting url");
EventUtils.synthesizeKey("KEY_Enter");
await promise;
gBrowser.removeCurrentTab({ skipPermitUnload: true });
info("Search for the decoded string.");
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: decoded,
});
Assert.equal(
UrlbarTestUtils.getResultCount(window),
2,
"Check number of results"
);
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
Assert.equal(result.url, encodeURI(TEST_URL), "Check result url");
info("Search for the encoded string.");
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: encodeURIComponent(decoded),
});
Assert.equal(
UrlbarTestUtils.getResultCount(window),
2,
"Check number of results"
);
result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
Assert.equal(result.url, encodeURI(TEST_URL), "Check result url");
});
|