Skip to content

Commit

Permalink
Bug 1708705 - Check new requests are rejected during structured cloni…
Browse files Browse the repository at this point in the history
…ng. r=dom-storage-reviewers,janv

The check is restored from the previous implementation.

Differential Revision: https://phabricator.services.mozilla.com/D137031
  • Loading branch information
jjjalkanen committed Feb 2, 2022
1 parent 44ab758 commit bf6553c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 16 additions & 5 deletions dom/indexedDB/IDBObjectStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,24 @@ RefPtr<IDBRequest> IDBObjectStore::AddOrPut(JSContext* aCx,
// According to spec https://w3c.github.io/IndexedDB/#clone-value,
// the transaction must be in inactive state during clone
mTransaction->TransitionToInactive();

#ifdef DEBUG
const uint32_t previousPendingRequestCount{
mTransaction->GetPendingRequestCount()};
#endif
GetAddInfo(aCx, aValueWrapper, aKey, cloneWriteInfo, key, updateInfos, aRv);
if (mTransaction
->IsAborted()) { // No error thrown, abort is a possible outcome
return nullptr;
// Check that new requests were rejected in the Inactive state
// and possibly in the Finished state, if the transaction has been aborted,
// during the structured cloning.
MOZ_ASSERT(mTransaction->GetPendingRequestCount() ==
previousPendingRequestCount);

if (!mTransaction->IsAborted()) {
mTransaction->TransitionToActive();
} else if (!aRv.Failed()) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR);
return nullptr; // It is mandatory to return right after throw
}
MOZ_ASSERT(mTransaction->IsInactive());
mTransaction->TransitionToActive();

if (aRv.Failed()) {
return nullptr;
Expand Down
2 changes: 2 additions & 0 deletions dom/indexedDB/IDBTransaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ class IDBTransaction final
return mMode;
}

uint32_t GetPendingRequestCount() const { return mPendingRequestCount; }

IDBDatabase* Database() const {
AssertIsOnOwningThread();
return mDatabase;
Expand Down

0 comments on commit bf6553c

Please sign in to comment.