← 返回首页
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 · Issue #417 · w3c/IndexedDB · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

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

New issue
New issue

Description

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:

  • 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.

Metadata

Metadata

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

  • Open in GitHub Copilot app

Footer

© 2026 GitHub, Inc.