mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 706762: Ensure that object stores and indexes are removed from caches when they are deleted. r=bent
This commit is contained in:
parent
cd4051ca12
commit
5e626ffd6d
@ -499,6 +499,9 @@ IDBDatabase::DeleteObjectStore(const nsAString& aName)
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
info->RemoveObjectStore(aName);
|
||||
|
||||
transaction->ReleaseCachedObjectStore(aName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1550,6 +1550,14 @@ IDBObjectStore::DeleteIndex(const nsAString& aName)
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
info->indexes.RemoveElementAt(index);
|
||||
|
||||
for (PRUint32 i = 0; i < mCreatedIndexes.Length(); i++) {
|
||||
if (mCreatedIndexes[i]->Name() == aName) {
|
||||
mCreatedIndexes.RemoveElementAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -213,6 +213,17 @@ IDBTransaction::OnRequestFinished()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IDBTransaction::ReleaseCachedObjectStore(const nsAString& aName)
|
||||
{
|
||||
for (PRUint32 i = 0; i < mCreatedObjectStores.Length(); i++) {
|
||||
if (mCreatedObjectStores[i]->Name() == aName) {
|
||||
mCreatedObjectStores.RemoveElementAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IDBTransaction::SetTransactionListener(IDBTransactionListener* aListener)
|
||||
{
|
||||
|
@ -103,6 +103,8 @@ public:
|
||||
void OnNewRequest();
|
||||
void OnRequestFinished();
|
||||
|
||||
void ReleaseCachedObjectStore(const nsAString& aName);
|
||||
|
||||
void SetTransactionListener(IDBTransactionListener* aListener);
|
||||
|
||||
bool StartSavepoint();
|
||||
|
@ -32,14 +32,30 @@
|
||||
|
||||
is(objectStore.indexNames.length, 0, "Correct indexNames list");
|
||||
|
||||
objectStore.createIndex(indexName, "foo");
|
||||
let index = objectStore.createIndex(indexName, "foo");
|
||||
|
||||
is(objectStore.indexNames.length, 1, "Correct indexNames list");
|
||||
is(objectStore.indexNames.item(0), indexName, "Correct name");
|
||||
is(objectStore.index(indexName), index, "Correct instance");
|
||||
|
||||
objectStore.deleteIndex(indexName);
|
||||
|
||||
is(objectStore.indexNames.length, 0, "Correct indexNames list");
|
||||
try {
|
||||
objectStore.index(indexName);
|
||||
ok(false, "should have thrown");
|
||||
}
|
||||
catch(ex) {
|
||||
ok(ex instanceof IDBDatabaseException, "Got a IDBDatabaseException");
|
||||
is(ex.code, IDBDatabaseException.NOT_FOUND_ERR, "expect a NOT_FOUND_ERR");
|
||||
}
|
||||
|
||||
let index2 = objectStore.createIndex(indexName, "foo");
|
||||
isnot(index, index2, "New instance should be created");
|
||||
|
||||
is(objectStore.indexNames.length, 1, "Correct recreacted indexNames list");
|
||||
is(objectStore.indexNames.item(0), indexName, "Correct recreacted name");
|
||||
is(objectStore.index(indexName), index2, "Correct instance");
|
||||
|
||||
finishTest();
|
||||
yield;
|
||||
|
@ -55,13 +55,26 @@
|
||||
let event = yield;
|
||||
|
||||
let db = event.target.result;
|
||||
let trans = event.target.transaction;
|
||||
|
||||
db.deleteObjectStore(objectStore.name);
|
||||
let oldObjectStore = trans.objectStore(objectStoreName);
|
||||
isnot(oldObjectStore, null, "Correct object store prior to deleting");
|
||||
db.deleteObjectStore(objectStoreName);
|
||||
is(db.objectStoreNames.length, 0, "Correct objectStores list");
|
||||
try {
|
||||
trans.objectStore(objectStoreName);
|
||||
ok(false, "should have thrown");
|
||||
}
|
||||
catch(ex) {
|
||||
ok(ex instanceof IDBDatabaseException, "Got a IDBDatabaseException");
|
||||
is(ex.code, IDBDatabaseException.NOT_FOUND_ERR, "expect a NOT_FOUND_ERR");
|
||||
}
|
||||
|
||||
objectStore = db.createObjectStore(objectStoreName, { keyPath: "foo" });
|
||||
is(db.objectStoreNames.length, 1, "Correct objectStoreNames list");
|
||||
is(db.objectStoreNames.item(0), objectStoreName, "Correct name");
|
||||
is(trans.objectStore(objectStoreName), objectStore, "Correct new objectStore");
|
||||
isnot(oldObjectStore, objectStore, "Old objectStore is not new objectStore");
|
||||
|
||||
request = objectStore.openCursor();
|
||||
request.onerror = errorHandler;
|
||||
|
Loading…
Reference in New Issue
Block a user