From da4c7e7ed675c3bf405668739c3012d140856109 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:42 +0200 Subject: Adding upstream version 126.0. Signed-off-by: Daniel Baumann --- dom/indexedDB/KeyPath.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'dom/indexedDB/KeyPath.cpp') diff --git a/dom/indexedDB/KeyPath.cpp b/dom/indexedDB/KeyPath.cpp index 5cad164296..f27ddd007a 100644 --- a/dom/indexedDB/KeyPath.cpp +++ b/dom/indexedDB/KeyPath.cpp @@ -329,8 +329,9 @@ bool KeyPath::AppendStringWithValidation(const nsAString& aString) { return false; } -nsresult KeyPath::ExtractKey(JSContext* aCx, const JS::Value& aValue, - Key& aKey) const { +nsresult KeyPath::ExtractKey(JSContext* aCx, const JS::Value& aValue, Key& aKey, + const VoidOrObjectStoreKeyPathString& + aAutoIncrementedObjectStoreKeyPath) const { uint32_t len = mStrings.Length(); JS::Rooted value(aCx); @@ -341,6 +342,17 @@ nsresult KeyPath::ExtractKey(JSContext* aCx, const JS::Value& aValue, GetJSValFromKeyPathString(aCx, aValue, mStrings[i], value.address(), DoNotCreateProperties, nullptr, nullptr); if (NS_FAILED(rv)) { + if (!aAutoIncrementedObjectStoreKeyPath.IsVoid() && + mStrings[i].Equals(aAutoIncrementedObjectStoreKeyPath)) { + // We are extracting index keys of an object to be added if + // object store key path for a string key is provided. + // Because the autoIncrement primary key is part of + // this index key but is not defined in |aValue|, so we reserve + // the space here to update the key later in parent. + aKey.ReserveAutoIncrementKey(IsArray() && i == 0); + continue; + } + return rv; } -- cgit v1.2.3