Bug 730424 - window.applicationCache.status not getting updated when resources finish loading, r=michal

This commit is contained in:
Honza Bambas 2013-05-01 18:57:58 +02:00
parent 27a0068bcb
commit 433cb50458
3 changed files with 24 additions and 0 deletions

View File

@ -86,6 +86,7 @@ nsDOMOfflineResourceList::nsDOMOfflineResourceList(nsIURI *aManifestURI,
, mManifestURI(aManifestURI)
, mDocumentURI(aDocumentURI)
, mExposeCacheUpdateStatus(true)
, mDontSetDocumentCache(false)
, mStatus(nsIDOMOfflineResourceList::IDLE)
, mCachedKeys(nullptr)
, mCachedKeysCount(0)
@ -449,6 +450,10 @@ nsDOMOfflineResourceList::Update()
window, getter_AddRefs(update));
NS_ENSURE_SUCCESS(rv, rv);
// Since we are invoking the cache update, cache on the document must not
// be updated until swapCache() method is called on applicationCache object.
mDontSetDocumentCache = true;
return NS_OK;
}
@ -620,6 +625,15 @@ NS_IMETHODIMP
nsDOMOfflineResourceList::ApplicationCacheAvailable(nsIApplicationCache *aApplicationCache)
{
mAvailableApplicationCache = aApplicationCache;
if (!mDontSetDocumentCache) {
nsCOMPtr<nsIApplicationCacheContainer> appCacheContainer =
GetDocumentAppCacheContainer();
if (appCacheContainer)
appCacheContainer->SetApplicationCache(aApplicationCache);
}
return NS_OK;
}
@ -718,6 +732,7 @@ nsDOMOfflineResourceList::UpdateCompleted(nsIOfflineCacheUpdate *aUpdate)
mCacheUpdate->RemoveObserver(this);
mCacheUpdate = nullptr;
mDontSetDocumentCache = false;
if (NS_SUCCEEDED(rv) && succeeded && !partial) {
if (isUpgrade) {

View File

@ -79,6 +79,7 @@ private:
nsCOMPtr<nsIApplicationCache> mAvailableApplicationCache;
nsCOMPtr<nsIOfflineCacheUpdate> mCacheUpdate;
bool mExposeCacheUpdateStatus;
bool mDontSetDocumentCache;
uint16_t mStatus;
// The set of dynamic keys for this application cache object.

View File

@ -502,6 +502,14 @@ nsOfflineCacheUpdateService::Schedule(nsIURI *aManifestURI,
nsresult rv;
if (aWindow) {
// Ensure there is window.applicationCache object that is
// responsible for association of the new applicationCache
// with the corresponding document. Just ignore the result.
nsCOMPtr<nsIDOMOfflineResourceList> appCacheWindowObject;
aWindow->GetApplicationCache(getter_AddRefs(appCacheWindowObject));
}
rv = update->Init(aManifestURI, aDocumentURI, aDocument,
aCustomProfileDir, aAppID, aInBrowser);
NS_ENSURE_SUCCESS(rv, rv);