Bug 1919555 - LSNG: Error out LSObject::EnsureDatabase if preparation has been invalidated; r=dom-storage-reviewers,nika,asuth

Differential Revision: https://phabricator.services.mozilla.com/D222425
This commit is contained in:
Jan Varga 2024-10-03 11:26:39 +00:00
parent deda722602
commit 0fb8d3ed72
4 changed files with 14 additions and 2 deletions

View File

@ -7539,6 +7539,7 @@ void PrepareDatastoreOp::GetResponse(LSRequestResponse& aResponse) {
LSRequestPrepareDatastoreResponse prepareDatastoreResponse;
prepareDatastoreResponse.databaseChildEndpoint() =
std::move(childEndpoint);
prepareDatastoreResponse.invalidated() = mInvalidated;
aResponse = std::move(prepareDatastoreResponse);
}

View File

@ -946,6 +946,11 @@ nsresult LSObject::EnsureDatabase() {
glean::ls_preparelsdatabase::processing_time.StopAndAccumulate(
std::move(latencyTimerId));
if (prepareDatastoreResponse.invalidated()) {
database->RequestAllowToClose();
return NS_ERROR_ABORT;
}
mDatabase = std::move(database);
return NS_OK;

View File

@ -18,6 +18,7 @@ struct LSRequestPreloadDatastoreResponse
struct LSRequestPrepareDatastoreResponse
{
Endpoint<PBackgroundLSDatabaseChild> databaseChildEndpoint;
bool invalidated;
};
struct LSRequestPrepareObserverResponse

View File

@ -16,6 +16,11 @@ add_task(async function testSteps() {
const storage = LocalStorageUtils.createStorage(principal);
// XXX This should throw!
storage.getItem("foo");
try {
storage.getItem("foo");
ok(false, "Should have thrown");
} catch (e) {
ok(true, "Should have thrown");
Assert.strictEqual(e.result, Cr.NS_ERROR_ABORT, "Threw right result code");
}
});