From e20d5ee685c8962b22217b983ed7946ab9f42c10 Mon Sep 17 00:00:00 2001 From: Sandor Molnar Date: Fri, 26 Apr 2024 00:52:35 +0300 Subject: [PATCH] Backed out changeset 133181fbd1ef (bug 1878148) for causing xpc crashes @ mozilla::dom::(anonymous namespace)::ensureCorrectDataCloneError --- dom/indexedDB/IDBObjectStore.cpp | 26 ++++------------------ ...rialize-sharedarraybuffer-throws.https.html.ini | 2 ++ .../serialize-sharedarraybuffer-throws.https.html | 2 +- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp index ea68af5f64e8..728f10b1055b 100644 --- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -276,24 +276,6 @@ bool CopyingStructuredCloneWriteCallback(JSContext* aCx, aObj); } -nsresult ensureCorrectDataCloneError(JSContext* aCx) { - // If JS threw a data cloning error, it will be a TypeError, not a - // DataCloneError as expected. Clear these and throw the right exception. - // But if JS threw another, non-data-cloning error, let it through. - if (JS_IsExceptionPending(aCx)) { - JS::Rooted exn(aCx); - if (JS_GetPendingException(aCx, &exn)) { - JS::Rooted obj(aCx, &exn.toObject()); - JSErrorReport* err = JS_ErrorFromException(aCx, obj); - if (err->errorNumber == JSMSG_SC_NOT_CLONABLE || - err->errorNumber == JSMSG_SC_NOT_CLONABLE_WITH_COOP_COEP) { - JS_ClearPendingException(aCx); - } - } - } - return NS_ERROR_DOM_DATA_CLONE_ERR; -} - nsresult GetAddInfoCallback(JSContext* aCx, void* aClosure) { static const JSStructuredCloneCallbacks kStructuredCloneCallbacks = { nullptr /* read */, StructuredCloneWriteCallback /* write */, @@ -312,7 +294,7 @@ nsresult GetAddInfoCallback(JSContext* aCx, void* aClosure) { if (!data->mCloneWriteInfo.mCloneBuffer.write(aCx, data->mValue, &kStructuredCloneCallbacks, &data->mCloneWriteInfo)) { - return ensureCorrectDataCloneError(aCx); + return NS_ERROR_DOM_DATA_CLONE_ERR; } return NS_OK; @@ -622,7 +604,7 @@ void IDBObjectStore::GetAddInfo(JSContext* aCx, ValueWrapper& aValueWrapper, } } else if (!isAutoIncrement) { if (!aValueWrapper.Clone(aCx)) { - aRv.Throw(ensureCorrectDataCloneError(aCx)); + aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR); return; } @@ -642,7 +624,7 @@ void IDBObjectStore::GetAddInfo(JSContext* aCx, ValueWrapper& aValueWrapper, // Figure out indexes and the index values to update here. if (mSpec->indexes().Length() && !aValueWrapper.Clone(aCx)) { - aRv.Throw(ensureCorrectDataCloneError(aCx)); + aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR); return; } @@ -682,7 +664,7 @@ void IDBObjectStore::GetAddInfo(JSContext* aCx, ValueWrapper& aValueWrapper, if (isAutoIncrement && HasValidKeyPath()) { if (!aValueWrapper.Clone(aCx)) { - aRv.Throw(ensureCorrectDataCloneError(aCx)); + aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR); return; } diff --git a/testing/web-platform/meta/IndexedDB/serialize-sharedarraybuffer-throws.https.html.ini b/testing/web-platform/meta/IndexedDB/serialize-sharedarraybuffer-throws.https.html.ini index 9a058c09d966..bcfac5ac85dc 100644 --- a/testing/web-platform/meta/IndexedDB/serialize-sharedarraybuffer-throws.https.html.ini +++ b/testing/web-platform/meta/IndexedDB/serialize-sharedarraybuffer-throws.https.html.ini @@ -2,3 +2,5 @@ expected: if (os == "android") and not debug: [OK, TIMEOUT] if (os == "android") and debug: [OK, TIMEOUT] + [IndexedDB: Attempting to serialize a SharedArrayBuffer should throw] + expected: FAIL diff --git a/testing/web-platform/tests/IndexedDB/serialize-sharedarraybuffer-throws.https.html b/testing/web-platform/tests/IndexedDB/serialize-sharedarraybuffer-throws.https.html index 03a71a78d25c..613ddfe99d81 100644 --- a/testing/web-platform/tests/IndexedDB/serialize-sharedarraybuffer-throws.https.html +++ b/testing/web-platform/tests/IndexedDB/serialize-sharedarraybuffer-throws.https.html @@ -13,7 +13,7 @@ let open_rq = createdb(t); open_rq.onupgradeneeded = function(e) { let db = e.target.result; - let objStore = db.createObjectStore("test", { autoIncrement: false }); + let objStore = db.createObjectStore("test", { keyPath:"pKey" }); let sab = new SharedArrayBuffer(256); -- 2.11.4.GIT