- From: Brian Cardarella <notifications@github.com>
- Date: Sat, 03 Oct 2026 11:11:03 -0700
- To: w3c/IndexedDB <IndexedDB@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/IndexedDB/issues/510@github.com>
bcardarella created an issue (w3c/IndexedDB#510) `IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen)` doesn't throw when `lower` and `upper` are equal and either bound is open, but every engine does. ### What the spec says The [`bound()` method steps](https://w3c.github.io/IndexedDB/#dom-idbkeyrange-bound) throw a "DataError" `DOMException` only when a key is invalid (steps 2 and 4) or when `lowerKey` is greater than `upperKey` (step 5). With equal keys and an open flag, step 6 returns a key range, and that range contains no key. §2.9 Key range says a range "may have a lower bound equal to its upper bound" and puts no condition on the open flags. ### What engines do Blink, Gecko and WebKit all throw "DataError" for `IDBKeyRange.bound(1, 1, true, false)`, `bound(1, 1, false, true)` and `bound(1, 1, true, true)`: - Blink: [`idb_key_range.cc`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/indexeddb/idb_key_range.cc), `IDBKeyRange::bound`: `if (upper->IsEqual(lower.get()) && (lower_open || upper_open))`, with the message "The lower key and upper key are equal and one of the bounds is open." - Gecko: [`IDBKeyRange.cpp`](https://searchfox.org/mozilla-central/source/dom/indexedDB/IDBKeyRange.cpp), `IDBKeyRange::Bound`: `keyRange->Lower() == keyRange->Upper() && (aLowerOpen || aUpperOpen)`, in the same condition as lower > upper. - WebKit: [`IDBKeyRange.cpp`](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp), `IDBKeyRange::bound`: `if (upper->isEqual(lower.get()) && (lowerOpen || upperOpen))`. ### History The [IndexedDB 1.0 Recommendation](https://www.w3.org/TR/2015/REC-IndexedDB-20150108/) had the rule: `bound()` threw "DataError" if "the lower key and upper key match and either of the bounds are open". It seems to have been lost when the algorithms were rewritten as numbered steps. ### Tests WPT doesn't test this case. `IndexedDB/idbkeyrange_incorrect.any.js` covers invalid keys and lower > upper, not equal keys with an open bound. ### Proposal Add a step after step 5: > If `lowerKey` is equal to `upperKey` and either `lowerOpen` or `upperOpen` is true, throw a "DataError" DOMException. Optionally, also amend §2.9 so that a key range whose lower and upper bounds are equal has both open flags false. A WPT test for this case belongs in `idbkeyrange_incorrect.any.js`. Found while implementing IndexedDB in [Crane](https://github.com/zig-whatwg/crane), a web platform engine, which follows the engines here. -- Reply to this email directly or view it on GitHub: https://github.com/w3c/IndexedDB/issues/510 You are receiving this because you are subscribed to this thread. Message ID: <w3c/IndexedDB/issues/510@github.com>
Received on Saturday, 3 October 2026 18:11:07 UTC