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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests for the paste and go functionality of the urlbar.
*/
add_task(async function () {
const kURLs = [
"http://example.com/1",
"http://example.org/2\n",
"http://\nexample.com/3\n",
];
for (let url of kURLs) {
await BrowserTestUtils.withNewTab("about:blank", async function (browser) {
gURLBar.focus();
await SimpleTest.promiseClipboardChange(url, () => {
clipboardHelper.copyString(url);
});
let menuitem = await promiseContextualMenuitem("paste-and-go");
let browserLoadedPromise = BrowserTestUtils.browserLoaded(
browser,
false,
url.replace(/\n/g, "")
);
menuitem.closest("menupopup").activateItem(menuitem);
// Using toSource in order to get the newlines escaped:
info("Paste and go, loading " + url.toSource());
await browserLoadedPromise;
ok(true, "Successfully loaded " + url);
});
}
});
add_task(async function test_invisible_char() {
const url = "http://example.com/4\u2028";
await BrowserTestUtils.withNewTab("about:blank", async function (browser) {
gURLBar.focus();
await SimpleTest.promiseClipboardChange(url, () => {
clipboardHelper.copyString(url);
});
let menuitem = await promiseContextualMenuitem("paste-and-go");
let browserLoadedPromise = BrowserTestUtils.browserLoaded(
browser,
false,
url.replace(/\u2028/g, "")
);
menuitem.closest("menupopup").activateItem(menuitem);
// Using toSource in order to get the newlines escaped:
info("Paste and go, loading " + url.toSource());
await browserLoadedPromise;
ok(true, "Successfully loaded " + url);
});
});
add_task(async function test_with_input_and_results() {
// Test paste and go When there's some input and the results pane is open.
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "foo",
});
const url = "http://example.com/";
await SimpleTest.promiseClipboardChange(url, () => {
clipboardHelper.copyString(url);
});
let menuitem = await promiseContextualMenuitem("paste-and-go");
let browserLoadedPromise = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
url
);
menuitem.closest("menupopup").activateItem(menuitem);
// Using toSource in order to get the newlines escaped:
info("Paste and go, loading " + url.toSource());
await browserLoadedPromise;
ok(true, "Successfully loaded " + url);
});
|