Bug 696591: Properly handle blocking databases from pages that are entering the bfcache. r=bent,bz

This commit is contained in:
Kyle Huey 2012-12-20 06:18:03 -08:00
parent 309e48cc08
commit dc63804499
3 changed files with 35 additions and 1 deletions

View File

@ -464,8 +464,22 @@ public:
return GetBFCacheEntry() ? nullptr : mPresShell;
}
void DisallowBFCaching()
{
NS_ASSERTION(!mBFCacheEntry, "We're already in the bfcache!");
mBFCacheDisallowed = true;
}
bool IsBFCachingAllowed() const
{
return !mBFCacheDisallowed;
}
void SetBFCacheEntry(nsIBFCacheEntry* aEntry)
{
NS_ASSERTION(IsBFCachingAllowed() || !aEntry,
"You should have checked!");
mBFCacheEntry = aEntry;
}
@ -1916,6 +1930,9 @@ protected:
// True if a document has loaded Mixed Active Script (see nsMixedContentBlocker.cpp)
bool mHasMixedActiveContentLoaded;
// True if DisallowBFCaching has been called on this document.
bool mBFCacheDisallowed;
// The document's script global object, the object from which the
// document can get its script context and scope. This is the
// *inner* window object.

View File

@ -1511,6 +1511,23 @@ public:
continue;
}
// Next check if it's in the process of being bfcached.
nsPIDOMWindow* owner = database->GetOwner();
if (owner && owner->IsFrozen()) {
// We can't kick the document out of the bfcache because it's not yet
// fully in the bfcache. Instead we'll abort everything for the window
// and mark it as not-bfcacheable.
indexedDB::IndexedDatabaseManager* manager =
indexedDB::IndexedDatabaseManager::Get();
NS_ASSERTION(manager, "Huh?");
manager->AbortCloseDatabasesForWindow(owner);
NS_ASSERTION(database->IsClosed(),
"AbortCloseDatabasesForWindow should have closed database");
ownerDoc->DisallowBFCaching();
continue;
}
// Otherwise fire a versionchange event.
nsRefPtr<nsDOMEvent> event =
IDBVersionChangeEvent::Create(mOldVersion, mNewVersion);

View File

@ -1542,7 +1542,7 @@ nsDocumentViewer::Destroy()
mSHEntry->SetSticky(mIsSticky);
mIsSticky = true;
bool savePresentation = true;
bool savePresentation = mDocument ? mDocument->IsBFCachingAllowed() : true;
// Remove our root view from the view hierarchy.
if (mPresShell) {