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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function test_proxy_modes_and_autoconfig() {
// Directly test the proxy Mode and AutoconfigURL parameters through
// the API instead of the policy engine, because the test harness
// uses these prefs, and changing them interfere with the harness.
// Checks that every Mode value translates correctly to the expected pref value
let { ProxyPolicies, PROXY_TYPES_MAP } = ChromeUtils.importESModule(
"resource:///modules/policies/ProxyPolicies.sys.mjs"
);
for (let [mode, expectedValue] of PROXY_TYPES_MAP) {
ProxyPolicies.configureProxySettings({ Mode: mode }, (_, value) => {
equal(value, expectedValue, "Correct proxy mode");
});
}
let autoconfigURL = new URL("data:text/plain,test");
ProxyPolicies.configureProxySettings(
{ AutoConfigURL: autoconfigURL },
(_, value) => {
equal(value, autoconfigURL.href, "AutoconfigURL correctly set");
}
);
});
add_task(async function test_proxy_boolean_settings() {
// Tests that both false and true values are correctly set and locked
await setupPolicyEngineWithJson({
policies: {
Proxy: {
UseProxyForDNS: false,
AutoLogin: false,
},
},
});
checkUnlockedPref("network.proxy.socks_remote_dns", false);
checkUnlockedPref("signon.autologin.proxy", false);
await setupPolicyEngineWithJson({
policies: {
Proxy: {
UseProxyForDNS: true,
AutoLogin: true,
},
},
});
checkUnlockedPref("network.proxy.socks_remote_dns", true);
checkUnlockedPref("signon.autologin.proxy", true);
});
add_task(async function test_proxy_socks_and_passthrough() {
await setupPolicyEngineWithJson({
policies: {
Proxy: {
SOCKSVersion: 4,
Passthrough: "a, b, c",
},
},
});
checkUnlockedPref("network.proxy.socks_version", 4);
checkUnlockedPref("network.proxy.no_proxies_on", "a, b, c");
});
add_task(async function test_proxy_addresses() {
function checkProxyPref(proxytype, address, port) {
checkUnlockedPref(`network.proxy.${proxytype}`, address);
checkUnlockedPref(`network.proxy.${proxytype}_port`, port);
}
await setupPolicyEngineWithJson({
policies: {
Proxy: {
HTTPProxy: "http.proxy.example.com:10",
SSLProxy: "ssl.proxy.example.com:30",
SOCKSProxy: "socks.proxy.example.com:40",
},
},
});
checkProxyPref("http", "http.proxy.example.com", 10);
checkProxyPref("ssl", "ssl.proxy.example.com", 30);
checkProxyPref("socks", "socks.proxy.example.com", 40);
// Do the same, but now use the UseHTTPProxyForAllProtocols option
// and check that it takes effect.
await setupPolicyEngineWithJson({
policies: {
Proxy: {
HTTPProxy: "http.proxy.example.com:10",
// FTP support was removed in bug 1574475
// Setting an FTPProxy should result in a warning but should not fail
FTPProxy: "ftp.proxy.example.com:20",
SSLProxy: "ssl.proxy.example.com:30",
SOCKSProxy: "socks.proxy.example.com:40",
UseHTTPProxyForAllProtocols: true,
},
},
});
checkProxyPref("http", "http.proxy.example.com", 10);
checkProxyPref("ssl", "http.proxy.example.com", 10);
checkProxyPref("socks", "http.proxy.example.com", 10);
// Make sure the FTPProxy setting did nothing
Assert.equal(
Preferences.has("network.proxy.ftp"),
false,
"network.proxy.ftp should not be set"
);
Assert.equal(
Preferences.has("network.proxy.ftp_port"),
false,
"network.proxy.ftp_port should not be set"
);
});
|