fake-indexeddb 6.2.8 → 6.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -204,19 +204,19 @@ import "fake-indexeddb/auto";
204
204
 
205
205
  ## Quality
206
206
 
207
- Here's a comparison of fake-indexeddb and real browser IndexedDB implementations on [the Web Platform Tests IndexedDB suite](https://wpt.fyi/results/IndexedDB) as of <!-- last_updated_date_start -->November 8, 2026<!-- last_updated_date_end -->:
207
+ Here's a comparison of fake-indexeddb and real browser IndexedDB implementations on [the Web Platform Tests IndexedDB suite](https://wpt.fyi/results/IndexedDB) as of <!-- last_updated_date_start -->December 4, 2026<!-- last_updated_date_end -->:
208
208
 
209
209
  <!-- DO NOT MANUALLY OVERWRITE THE TABLE BELOW! -->
210
210
  <!-- To update the results, run `pnpm run update-wpt-results` -->
211
211
  <!-- wpt_results_start -->
212
- <!-- wpt_results_total=1678 -->
212
+ <!-- wpt_results_total=1686 -->
213
213
  | Implementation | Version | Passed | % |
214
214
  | --- | --- | --- | --- |
215
- | Chrome | 159.0.8149.0 | 1672 | 99.6% |
216
- | Firefox | 160.0b5 | 1671 | 99.6% |
217
- | Safari | 256 preview | 1677 | 99.9% |
218
- | Ladybird | 1.0-d48145ebfce | 1668 | 99.4% |
219
- | fake-indexeddb | 6.2.8 | 1369 | 81.6% |
215
+ | Chrome | 158.0.8127.107 | 1680 | 99.6% |
216
+ | Firefox | 164.0a1 | 1679 | 99.6% |
217
+ | Safari | 27.2 (22625.2.8.11.9) | 1513 | 89.7% |
218
+ | Ladybird | 1.0-8bd3606c4c3 | 1678 | 99.5% |
219
+ | fake-indexeddb | 6.2.9 | 1370 | 81.3% |
220
220
  <!-- wpt_results_end -->
221
221
 
222
222
  Keep in mind that these tests include a lot of edge cases (such as rare error conditions), so even hitting ~40% likely means that the core IndexedDB functionality is covered. Your app will probably work fine.
@@ -129,6 +129,9 @@ class FDBDatabase extends _FakeEventTarget.default {
129
129
  transaction._objectStoresCache.delete(name);
130
130
  }
131
131
  transaction(storeNames, mode, options) {
132
+ // storeNames is a `(DOMString or sequence<DOMString>)`: any iterable, like `db.objectStoreNames`, is a
133
+ // sequence, and anything else is converted to a string. https://webidl.spec.whatwg.org/#es-union
134
+ const scope = typeof storeNames === "object" && storeNames !== null && storeNames[Symbol.iterator] != null ? Array.from(storeNames, storeName => `${storeName}`) : [`${storeNames}`];
132
135
  mode = mode !== undefined ? mode : "readonly";
133
136
  if (mode !== "readonly" && mode !== "readwrite" && mode !== "versionchange") {
134
137
  throw new TypeError("Invalid mode: " + mode);
@@ -142,17 +145,19 @@ class FDBDatabase extends _FakeEventTarget.default {
142
145
  if (this._closePending) {
143
146
  throw new _errors.InvalidStateError();
144
147
  }
145
- if (!Array.isArray(storeNames)) {
146
- storeNames = [storeNames];
147
- }
148
- if (storeNames.length === 0 && mode !== "versionchange") {
149
- throw new _errors.InvalidAccessError();
150
- }
151
- for (const storeName of storeNames) {
148
+ for (const storeName of scope) {
152
149
  if (!this.objectStoreNames.contains(storeName)) {
153
150
  throw new _errors.NotFoundError("No objectStore named " + storeName + " in this database");
154
151
  }
155
152
  }
153
+ if (scope.length === 0) {
154
+ throw new _errors.InvalidAccessError();
155
+ }
156
+
157
+ // "versionchange" is a valid IDBTransactionMode, but only an upgrade can create such a transaction
158
+ if (mode !== "readonly" && mode !== "readwrite") {
159
+ throw new TypeError("Invalid mode: " + mode);
160
+ }
156
161
 
157
162
  // the actual algo is more complex but this passes the IDB tests: https://webidl.spec.whatwg.org/#es-dictionary
158
163
  const durability = options?.durability ?? "default";
@@ -162,6 +167,11 @@ class FDBDatabase extends _FakeEventTarget.default {
162
167
  // based on Firefox's error message
163
168
  `'${durability}' (value of 'durability' member of IDBTransactionOptions) ` + `is not a valid value for enumeration IDBTransactionDurability`);
164
169
  }
170
+ return this._createTransaction(scope, mode, durability);
171
+ }
172
+
173
+ // Used by `transaction()`, and by `FDBFactory` to create the upgrade transaction
174
+ _createTransaction(storeNames, mode, durability) {
165
175
  const tx = new _FDBTransaction.default(storeNames, mode, durability, this);
166
176
  this._rawDatabase.transactions.push(tx);
167
177
  this._rawDatabase.processTransactions(); // See if can start right away (async)
@@ -169,7 +169,7 @@ const runVersionchangeTransaction = (connection, version, request, cb) => {
169
169
  connection.version = version;
170
170
 
171
171
  // Get rid of this setImmediate?
172
- const transaction = connection.transaction(Array.from(connection.objectStoreNames), "versionchange");
172
+ const transaction = connection._createTransaction(Array.from(connection.objectStoreNames), "versionchange", "default");
173
173
 
174
174
  // associate the transaction with the open request for later lookup
175
175
  transaction._openRequest = request;
@@ -122,6 +122,9 @@ class FDBDatabase extends FakeEventTarget {
122
122
  transaction._objectStoresCache.delete(name);
123
123
  }
124
124
  transaction(storeNames, mode, options) {
125
+ // storeNames is a `(DOMString or sequence<DOMString>)`: any iterable, like `db.objectStoreNames`, is a
126
+ // sequence, and anything else is converted to a string. https://webidl.spec.whatwg.org/#es-union
127
+ const scope = typeof storeNames === "object" && storeNames !== null && storeNames[Symbol.iterator] != null ? Array.from(storeNames, storeName => `${storeName}`) : [`${storeNames}`];
125
128
  mode = mode !== undefined ? mode : "readonly";
126
129
  if (mode !== "readonly" && mode !== "readwrite" && mode !== "versionchange") {
127
130
  throw new TypeError("Invalid mode: " + mode);
@@ -135,17 +138,19 @@ class FDBDatabase extends FakeEventTarget {
135
138
  if (this._closePending) {
136
139
  throw new InvalidStateError();
137
140
  }
138
- if (!Array.isArray(storeNames)) {
139
- storeNames = [storeNames];
140
- }
141
- if (storeNames.length === 0 && mode !== "versionchange") {
142
- throw new InvalidAccessError();
143
- }
144
- for (const storeName of storeNames) {
141
+ for (const storeName of scope) {
145
142
  if (!this.objectStoreNames.contains(storeName)) {
146
143
  throw new NotFoundError("No objectStore named " + storeName + " in this database");
147
144
  }
148
145
  }
146
+ if (scope.length === 0) {
147
+ throw new InvalidAccessError();
148
+ }
149
+
150
+ // "versionchange" is a valid IDBTransactionMode, but only an upgrade can create such a transaction
151
+ if (mode !== "readonly" && mode !== "readwrite") {
152
+ throw new TypeError("Invalid mode: " + mode);
153
+ }
149
154
 
150
155
  // the actual algo is more complex but this passes the IDB tests: https://webidl.spec.whatwg.org/#es-dictionary
151
156
  const durability = options?.durability ?? "default";
@@ -155,6 +160,11 @@ class FDBDatabase extends FakeEventTarget {
155
160
  // based on Firefox's error message
156
161
  `'${durability}' (value of 'durability' member of IDBTransactionOptions) ` + `is not a valid value for enumeration IDBTransactionDurability`);
157
162
  }
163
+ return this._createTransaction(scope, mode, durability);
164
+ }
165
+
166
+ // Used by `transaction()`, and by `FDBFactory` to create the upgrade transaction
167
+ _createTransaction(storeNames, mode, durability) {
158
168
  const tx = new FDBTransaction(storeNames, mode, durability, this);
159
169
  this._rawDatabase.transactions.push(tx);
160
170
  this._rawDatabase.processTransactions(); // See if can start right away (async)
@@ -162,7 +162,7 @@ const runVersionchangeTransaction = (connection, version, request, cb) => {
162
162
  connection.version = version;
163
163
 
164
164
  // Get rid of this setImmediate?
165
- const transaction = connection.transaction(Array.from(connection.objectStoreNames), "versionchange");
165
+ const transaction = connection._createTransaction(Array.from(connection.objectStoreNames), "versionchange", "default");
166
166
 
167
167
  // associate the transaction with the open request for later lookup
168
168
  transaction._openRequest = request;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fake-indexeddb",
3
- "version": "6.2.8",
3
+ "version": "6.2.9",
4
4
  "description": "Fake IndexedDB: a pure JS in-memory implementation of the IndexedDB API",
5
5
  "homepage": "https://github.com/dumbmatter/fakeIndexedDB",
6
6
  "repository": {