|
1 function test() { |
|
2 waitForExplicitFinish(); |
|
3 testNext(); |
|
4 } |
|
5 |
|
6 var pairs = [ |
|
7 ["example", "http://www.example.net/"], |
|
8 ["ex-ample", "http://www.ex-ample.net/"], |
|
9 [" example ", "http://www.example.net/"], |
|
10 [" example/foo ", "http://www.example.net/foo"], |
|
11 [" example/foo bar ", "http://www.example.net/foo%20bar"], |
|
12 ["example.net", "http://example.net/"], |
|
13 ["http://example", "http://example/"], |
|
14 ["example:8080", "http://example:8080/"], |
|
15 ["ex-ample.foo", "http://ex-ample.foo/"], |
|
16 ["example.foo/bar ", "http://example.foo/bar"], |
|
17 ["1.1.1.1", "http://1.1.1.1/"], |
|
18 ["ftp://example", "ftp://example/"], |
|
19 ["ftp.example.bar", "ftp://ftp.example.bar/"], |
|
20 ["ex ample", Services.search.defaultEngine.getSubmission("ex ample", null, "keyword").uri.spec], |
|
21 ]; |
|
22 |
|
23 function testNext() { |
|
24 if (!pairs.length) { |
|
25 finish(); |
|
26 return; |
|
27 } |
|
28 |
|
29 let [inputValue, expectedURL] = pairs.shift(); |
|
30 |
|
31 gBrowser.addProgressListener({ |
|
32 onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { |
|
33 if (aStateFlags & Ci.nsIWebProgressListener.STATE_START && |
|
34 aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { |
|
35 is(aRequest.originalURI.spec, expectedURL, |
|
36 "entering '" + inputValue + "' loads expected URL"); |
|
37 |
|
38 gBrowser.removeProgressListener(this); |
|
39 gBrowser.stop(); |
|
40 |
|
41 executeSoon(testNext); |
|
42 } |
|
43 } |
|
44 }); |
|
45 |
|
46 gURLBar.addEventListener("focus", function onFocus() { |
|
47 gURLBar.removeEventListener("focus", onFocus); |
|
48 EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }); |
|
49 }); |
|
50 |
|
51 gBrowser.selectedBrowser.focus(); |
|
52 gURLBar.inputField.value = inputValue; |
|
53 gURLBar.focus(); |
|
54 } |