w3c / IndexedDB

Indexed Database API
https://w3c.github.io/IndexedDB/
Other
240 stars 62 forks source link

Inconsistency between spec and tests for detached arraybuffers; spec for keys says don't throw, test for keys says throw, spec for values says throw #417

Open asutherland opened 5 months ago

asutherland commented 5 months ago

While addressing a Firefox test failure in 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 in convert a value to a key means we shouldn't throw because webidl says to "return the empty byte sequence".

However, StructuredSerializeInternal step 13.2.1 says:

If IsDetachedBuffer(value) is true, then throw a "DataCloneError" 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:

inexorabletash commented 5 months ago

SGTM. @evanstade - any opinions?

Anyone up for a PR for the spec?

evanstade commented 5 months ago

sgtm

inexorabletash commented 5 months ago

cc: @SteveBeckerMSFT

SteveBeckerMSFT commented 4 months ago

cc: @SteveBeckerMSFT

@inexorabletash , sorry, missed this until now. Yes, we can work on a spec PR for this inconsistency.