Bug 1195713 - Set the proper notification callbacks for the inner channel. r=valentin

This commit is contained in:
Henry Chang 2015-08-31 17:47:10 +08:00
parent f9cd1e824b
commit 99c5fbf41e
2 changed files with 18 additions and 1 deletions

View File

@ -16,6 +16,7 @@
#include "mozilla/Logging.h"
#include "mozilla/DebugOnly.h"
#include "nsIHttpHeaderVisitor.h"
#include "mozilla/LoadContext.h"
namespace mozilla {
namespace net {
@ -811,6 +812,12 @@ PackagedAppService::GetResource(nsIChannel *aChannel,
nsRefPtr<PackagedAppChannelListener> listener =
new PackagedAppChannelListener(downloader, mimeConverter);
nsCOMPtr<nsIInterfaceRequestor> loadContext;
aChannel->GetNotificationCallbacks(getter_AddRefs(loadContext));
if (loadContext) {
channel->SetNotificationCallbacks(loadContext);
}
if (loadInfo && loadInfo->GetEnforceSecurity()) {
return channel->AsyncOpen2(listener);
}

View File

@ -123,14 +123,20 @@ function run_test()
do_register_cleanup(reset_pref);
add_test(test_channel);
add_test(test_channel_no_notificationCallbacks);
add_test(test_channel_uris);
// run tests
run_next_test();
}
function test_channel() {
function test_channel(aNullNotificationCallbacks) {
var channel = make_channel(uri+"/package!//index.html");
if (!aNullNotificationCallbacks) {
channel.notificationCallbacks = new LoadContextCallback(1024, false, false, false);
}
channel.asyncOpen(new Listener(function(l) {
// XXX: no content length available for this resource
//do_check_true(channel.contentLength > 0);
@ -140,6 +146,10 @@ function test_channel() {
}), null);
}
function test_channel_no_notificationCallbacks() {
test_channel(true);
}
function test_channel_uris() {
// A `!//` in the query or ref should not be handled as a packaged app resource
var channel = make_channel(uri+"/regular?bla!//bla#bla!//bla");