Bug 1919493 - IDB: Propagate database invalidation when the actor becomes alive; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D220674
This commit is contained in:
@@ -909,8 +909,6 @@ void BackgroundFactoryRequestChild::HandleResponse(
|
||||
|
||||
database = databaseActor->GetDOMObject();
|
||||
MOZ_ASSERT(database);
|
||||
|
||||
MOZ_ASSERT(!database->IsClosed());
|
||||
}
|
||||
|
||||
return database;
|
||||
@@ -1030,7 +1028,8 @@ BackgroundDatabaseChild::BackgroundDatabaseChild(
|
||||
const DatabaseSpec& aSpec, BackgroundFactoryRequestChild* aOpenRequestActor)
|
||||
: mSpec(MakeUnique<DatabaseSpec>(aSpec)),
|
||||
mOpenRequestActor(aOpenRequestActor),
|
||||
mDatabase(nullptr) {
|
||||
mDatabase(nullptr),
|
||||
mPendingInvalidate(false) {
|
||||
// Can't assert owning thread here because IPDL has not yet set our manager!
|
||||
MOZ_ASSERT(aOpenRequestActor);
|
||||
|
||||
@@ -1102,6 +1101,11 @@ bool BackgroundDatabaseChild::EnsureDOMObject() {
|
||||
|
||||
mDatabase = mTemporaryStrongDatabase;
|
||||
|
||||
if (mPendingInvalidate) {
|
||||
mDatabase->Invalidate();
|
||||
mPendingInvalidate = false;
|
||||
}
|
||||
|
||||
mOpenRequestActor->SetDatabaseActor(this);
|
||||
|
||||
return true;
|
||||
@@ -1299,6 +1303,8 @@ mozilla::ipc::IPCResult BackgroundDatabaseChild::RecvInvalidate() {
|
||||
|
||||
if (mDatabase) {
|
||||
mDatabase->Invalidate();
|
||||
} else {
|
||||
mPendingInvalidate = true;
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
|
||||
@@ -208,6 +208,7 @@ class BackgroundDatabaseChild final : public PBackgroundIDBDatabaseChild {
|
||||
RefPtr<IDBDatabase> mTemporaryStrongDatabase;
|
||||
BackgroundFactoryRequestChild* mOpenRequestActor;
|
||||
IDBDatabase* mDatabase;
|
||||
bool mPendingInvalidate;
|
||||
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(BackgroundDatabaseChild, override)
|
||||
|
||||
@@ -16023,6 +16023,10 @@ nsresult OpenDatabaseOp::EnsureDatabaseActorIsAlive() {
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
if (mDatabase->IsInvalidated()) {
|
||||
Unused << mDatabase->SendInvalidate();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,20 +99,17 @@ async function testExistingDatabase() {
|
||||
|
||||
info("Waiting for database to finish opening");
|
||||
|
||||
// XXX This should throw!
|
||||
const database = await openPromise;
|
||||
try {
|
||||
await openPromise;
|
||||
ok(false, "Should have thrown");
|
||||
} catch (e) {
|
||||
ok(true, "Should have thrown");
|
||||
Assert.strictEqual(e.name, "AbortError", "Threw right result code");
|
||||
}
|
||||
|
||||
info("Waiting for origin to finish clearing");
|
||||
|
||||
await clearPromise;
|
||||
|
||||
info("Reading from the database");
|
||||
|
||||
const request = database
|
||||
.transaction(objectStoreName)
|
||||
.objectStore(objectStoreName)
|
||||
.count();
|
||||
await IndexedDBUtils.requestFinished(request);
|
||||
}
|
||||
|
||||
/* exported testSteps */
|
||||
@@ -131,7 +128,6 @@ async function testSteps() {
|
||||
pref_set: [
|
||||
["dom.indexedDB.databaseInitialization.pauseOnIOThreadMs", 2000],
|
||||
],
|
||||
skip_if: () => true,
|
||||
},
|
||||
testExistingDatabase
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user