|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 function testVal(originalValue, targetValue) { |
|
6 gURLBar.value = originalValue; |
|
7 gURLBar.valueIsTyped = false; |
|
8 is(gURLBar.value, targetValue || originalValue, "url bar value set"); |
|
9 } |
|
10 |
|
11 function test() { |
|
12 const prefname = "browser.urlbar.trimURLs"; |
|
13 |
|
14 gBrowser.selectedTab = gBrowser.addTab(); |
|
15 |
|
16 registerCleanupFunction(function () { |
|
17 gBrowser.removeCurrentTab(); |
|
18 Services.prefs.clearUserPref(prefname); |
|
19 URLBarSetURI(); |
|
20 }); |
|
21 |
|
22 Services.prefs.setBoolPref(prefname, true); |
|
23 |
|
24 testVal("http://mozilla.org/", "mozilla.org"); |
|
25 testVal("https://mozilla.org/", "https://mozilla.org"); |
|
26 testVal("http://mözilla.org/", "mözilla.org"); |
|
27 testVal("http://mozilla.imaginatory/", "mozilla.imaginatory"); |
|
28 testVal("http://www.mozilla.org/", "www.mozilla.org"); |
|
29 testVal("http://sub.mozilla.org/", "sub.mozilla.org"); |
|
30 testVal("http://sub1.sub2.sub3.mozilla.org/", "sub1.sub2.sub3.mozilla.org"); |
|
31 testVal("http://mozilla.org/file.ext", "mozilla.org/file.ext"); |
|
32 testVal("http://mozilla.org/sub/", "mozilla.org/sub/"); |
|
33 |
|
34 testVal("http://ftp.mozilla.org/", "http://ftp.mozilla.org"); |
|
35 testVal("http://ftp1.mozilla.org/", "http://ftp1.mozilla.org"); |
|
36 testVal("http://ftp42.mozilla.org/", "http://ftp42.mozilla.org"); |
|
37 testVal("http://ftpx.mozilla.org/", "ftpx.mozilla.org"); |
|
38 testVal("ftp://ftp.mozilla.org/", "ftp://ftp.mozilla.org"); |
|
39 testVal("ftp://ftp1.mozilla.org/", "ftp://ftp1.mozilla.org"); |
|
40 testVal("ftp://ftp42.mozilla.org/", "ftp://ftp42.mozilla.org"); |
|
41 testVal("ftp://ftpx.mozilla.org/", "ftp://ftpx.mozilla.org"); |
|
42 |
|
43 testVal("https://user:pass@mozilla.org/", "https://user:pass@mozilla.org"); |
|
44 testVal("http://user:pass@mozilla.org/", "http://user:pass@mozilla.org"); |
|
45 testVal("http://sub.mozilla.org:666/", "sub.mozilla.org:666"); |
|
46 |
|
47 testVal("https://[fe80::222:19ff:fe11:8c76]/file.ext"); |
|
48 testVal("http://[fe80::222:19ff:fe11:8c76]/", "[fe80::222:19ff:fe11:8c76]"); |
|
49 testVal("https://user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext"); |
|
50 testVal("http://user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext"); |
|
51 |
|
52 testVal("mailto:admin@mozilla.org"); |
|
53 testVal("gopher://mozilla.org/"); |
|
54 testVal("about:config"); |
|
55 testVal("jar:http://mozilla.org/example.jar!/"); |
|
56 testVal("view-source:http://mozilla.org/"); |
|
57 |
|
58 Services.prefs.setBoolPref(prefname, false); |
|
59 |
|
60 testVal("http://mozilla.org/"); |
|
61 |
|
62 Services.prefs.setBoolPref(prefname, true); |
|
63 |
|
64 waitForExplicitFinish(); |
|
65 |
|
66 gBrowser.selectedBrowser.addEventListener("load", function () { |
|
67 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
|
68 |
|
69 is(gBrowser.currentURI.spec, "http://example.com/", "expected page should have loaded"); |
|
70 |
|
71 testCopy("example.com", "http://example.com/", function () { |
|
72 SetPageProxyState("invalid"); |
|
73 gURLBar.valueIsTyped = true; |
|
74 testCopy("example.com", "example.com", finish); |
|
75 }); |
|
76 }, true); |
|
77 |
|
78 gBrowser.loadURI("http://example.com/"); |
|
79 } |
|
80 |
|
81 function testCopy(originalValue, targetValue, cb) { |
|
82 waitForClipboard(targetValue, function () { |
|
83 is(gURLBar.value, originalValue, "url bar copy value set"); |
|
84 |
|
85 gURLBar.focus(); |
|
86 gURLBar.select(); |
|
87 goDoCommand("cmd_copy"); |
|
88 }, cb, cb); |
|
89 } |