Bug 1359417 - WebExtensions ProxyAPI uses HTTPS proxy instead of HTTP proxy
MozReview-Commit-ID: 4IAyPMcGk3V
--- a/toolkit/components/extensions/ProxyScriptContext.jsm
+++ b/toolkit/components/extensions/ProxyScriptContext.jsm
@@ -191,22 +191,21 @@ class ProxyScriptContext extends BaseCon
let [host, port] = parts[1].split(":");
if (!host || !port) {
this.extension.emit("proxy-error", {
message: `FindProxyForURL: Unable to parse argument for ${rule}`,
});
return null;
}
- if (parts[0] == PROXY_TYPES.HTTP) {
+ let type = parts[0];
+ if (parts[0] == PROXY_TYPES.PROXY) {
// PROXY_TYPES.HTTP and PROXY_TYPES.PROXY are synonyms
- type = PROXY_TYPES.PROXY;
- }
- else {
- type = parts[0];
+ // but ProxyService.newProxyInfo() does not accept "proxy"
+ type = PROXY_TYPES.HTTP;
}
let failoverProxy = this.createProxyInfo(rules.slice(1));
return ProxyService.newProxyInfo(type, host, port, 0,
PROXY_TIMEOUT_SEC, failoverProxy);
case PROXY_TYPES.DIRECT:
return null;
default:
--- a/toolkit/components/extensions/test/xpcshell/test_proxy_scripts.js
+++ b/toolkit/components/extensions/test/xpcshell/test_proxy_scripts.js
@@ -161,38 +161,43 @@ add_task(function* testSocksReturnType()
scriptData() {
function FindProxyForURL(url, host) {
if (host === "www.mozilla.org") {
return "SOCKS 4.4.4.4:9002";
}
}
},
}, {
- proxyInfo: null,
+ proxyInfo: {
+ host: "4.4.4.4",
+ port: "9002",
+ type: "socks",
+ failoverProxy: null,
+ },
});
});
-add_task(function* testSocksReturnType() {
+add_task(function* testSocksReturnTypeNoConditional() {
yield testProxyScript({
scriptData() {
function FindProxyForURL(url, host) {
- return "SOCKS 4.4.4.4:1080";
+ return "SOCKS foo.bar:1080";
}
},
}, {
proxyInfo: {
- host: "mozilla.com",
+ host: "foo.bar",
port: "1080",
type: "socks",
failoverProxy: null,
},
});
});
-add_task(function* testSocksReturnType() {
+add_task(function* testSocks4ReturnType() {
yield testProxyScript({
scriptData() {
function FindProxyForURL(url, host) {
return "SOCKS4 1.2.3.4:1080";
}
},
}, {
proxyInfo: {
@@ -214,34 +219,17 @@ add_task(function* testProxyReturnType()
}, {
proxyInfo: {
host: "1.2.3.4",
port: "8080",
type: "http",
failoverProxy: null,
},
});
-});
-
-add_task(function* testProxyReturnType() {
- yield testProxyScript({
- scriptData() {
- function FindProxyForURL(url, host) {
- return "HTTP 1.2.3.4:8080";
- }
- },
- }, {
- proxyInfo: {
- host: "1.2.3.4",
- port: "8080",
- type: "http",
- failoverProxy: null,
- },
- });
-});
+});
add_task(function* testUnusualWhitespaceForFindProxyForURL() {
yield testProxyScript({
scriptData() {
function FindProxyForURL(url, host) {
return " PROXY 1.2.3.4:8080 ";
}
},