diff --git a/content/base/test/test_bug382113.html b/content/base/test/test_bug382113.html index 3b78210ec9d..6de62f792e7 100644 --- a/content/base/test/test_bug382113.html +++ b/content/base/test/test_bug382113.html @@ -27,8 +27,8 @@ var objectGotOnload = false; /** Test for Bug 100533 **/ function checkEvents() { - // todo(childGotOnload, true, "Child got load event"); - // todo(objectGotOnload, true, "Object got load event"); + is(childGotOnload, true, "Child got load event"); + is(objectGotOnload, true, "Object got load event"); SimpleTest.finish(); } diff --git a/netwerk/base/src/nsLoadGroup.cpp b/netwerk/base/src/nsLoadGroup.cpp index bf2a4246b67..110f1b90cdf 100644 --- a/netwerk/base/src/nsLoadGroup.cpp +++ b/netwerk/base/src/nsLoadGroup.cpp @@ -534,6 +534,18 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt) } #endif /* PR_LOGGING */ +#ifdef DEBUG + { + RequestMapEntry *entry = + static_cast + (PL_DHashTableOperate(&mRequests, request, + PL_DHASH_LOOKUP)); + + NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(entry), + "Entry added to loadgroup twice, don't do that"); + } +#endif + // // Do not add the channel, if the loadgroup is being canceled... // diff --git a/uriloader/base/nsURILoader.cpp b/uriloader/base/nsURILoader.cpp index 8bb1ed3d3f4..f6e9f644237 100644 --- a/uriloader/base/nsURILoader.cpp +++ b/uriloader/base/nsURILoader.cpp @@ -1,4 +1,5 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sts=2 sw=2 et cin: */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -975,20 +976,21 @@ nsresult nsURILoader::OpenChannel(nsIChannel* channel, // If the channel is pending, then we need to remove it from its current // loadgroup - if (aChannelIsOpen) { - nsCOMPtr oldGroup; - channel->GetLoadGroup(getter_AddRefs(oldGroup)); - if (oldGroup) { + nsCOMPtr oldGroup; + channel->GetLoadGroup(getter_AddRefs(oldGroup)); + if (aChannelIsOpen && !SameCOMIdentity(oldGroup, loadGroup)) { + // It is important to add the channel to the new group before + // removing it from the old one, so that the load isn't considered + // done as soon as the request is removed. + loadGroup->AddRequest(channel, nsnull); + + if (oldGroup) { oldGroup->RemoveRequest(channel, nsnull, NS_BINDING_RETARGETED); } } channel->SetLoadGroup(loadGroup); - if (aChannelIsOpen) { - loadGroup->AddRequest(channel, nsnull); - } - // prepare the loader for receiving data nsresult rv = loader->Prepare(); if (NS_SUCCEEDED(rv))