Bug 482370 - after noupdate documents are associated with the wrong application cache. r+sr=jst

This commit is contained in:
Dave Camp 2009-03-10 14:58:00 -07:00
parent bb3fad06d5
commit 2ddf9e1741
3 changed files with 26 additions and 8 deletions

View File

@ -20,8 +20,14 @@ function manifestUpdated()
window.opener.OfflineTest.ok(true, "Unable to fetch unlisted resource, properly associated.");
}
window.opener.OfflineTest.checkCache("http://localhost:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html",
true);
req = new XMLHttpRequest;
req.open("GET", "updatingImplicit.html", false);
try {
req.send(null);
window.opener.OfflineTest.ok(true, "Able to fetch listed resource, properly associated.");
} catch(ex) {
window.opener.OfflineTest.ok(false, "Unable to fetch listed resource, not properly associated.");
}
window.opener.implicitLoaded(window, false);
}

View File

@ -1371,7 +1371,7 @@ nsOfflineCacheUpdate::LoadCompleted()
mSucceeded = PR_FALSE;
for (PRInt32 i = 0; i < mDocuments.Count(); i++) {
AssociateDocument(mDocuments[i]);
AssociateDocument(mDocuments[i], mPreviousApplicationCache);
}
ScheduleImplicit();
@ -1870,7 +1870,8 @@ nsOfflineCacheUpdate::ScheduleImplicit()
}
nsresult
nsOfflineCacheUpdate::AssociateDocument(nsIDOMDocument *aDocument)
nsOfflineCacheUpdate::AssociateDocument(nsIDOMDocument *aDocument,
nsIApplicationCache *aApplicationCache)
{
// Check that the document that requested this update was
// previously associated with an application cache. If not, it
@ -1885,8 +1886,18 @@ nsOfflineCacheUpdate::AssociateDocument(nsIDOMDocument *aDocument)
NS_ENSURE_SUCCESS(rv, rv);
if (!existingCache) {
LOG(("Update %p: associating app cache %s to document %p", this, mClientID.get(), aDocument));
rv = container->SetApplicationCache(mApplicationCache);
#if defined(PR_LOGGING)
if (LOG_ENABLED()) {
nsCAutoString clientID;
if (aApplicationCache) {
aApplicationCache->GetClientID(clientID);
}
LOG(("Update %p: associating app cache %s to document %p",
this, clientID.get(), aDocument));
}
#endif
rv = container->SetApplicationCache(aApplicationCache);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -1923,7 +1934,7 @@ nsOfflineCacheUpdate::Finish()
}
for (PRInt32 i = 0; i < mDocuments.Count(); i++) {
AssociateDocument(mDocuments[i]);
AssociateDocument(mDocuments[i], mApplicationCache);
}
}

View File

@ -256,7 +256,8 @@ private:
nsresult NotifyDownloading();
nsresult NotifyStarted(nsOfflineCacheUpdateItem *aItem);
nsresult NotifyCompleted(nsOfflineCacheUpdateItem *aItem);
nsresult AssociateDocument(nsIDOMDocument *aDocument);
nsresult AssociateDocument(nsIDOMDocument *aDocument,
nsIApplicationCache *aApplicationCache);
nsresult ScheduleImplicit();
nsresult Finish();