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
|
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// When strings containing URLs are entered into the webconsole,
// check its output and ensure that the output can be clicked to open those URLs.
"use strict";
const TEST_URI = "data:text/html;charset=utf8,Bug 1005909 - Clickable URLS";
let inputTests = [
// 0: URL opens page when clicked.
{
input: "'http://example.com'",
output: "http://example.com",
expectedTab: "http://example.com/",
},
// 1: URL opens page using https when clicked.
{
input: "'https://example.com'",
output: "https://example.com",
expectedTab: "https://example.com/",
},
// 2: URL with port opens page when clicked.
{
input: "'https://example.com:443'",
output: "https://example.com:443",
expectedTab: "https://example.com/",
},
// 3: URL containing non-empty path opens page when clicked.
{
input: "'http://example.com/foo'",
output: "http://example.com/foo",
expectedTab: "http://example.com/foo",
},
// 4: URL opens page when clicked, even when surrounded by non-URL tokens.
{
input: "'foo http://example.com bar'",
output: "foo http://example.com bar",
expectedTab: "http://example.com/",
},
// 5: URL opens page when clicked, and whitespace is be preserved.
{
input: "'foo\\nhttp://example.com\\nbar'",
output: "foo\nhttp://example.com\nbar",
expectedTab: "http://example.com/",
},
// 6: URL opens page when clicked when multiple links are present.
{
input: "'http://example.com http://example.com'",
output: "http://example.com http://example.com",
expectedTab: "http://example.com/",
},
// 7: URL without scheme does not open page when clicked.
{
input: "'example.com'",
output: "example.com",
},
// 8: URL with invalid scheme does not open page when clicked.
{
input: "'foo://example.com'",
output: "foo://example.com",
},
];
function test() {
Task.spawn(function*() {
let {tab} = yield loadTab(TEST_URI);
let hud = yield openConsole(tab);
yield checkOutputForInputs(hud, inputTests);
inputTests = null;
}).then(finishTest);
}
|