Bug 382113 make sure to add the request to the new loadgroup before removing it

from the old one so that onload doesn't fire before it should
Also make nsLoadGroup::AddRequest assert that the request isn't in the loadgroup yet
Finally, reenable the reftest that tests the <object> onload behaviour
r+sr=bz
This commit is contained in:
cbiesinger@gmx.at 2007-07-18 14:37:39 -07:00
Родитель 3f90535472
Коммит 0fdb87f45b
3 изменённых файлов: 24 добавлений и 10 удалений

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

@ -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();
}
</script>

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

@ -534,6 +534,18 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt)
}
#endif /* PR_LOGGING */
#ifdef DEBUG
{
RequestMapEntry *entry =
static_cast<RequestMapEntry *>
(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...
//

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

@ -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<nsILoadGroup> oldGroup;
channel->GetLoadGroup(getter_AddRefs(oldGroup));
if (oldGroup) {
nsCOMPtr<nsILoadGroup> 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))