- From: Andrew Sutherland <notifications@github.com>
- Date: Tue, 26 Mar 2024 13:21:18 -0700
- To: w3c/IndexedDB <IndexedDB@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/IndexedDB/issues/417@github.com>
While addressing a Firefox test failure in [idb-binary-key-detached.htm](https://searchfox.org/mozilla-central/source/testing/web-platform/tests/IndexedDB/idb-binary-key-detached.htm) in https://phabricator.services.mozilla.com/D202947 we became aware of a chromium issue https://issues.chromium.org/issues/40282817 which correctly points out that the IDB invocation of [getting a copy of the bytes held by the buffer source](https://webidl.spec.whatwg.org/#dfn-get-buffer-source-copy) in [convert a value to a key](https://w3c.github.io/IndexedDB/#convert-a-value-to-a-key) means we shouldn't throw because webidl says to "return the empty byte sequence". However, [StructuredSerializeInternal](https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal) step 13.2.1 says: > If [IsDetachedBuffer](https://tc39.es/ecma262/#sec-isdetachedbuffer)(value) is true, then throw a ["DataCloneError"](https://webidl.spec.whatwg.org/#datacloneerror) [DOMException](https://webidl.spec.whatwg.org/#dfn-DOMException). Arguably the current test behavior (which Blink implements) is the most consistent and developer-friendly behavior. It would be weird for a detached arraybuffer to fail as a value but succeed with a potentially incorrect result as a key. I would propose we: - Modify the IDB spec to explicitly return invalid if "IsDetachedBuffer". - Note this will throw a DataError rather than the TypeError expected by the test. I'm not opposed to retaining TypeError, but it would be good to have some rationale for choosing that given that we otherwise just seem to return DataError and structured serialization returns DataCloneError. - Update the existing test to expect DataError - Add a case for a key that is a JS array that contains a detached arraybuffer. -- Reply to this email directly or view it on GitHub: https://github.com/w3c/IndexedDB/issues/417 You are receiving this because you are subscribed to this thread. Message ID: <w3c/IndexedDB/issues/417@github.com>
Received on Tuesday, 26 March 2024 20:21:22 UTC