We do throw an error, but it's not the one the test expects: ``` assert_throws_dom: function "() => { rq = objStore.put({sab: sab}, "key"); }" threw object "DataError: Data provided to an operation does not meet requirements." that is not a DOMException DataCloneError: property "code" is equal to 0, expected 25 ``` And we're getting that NS_ERROR_DOM_INDEXEDDB_DATA_ERR [from here](https://searchfox.org/mozilla-central/source/dom/indexedDB/IDBObjectStore.cpp#591): ``` void IDBObjectStore::GetAddInfo(...) { // Return DATA_ERR if a key was passed in and this objectStore uses inline keys. if (!aKeyVal.isUndefined() && HasValidKeyPath()) { aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR); return; } ``` Which seems odd. This is the core of the test: ``` let open_rq = createdb(t); open_rq.onupgradeneeded = function(e) { let db = e.target.result; let objStore = db.createObjectStore("test", { keyPath:"pKey" }); let sab = new SharedArrayBuffer(256); let rq; assert_throws_dom("DataCloneError", () => { rq = objStore.put({sab: sab}, "key"); }); ``` If I drop the "key" argument on the `put` so it's just `objStore.put({sab: sab})`, then we do get a data clone error, it's just still not the "right" one: ``` assert_throws_dom: function "() => { rq = objStore.put({sab: sab}); }" threw object "TypeError: The SharedArrayBuffer object cannot be serialized. The Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy HTTP headers can be used to enable this." that is not a DOMException DataCloneError: property "code" is equal to undefined, expected 25 ``` It becomes the "right" one if I add a `JS_ClearPendingException(aCx);` [here](https://searchfox.org/mozilla-central/source/dom/indexedDB/IDBObjectStore.cpp#607): ``` if (!aValueWrapper.Clone(aCx)) { JS_ClearPendingException(aCx); aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR); return; } ``` But the real question is: what's going on with the "key" argument in the test. Jarl, any clues?
Bug 1878148 Comment 1 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
We do throw an error, but it's not the one the test expects: ``` assert_throws_dom: function "() => { rq = objStore.put({sab: sab}, "key"); }" threw object "DataError: Data provided to an operation does not meet requirements." that is not a DOMException DataCloneError: property "code" is equal to 0, expected 25 ``` And we're getting that NS_ERROR_DOM_INDEXEDDB_DATA_ERR [from here](https://searchfox.org/mozilla-central/source/dom/indexedDB/IDBObjectStore.cpp#591): ``` void IDBObjectStore::GetAddInfo(...) { // Return DATA_ERR if a key was passed in and this objectStore uses inline keys. if (!aKeyVal.isUndefined() && HasValidKeyPath()) { aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR); return; } ``` Which seems odd. This is the core of the test: ``` let open_rq = createdb(t); open_rq.onupgradeneeded = function(e) { let db = e.target.result; let objStore = db.createObjectStore("test", { keyPath:"pKey" }); let sab = new SharedArrayBuffer(256); let rq; assert_throws_dom("DataCloneError", () => { rq = objStore.put({sab: sab}, "key"); }); ``` If I drop the "key" argument on the `put` so it's just `objStore.put({sab: sab})`, then we do get a data clone error, it's just still not the "right" one: ``` assert_throws_dom: function "() => { rq = objStore.put({sab: sab}); }" threw object "TypeError: The SharedArrayBuffer object cannot be serialized. The Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy HTTP headers can be used to enable this." that is not a DOMException DataCloneError: property "code" is equal to undefined, expected 25 ``` It becomes the "right" one if I add a `JS_ClearPendingException(aCx);` [here](https://searchfox.org/mozilla-central/source/dom/indexedDB/IDBObjectStore.cpp#607): ``` if (!aValueWrapper.Clone(aCx)) { JS_ClearPendingException(aCx); aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR); return; } ``` But the real question is: what's going on with the "key" argument in the test. Jarl, any clues?
We do throw an error, but it's not the one the test expects: ``` assert_throws_dom: function "() => { rq = objStore.put({sab: sab}, "key"); }" threw object "DataError: Data provided to an operation does not meet requirements." that is not a DOMException DataCloneError: property "code" is equal to 0, expected 25 ``` And we're getting that NS_ERROR_DOM_INDEXEDDB_DATA_ERR [from here](https://searchfox.org/mozilla-central/source/dom/indexedDB/IDBObjectStore.cpp#591): ``` void IDBObjectStore::GetAddInfo(...) { // Return DATA_ERR if a key was passed in and this objectStore uses inline keys. if (!aKeyVal.isUndefined() && HasValidKeyPath()) { aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR); return; } ``` Which seems odd. This is the core of the test: ``` let open_rq = createdb(t); open_rq.onupgradeneeded = function(e) { let db = e.target.result; let objStore = db.createObjectStore("test", { keyPath:"pKey" }); let sab = new SharedArrayBuffer(256); let rq; assert_throws_dom("DataCloneError", () => { rq = objStore.put({sab: sab}, "key"); }); ``` If I drop the "key" argument on the `put` so it's just `objStore.put({sab: sab})`, then we do get a data clone error, it's just still not the "right" one: ``` assert_throws_dom: function "() => { rq = objStore.put({sab: sab}); }" threw object "TypeError: The SharedArrayBuffer object cannot be serialized. The Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy HTTP headers can be used to enable this." that is not a DOMException DataCloneError: property "code" is equal to undefined, expected 25 ``` It becomes the "right" one if I add a `JS_ClearPendingException` [here](https://searchfox.org/mozilla-central/source/dom/indexedDB/IDBObjectStore.cpp#607): ``` if (!aValueWrapper.Clone(aCx)) { JS_ClearPendingException(aCx); aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR); return; } ``` But the real question is: what's going on with the "key" argument in the test. Jarl, any clues?