зеркало из https://github.com/mozilla/gecko-dev.git
Bug 949667 - crash in mozilla::net::HttpChannelParent::OnStartRequest, fail redirect to unsupported protocol on child process, r=jduell
This commit is contained in:
Родитель
27dbc599b4
Коммит
8ee832cff4
|
@ -744,13 +744,15 @@ HttpChannelChild::Redirect1Begin(const uint32_t& newChannelId,
|
|||
mRedirectChannelChild = do_QueryInterface(newChannel);
|
||||
if (mRedirectChannelChild) {
|
||||
mRedirectChannelChild->ConnectParent(newChannelId);
|
||||
rv = gHttpHandler->AsyncOnChannelRedirect(this,
|
||||
newChannel,
|
||||
redirectFlags);
|
||||
} else {
|
||||
NS_ERROR("Redirecting to a protocol that doesn't support universal protocol redirect");
|
||||
LOG((" redirecting to a protocol that doesn't implement"
|
||||
" nsIChildChannel"));
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = gHttpHandler->AsyncOnChannelRedirect(this,
|
||||
newChannel,
|
||||
redirectFlags);
|
||||
if (NS_FAILED(rv))
|
||||
OnRedirectVerifyCallback(rv);
|
||||
}
|
||||
|
|
|
@ -185,6 +185,10 @@ HttpChannelParentListener::OnRedirectResult(bool succeeded)
|
|||
mRedirectChannelId = 0;
|
||||
}
|
||||
|
||||
if (!redirectChannel) {
|
||||
succeeded = false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIParentRedirectingChannel> activeRedirectingChannel =
|
||||
do_QueryInterface(mActiveChannel);
|
||||
MOZ_ASSERT(activeRedirectingChannel,
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
Cu.import("resource://testing-common/httpd.js");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpServer.identity.primaryPort;
|
||||
});
|
||||
|
||||
var httpServer = null;
|
||||
// Need to randomize, because apparently no one clears our cache
|
||||
var randomPath = "/redirect/" + Math.random();
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "randomURI", function() {
|
||||
return URL + randomPath;
|
||||
});
|
||||
|
||||
function inChildProcess() {
|
||||
return Cc["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel(url, "", null);
|
||||
}
|
||||
|
||||
const redirectTargetBody = "response body";
|
||||
const response301Body = "redirect body";
|
||||
|
||||
function redirectHandler(metadata, response)
|
||||
{
|
||||
response.setStatusLine(metadata.httpVersion, 301, "Moved");
|
||||
response.bodyOutputStream.write(response301Body, response301Body.length);
|
||||
response.setHeader("Location", "data:text/plain," + redirectTargetBody, false);
|
||||
}
|
||||
|
||||
function finish_test(request, buffer)
|
||||
{
|
||||
if (inChildProcess()) {
|
||||
// redirects to protocols other than http/ftp will fail until bug 590682 is fixed.
|
||||
do_check_eq(buffer, response301Body);
|
||||
} else {
|
||||
do_check_eq(buffer, redirectTargetBody);
|
||||
}
|
||||
|
||||
httpServer.stop(do_test_finished);
|
||||
}
|
||||
|
||||
function run_test()
|
||||
{
|
||||
httpServer = new HttpServer();
|
||||
httpServer.registerPathHandler(randomPath, redirectHandler);
|
||||
httpServer.start(-1);
|
||||
|
||||
var chan = make_channel(randomURI);
|
||||
chan.asyncOpen(new ChannelListener(finish_test, null, 0), null);
|
||||
do_test_pending();
|
||||
}
|
|
@ -259,6 +259,7 @@ fail-if = os == "android"
|
|||
[test_redirect_passing.js]
|
||||
[test_redirect_loop.js]
|
||||
[test_redirect_baduri.js]
|
||||
[test_redirect_different-protocol.js]
|
||||
[test_reentrancy.js]
|
||||
[test_reopen.js]
|
||||
[test_resumable_channel.js]
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
//
|
||||
// Run test script in content process instead of chrome (xpcshell's default)
|
||||
//
|
||||
|
||||
function run_test() {
|
||||
run_test_in_child("../unit/test_redirect_different-protocol.js");
|
||||
}
|
|
@ -26,6 +26,7 @@ support-files = disabled_test_bug528292_wrap.js
|
|||
[test_redirect_from_script_wrap.js]
|
||||
skip-if = true
|
||||
[test_redirect_passing_wrap.js]
|
||||
[test_redirect_different-protocol_wrap.js]
|
||||
[test_reentrancy_wrap.js]
|
||||
[test_resumable_channel_wrap.js]
|
||||
[test_simple_wrap.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче