зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1552248 support ftp channel in proxy api r=mayhemer,kmag
ChannelWrapper is used throughout webext APIs and it requires a channel to support weakref. FTPChannel did not, thus ftp requests did not go through proxy.onRequest. Differential Revision: https://phabricator.services.mozilla.com/D31540 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
eb97e60e6c
Коммит
636c68369c
|
@ -27,6 +27,7 @@ extern LazyLogModule gFTPLog;
|
|||
NS_IMPL_ISUPPORTS_INHERITED(nsFtpChannel, nsBaseChannel, nsIUploadChannel,
|
||||
nsIResumableChannel, nsIFTPChannel,
|
||||
nsIProxiedChannel, nsIForcePendingChannel,
|
||||
nsISupportsWeakReference,
|
||||
nsIChannelWithDivertableParentListener)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "nsIProxyInfo.h"
|
||||
#include "nsIProxiedChannel.h"
|
||||
#include "nsIResumableChannel.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsIURI;
|
||||
using mozilla::net::ADivertableParentChannel;
|
||||
|
@ -28,6 +29,7 @@ class nsFtpChannel final : public nsBaseChannel,
|
|||
public nsIResumableChannel,
|
||||
public nsIProxiedChannel,
|
||||
public nsIForcePendingChannel,
|
||||
public nsSupportsWeakReference,
|
||||
public nsIChannelWithDivertableParentListener {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
|
|
@ -158,7 +158,6 @@ async function getExtension(expectedProxyInfo) {
|
|||
browser.proxy.onRequest.addListener(details => {
|
||||
return proxyInfo;
|
||||
}, {urls: ["<all_urls>"]});
|
||||
browser.test.sendMessage("ready");
|
||||
}
|
||||
let extensionData = {
|
||||
manifest: {
|
||||
|
@ -168,7 +167,6 @@ async function getExtension(expectedProxyInfo) {
|
|||
};
|
||||
let extension = ExtensionTestUtils.loadExtension(extensionData);
|
||||
await extension.startup();
|
||||
await extension.awaitMessage("ready");
|
||||
return extension;
|
||||
}
|
||||
|
||||
|
@ -189,3 +187,15 @@ add_task(async function test_passthrough() {
|
|||
equal(proxyInfo, null, `expected no proxy`);
|
||||
await ext1.unload();
|
||||
});
|
||||
|
||||
add_task(async function test_ftp() {
|
||||
let extension = await getExtension({host: "1.2.3.4", port: 8888, type: "http"});
|
||||
|
||||
let proxyInfo = await getProxyInfo("ftp://somewhere.mozilla.org/");
|
||||
|
||||
equal(proxyInfo.host, "1.2.3.4", `proxy host correct`);
|
||||
equal(proxyInfo.port, "8888", `proxy port correct`);
|
||||
equal(proxyInfo.type, "http", `proxy type correct`);
|
||||
|
||||
await extension.unload();
|
||||
});
|
||||
|
|
|
@ -56,14 +56,14 @@ async function setupProxyScript(proxy) {
|
|||
}
|
||||
|
||||
async function testProxyResolution(test) {
|
||||
let {proxy, expected} = test;
|
||||
let {uri, proxy, expected} = test;
|
||||
let errorMsg;
|
||||
if (expected.error) {
|
||||
errorMsg = extension.awaitMessage("proxy-error-received");
|
||||
}
|
||||
let proxyInfo = await new Promise((resolve, reject) => {
|
||||
let channel = NetUtil.newChannel({
|
||||
uri: "http://www.mozilla.org/",
|
||||
uri,
|
||||
loadUsingSystemPrincipal: true,
|
||||
});
|
||||
|
||||
|
@ -202,6 +202,18 @@ add_task(async function test_pac_results() {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
uri: "ftp://mozilla.org",
|
||||
proxy: "PROXY 1.2.3.4:8080",
|
||||
expected: {
|
||||
proxyInfo: {
|
||||
host: "1.2.3.4",
|
||||
port: "8080",
|
||||
type: "http",
|
||||
failoverProxy: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
proxy: " PROXY 2.3.4.5:8080 ",
|
||||
expected: {
|
||||
|
@ -329,6 +341,9 @@ add_task(async function test_pac_results() {
|
|||
];
|
||||
for (let test of tests) {
|
||||
await setupProxyScript(test.proxy);
|
||||
if (!test.uri) {
|
||||
test.uri = "http://www.mozilla.org/";
|
||||
}
|
||||
await testProxyResolution(test);
|
||||
// Our proxy script for testing is stateless, so repeating the test should
|
||||
// yield exactly the same results.
|
||||
|
|
Загрузка…
Ссылка в новой задаче