зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1387094 - Add noProxy support for manual proxy type. r=ato
MozReview-Commit-ID: 1C9sFgrno4i --HG-- extra : rebase_source : 4182535b4dc5660966856adc250e38c08e009623
This commit is contained in:
Родитель
e94809441d
Коммит
476c801003
|
@ -78,6 +78,25 @@ class TestProxyCapabilities(MarionetteTestCase):
|
|||
with self.assertRaises(errors.SessionNotCreatedException):
|
||||
self.marionette.start_session(capabilities)
|
||||
|
||||
def test_proxy_type_manual_no_proxy_on(self):
|
||||
capabilities = {"proxy": {
|
||||
"proxyType": "manual",
|
||||
"noProxy": ["foo", "bar"],
|
||||
}}
|
||||
|
||||
self.marionette.start_session(capabilities)
|
||||
self.assertEqual(self.marionette.session_capabilities["proxy"],
|
||||
capabilities["proxy"])
|
||||
|
||||
def test_proxy_type_manual_invalid_no_proxy_on(self):
|
||||
capabilities = {"proxy": {
|
||||
"proxyType": "manual",
|
||||
"noProxy": "foo, bar",
|
||||
}}
|
||||
|
||||
with self.assertRaises(errors.SessionNotCreatedException):
|
||||
self.marionette.start_session(capabilities)
|
||||
|
||||
def test_proxy_type_pac(self):
|
||||
pac_url = "http://marionette.test"
|
||||
capabilities = {"proxy": {"proxyType": "pac", "proxyAutoconfigUrl": pac_url}}
|
||||
|
|
|
@ -114,6 +114,7 @@ session.Proxy = class {
|
|||
this.ftpProxyPort = null;
|
||||
this.httpProxy = null;
|
||||
this.httpProxyPort = null;
|
||||
this.noProxy = null;
|
||||
this.sslProxy = null;
|
||||
this.sslProxyPort = null;
|
||||
this.socksProxy = null;
|
||||
|
@ -173,6 +174,10 @@ session.Proxy = class {
|
|||
Preferences.set("network.proxy.socks_version", this.socksVersion);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.noProxy && this.noProxy.length > 0) {
|
||||
Preferences.set("network.proxy.no_proxies_on", this.noProxy.join(", "));
|
||||
}
|
||||
return true;
|
||||
|
||||
case "pac":
|
||||
|
@ -278,6 +283,13 @@ session.Proxy = class {
|
|||
[p.socksProxy, p.socksProxyPort] = fromHost("socks", json.socksProxy);
|
||||
p.socksVersion = assert.positiveInteger(json.socksVersion);
|
||||
}
|
||||
if (typeof json.noProxy != "undefined") {
|
||||
let entries = assert.array(json.noProxy);
|
||||
for (let entry of entries) {
|
||||
assert.string(entry);
|
||||
}
|
||||
p.noProxy = entries;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -309,6 +321,7 @@ session.Proxy = class {
|
|||
proxyType: this.proxyType,
|
||||
ftpProxy: toHost(this.ftpProxy, this.ftpProxyPort),
|
||||
httpProxy: toHost(this.httpProxy, this.httpProxyPort),
|
||||
noProxy: this.noProxy,
|
||||
sslProxy: toHost(this.sslProxy, this.sslProxyPort),
|
||||
socksProxy: toHost(this.socksProxy, this.socksProxyPort),
|
||||
socksVersion: this.socksVersion,
|
||||
|
|
|
@ -150,6 +150,7 @@ add_test(function test_Proxy_init() {
|
|||
for (let proxy of ["ftp", "http", "ssl", "socks"]) {
|
||||
p = new session.Proxy();
|
||||
p.proxyType = "manual";
|
||||
p.noProxy = ["foo", "bar"];
|
||||
p[`${proxy}Proxy`] = "foo";
|
||||
p[`${proxy}ProxyPort`] = 42;
|
||||
if (proxy === "socks") {
|
||||
|
@ -158,6 +159,7 @@ add_test(function test_Proxy_init() {
|
|||
|
||||
ok(p.init());
|
||||
equal(Preferences.get("network.proxy.type"), 1);
|
||||
equal(Preferences.get("network.proxy.no_proxies_on"), "foo, bar");
|
||||
equal(Preferences.get(`network.proxy.${proxy}`), "foo");
|
||||
equal(Preferences.get(`network.proxy.${proxy}_port`), 42);
|
||||
if (proxy === "socks") {
|
||||
|
@ -278,6 +280,20 @@ add_test(function test_Proxy_fromJSON() {
|
|||
{proxyType: "manual", socksProxy: "foo:1234"}),
|
||||
InvalidArgumentError);
|
||||
|
||||
// invalid noProxy
|
||||
for (let noProxy of [true, 42, {}, null, "foo",
|
||||
[true], [42], [{}], [null]]) {
|
||||
Assert.throws(() => session.Proxy.fromJSON(
|
||||
{proxyType: "manual", noProxy: noProxy}),
|
||||
InvalidArgumentError);
|
||||
}
|
||||
|
||||
// valid noProxy
|
||||
for (let noProxy of [[], ["foo"], ["foo", "bar"]]) {
|
||||
let manual = {proxyType: "manual", "noProxy": noProxy}
|
||||
deepEqual(manual, session.Proxy.fromJSON(manual).toJSON());
|
||||
}
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче