Bug 1560703 - Make sure creating an FTP channel throws if FTP is disabled r=michal

Previously we would throw in nsFtpProtocolHandler::NewURI. Since that doesn't exist anymore, and creating FTP URLs always works, we need to make sure creating the FTP channel doesn't work anymore.

Differential Revision: https://phabricator.services.mozilla.com/D35642

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Valentin Gosu 2019-06-24 10:20:16 +00:00
Родитель 01825c70a5
Коммит 11362784ca
3 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -151,6 +151,10 @@ nsFtpProtocolHandler::NewProxiedChannel(nsIURI* uri, nsIProxyInfo* proxyInfo,
nsIURI* proxyURI,
nsILoadInfo* aLoadInfo,
nsIChannel** result) {
if (!mEnabled) {
return NS_ERROR_UNKNOWN_PROTOCOL;
}
NS_ENSURE_ARG_POINTER(uri);
RefPtr<nsBaseChannel> channel;
if (IsNeckoChild())

Просмотреть файл

@ -0,0 +1,12 @@
registerCleanupFunction(function() {
Services.prefs.clearUserPref("network.ftp.enabled");
});
add_task(async function ftp_disabled() {
Services.prefs.setBoolPref("network.ftp.enabled", false);
let chan = null;
Assert.throws(() => { chan = NetUtil.newChannel({uri: "ftp://ftp.de.debian.org/", loadUsingSystemPrincipal: true})
.QueryInterface(Ci.nsIHttpChannel); },
/NS_ERROR_UNKNOWN_PROTOCOL/, "creating the FTP channel must throw");
});

Просмотреть файл

@ -456,3 +456,5 @@ run-sequentially = one http2 node proxy is used for all tests, this test is usin
# so far has to be disabled until we update nodejs to at least 8.4+, then keep off on android (os == "android")
skip-if = true
[test_head_request_no_response_body.js]
[test_disabled_ftp.js]