aboutsummaryrefslogtreecommitdiff
path: root/packages/idb-bridge
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-02-10 19:52:45 +0100
committerFlorian Dold <florian@dold.me>2022-02-10 19:53:44 +0100
commit5ff3b44550d4f5ab9a20d85dbf4387d455ebb862 (patch)
tree7db62fdc0a87338a4e7fc8dcb51f80fb00d789e4 /packages/idb-bridge
parent1de423834d0a9ca34b10de39e7e51570415f1ed5 (diff)
downloadwallet-core-5ff3b44550d4f5ab9a20d85dbf4387d455ebb862.tar.xz
idb-bridge: update tests for ava 4.x
Diffstat (limited to 'packages/idb-bridge')
-rw-r--r--packages/idb-bridge/package.json11
-rw-r--r--packages/idb-bridge/src/MemoryBackend.test.ts36
-rw-r--r--packages/idb-bridge/src/MemoryBackend.ts20
-rw-r--r--packages/idb-bridge/src/backend-interface.ts4
-rw-r--r--packages/idb-bridge/src/bridge-idb.ts33
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/abort-in-initial-upgradeneeded.test.ts2
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/close-in-upgradeneeded.test.ts76
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts211
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/event-dispatch-active-flag.test.ts5
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbcursor-advance-index.test.ts6
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-index.test.ts694
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-objectstore.test.ts439
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-exception-order.test.ts2
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-index.test.ts354
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-objectstore.test.ts330
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.test.ts2
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbcursor-update-index.test.ts594
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbfactory-cmp.test.ts2
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts6
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbindex-get.test.ts6
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbindex-openCursor.test.ts125
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add-put-exception-order.test.ts5
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add.test.ts6
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-get.test.ts275
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-put.test.ts776
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-rename-store.test.ts2
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbtransaction-oncomplete.test.ts2
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/keypath.test.ts2
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/request-bubble-and-capture.test.ts5
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.test.ts6
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/value.test.ts72
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/wptsupport.ts11
-rw-r--r--packages/idb-bridge/src/util/FakeEvent.ts4
-rw-r--r--packages/idb-bridge/src/util/FakeEventTarget.ts4
-rw-r--r--packages/idb-bridge/src/util/canInjectKey.test.ts2
-rw-r--r--packages/idb-bridge/src/util/canInjectKey.ts2
-rw-r--r--packages/idb-bridge/src/util/cmp.ts4
-rw-r--r--packages/idb-bridge/src/util/extractKey.ts4
-rw-r--r--packages/idb-bridge/src/util/fakeDOMStringList.ts1
-rw-r--r--packages/idb-bridge/src/util/getIndexKeys.test.ts10
-rw-r--r--packages/idb-bridge/src/util/getIndexKeys.ts6
-rw-r--r--packages/idb-bridge/src/util/makeStoreKeyValue.test.ts2
-rw-r--r--packages/idb-bridge/src/util/makeStoreKeyValue.ts10
-rw-r--r--packages/idb-bridge/src/util/structuredClone.test.ts2
-rw-r--r--packages/idb-bridge/src/util/validateKeyPath.ts2
-rw-r--r--packages/idb-bridge/src/util/valueToKey.ts4
46 files changed, 2169 insertions, 2008 deletions
diff --git a/packages/idb-bridge/package.json b/packages/idb-bridge/package.json
index 87add525e..b26ce20eb 100644
--- a/packages/idb-bridge/package.json
+++ b/packages/idb-bridge/package.json
@@ -4,6 +4,7 @@
"description": "IndexedDB implementation that uses SQLite3 as storage",
"main": "./dist/idb-bridge.js",
"module": "./lib/index.js",
+ "type": "module",
"types": "./lib/index.d.ts",
"author": "Florian Dold",
"license": "AGPL-3.0-or-later",
@@ -19,13 +20,13 @@
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
- "@types/node": "^17.0.8",
- "ava": "^3.15.0",
+ "@types/node": "^17.0.17",
+ "ava": "^4.0.1",
"esm": "^3.2.25",
- "prettier": "^2.2.1",
+ "prettier": "^2.5.1",
"rimraf": "^3.0.2",
- "rollup": "^2.63.0",
- "typescript": "^4.5.4"
+ "rollup": "^2.67.2",
+ "typescript": "^4.5.5"
},
"dependencies": {
"tslib": "^2.3.1"
diff --git a/packages/idb-bridge/src/MemoryBackend.test.ts b/packages/idb-bridge/src/MemoryBackend.test.ts
index 3c5e13dff..b36143aa2 100644
--- a/packages/idb-bridge/src/MemoryBackend.test.ts
+++ b/packages/idb-bridge/src/MemoryBackend.test.ts
@@ -22,14 +22,14 @@ import {
BridgeIDBKeyRange,
BridgeIDBRequest,
BridgeIDBTransaction,
-} from "./bridge-idb";
+} from "./bridge-idb.js";
import {
IDBCursorDirection,
IDBCursorWithValue,
IDBKeyRange,
IDBValidKey,
} from "./idbtypes.js";
-import { MemoryBackend } from "./MemoryBackend";
+import { MemoryBackend } from "./MemoryBackend.js";
function promiseFromRequest(request: BridgeIDBRequest): Promise<any> {
return new Promise((resolve, reject) => {
@@ -150,7 +150,7 @@ test("Spec: Example 1 Part 3", async (t) => {
await promiseFromRequest(request3);
- let cursor: BridgeIDBCursorWithValue;
+ let cursor: BridgeIDBCursorWithValue | null;
cursor = request3.result as BridgeIDBCursorWithValue;
t.is(cursor.value.author, "Fred");
t.is(cursor.value.isbn, 123456);
@@ -172,6 +172,9 @@ test("Spec: Example 1 Part 3", async (t) => {
await promiseFromRequest(request4);
cursor = request4.result;
+ if (!cursor) {
+ throw new Error();
+ }
t.is(cursor.value.isbn, 123456);
cursor.continue();
@@ -179,6 +182,9 @@ test("Spec: Example 1 Part 3", async (t) => {
await promiseFromRequest(request4);
cursor = request4.result;
+ if (!cursor) {
+ throw new Error();
+ }
t.is(cursor.value.isbn, 234567);
cursor.continue();
@@ -186,6 +192,9 @@ test("Spec: Example 1 Part 3", async (t) => {
await promiseFromRequest(request4);
cursor = request4.result;
+ if (!cursor) {
+ throw new Error();
+ }
t.is(cursor.value.isbn, 345678);
cursor.continue();
@@ -203,16 +212,25 @@ test("Spec: Example 1 Part 3", async (t) => {
await promiseFromRequest(request5);
cursor = request5.result;
+ if (!cursor) {
+ throw new Error();
+ }
t.is(cursor.value.author, "Barney");
cursor.continue();
await promiseFromRequest(request5);
cursor = request5.result;
+ if (!cursor) {
+ throw new Error();
+ }
t.is(cursor.value.author, "Fred");
cursor.continue();
await promiseFromRequest(request5);
cursor = request5.result;
+ if (!cursor) {
+ throw new Error();
+ }
t.is(cursor.value.author, "Fred");
cursor.continue();
@@ -224,11 +242,17 @@ test("Spec: Example 1 Part 3", async (t) => {
await promiseFromRequest(request6);
cursor = request6.result;
+ if (!cursor) {
+ throw new Error();
+ }
t.is(cursor.value.author, "Barney");
cursor.continue();
await promiseFromRequest(request6);
cursor = request6.result;
+ if (!cursor) {
+ throw new Error();
+ }
t.is(cursor.value.author, "Fred");
t.is(cursor.value.isbn, 123456);
cursor.continue();
@@ -240,12 +264,18 @@ test("Spec: Example 1 Part 3", async (t) => {
const request7 = index5.openCursor(null, "prevunique");
await promiseFromRequest(request7);
cursor = request7.result;
+ if (!cursor) {
+ throw new Error();
+ }
t.is(cursor.value.author, "Fred");
t.is(cursor.value.isbn, 123456);
cursor.continue();
await promiseFromRequest(request7);
cursor = request7.result;
+ if (!cursor) {
+ throw new Error();
+ }
t.is(cursor.value.author, "Barney");
cursor.continue();
diff --git a/packages/idb-bridge/src/MemoryBackend.ts b/packages/idb-bridge/src/MemoryBackend.ts
index b37dd376d..3919cdf97 100644
--- a/packages/idb-bridge/src/MemoryBackend.ts
+++ b/packages/idb-bridge/src/MemoryBackend.ts
@@ -26,20 +26,20 @@ import {
ResultLevel,
StoreLevel,
RecordStoreResponse,
-} from "./backend-interface";
+} from "./backend-interface.js";
import {
structuredClone,
structuredEncapsulate,
structuredRevive,
-} from "./util/structuredClone";
-import { ConstraintError, DataError } from "./util/errors";
-import BTree, { ISortedMapF, ISortedSetF } from "./tree/b+tree";
-import { compareKeys } from "./util/cmp";
-import { StoreKeyResult, makeStoreKeyValue } from "./util/makeStoreKeyValue";
-import { getIndexKeys } from "./util/getIndexKeys";
-import { openPromise } from "./util/openPromise";
-import { IDBKeyRange, IDBTransactionMode, IDBValidKey } from "./idbtypes";
-import { BridgeIDBKeyRange } from "./bridge-idb";
+} from "./util/structuredClone.js";
+import { ConstraintError, DataError } from "./util/errors.js";
+import BTree, { ISortedMapF, ISortedSetF } from "./tree/b+tree.js";
+import { compareKeys } from "./util/cmp.js";
+import { StoreKeyResult, makeStoreKeyValue } from "./util/makeStoreKeyValue.js";
+import { getIndexKeys } from "./util/getIndexKeys.js";
+import { openPromise } from "./util/openPromise.js";
+import { IDBKeyRange, IDBTransactionMode, IDBValidKey } from "./idbtypes.js";
+import { BridgeIDBKeyRange } from "./bridge-idb.js";
type Key = IDBValidKey;
type Value = unknown;
diff --git a/packages/idb-bridge/src/backend-interface.ts b/packages/idb-bridge/src/backend-interface.ts
index 1b9883d2b..a21515544 100644
--- a/packages/idb-bridge/src/backend-interface.ts
+++ b/packages/idb-bridge/src/backend-interface.ts
@@ -14,12 +14,12 @@
permissions and limitations under the License.
*/
-import { BridgeIDBDatabaseInfo, BridgeIDBKeyRange } from "./bridge-idb";
+import { BridgeIDBDatabaseInfo, BridgeIDBKeyRange } from "./bridge-idb.js";
import {
IDBCursorDirection,
IDBTransactionMode,
IDBValidKey,
-} from "./idbtypes";
+} from "./idbtypes.js";
/** @public */
export interface ObjectStoreProperties {
diff --git a/packages/idb-bridge/src/bridge-idb.ts b/packages/idb-bridge/src/bridge-idb.ts
index 8264b43ec..35cedb1db 100644
--- a/packages/idb-bridge/src/bridge-idb.ts
+++ b/packages/idb-bridge/src/bridge-idb.ts
@@ -24,7 +24,7 @@ import {
ResultLevel,
Schema,
StoreLevel,
-} from "./backend-interface";
+} from "./backend-interface.js";
import {
DOMException,
DOMStringList,
@@ -41,10 +41,10 @@ import {
IDBTransaction,
IDBTransactionMode,
IDBValidKey,
-} from "./idbtypes";
-import { canInjectKey } from "./util/canInjectKey";
-import { compareKeys } from "./util/cmp";
-import { enforceRange } from "./util/enforceRange";
+} from "./idbtypes.js";
+import { canInjectKey } from "./util/canInjectKey.js";
+import { compareKeys } from "./util/cmp.js";
+import { enforceRange } from "./util/enforceRange.js";
import {
AbortError,
ConstraintError,
@@ -56,20 +56,19 @@ import {
ReadOnlyError,
TransactionInactiveError,
VersionError,
-} from "./util/errors";
-import { FakeDOMStringList, fakeDOMStringList } from "./util/fakeDOMStringList";
-import FakeEvent from "./util/FakeEvent";
-import FakeEventTarget from "./util/FakeEventTarget";
-import { makeStoreKeyValue } from "./util/makeStoreKeyValue";
-import { normalizeKeyPath } from "./util/normalizeKeyPath";
-import { openPromise } from "./util/openPromise";
-import queueTask from "./util/queueTask";
+} from "./util/errors.js";
+import { FakeDOMStringList, fakeDOMStringList } from "./util/fakeDOMStringList.js";
+import FakeEvent from "./util/FakeEvent.js";
+import FakeEventTarget from "./util/FakeEventTarget.js";
+import { makeStoreKeyValue } from "./util/makeStoreKeyValue.js";
+import { normalizeKeyPath } from "./util/normalizeKeyPath.js";
+import { openPromise } from "./util/openPromise.js";
+import queueTask from "./util/queueTask.js";
import {
checkStructuredCloneOrThrow,
- structuredClone,
-} from "./util/structuredClone";
-import { validateKeyPath } from "./util/validateKeyPath";
-import { valueToKey } from "./util/valueToKey";
+} from "./util/structuredClone.js";
+import { validateKeyPath } from "./util/validateKeyPath.js";
+import { valueToKey } from "./util/valueToKey.js";
/** @public */
export type CursorSource = BridgeIDBIndex | BridgeIDBObjectStore;
diff --git a/packages/idb-bridge/src/idb-wpt-ported/abort-in-initial-upgradeneeded.test.ts b/packages/idb-bridge/src/idb-wpt-ported/abort-in-initial-upgradeneeded.test.ts
index 3b65a9033..bbbcf9b94 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/abort-in-initial-upgradeneeded.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/abort-in-initial-upgradeneeded.test.ts
@@ -1,5 +1,5 @@
import test from "ava";
-import { createdb } from "./wptsupport";
+import { createdb } from "./wptsupport.js";
test("WPT test abort-in-initial-upgradeneeded.htm", async (t) => {
await new Promise<void>((resolve, reject) => {
diff --git a/packages/idb-bridge/src/idb-wpt-ported/close-in-upgradeneeded.test.ts b/packages/idb-bridge/src/idb-wpt-ported/close-in-upgradeneeded.test.ts
index 96abe3918..723a0abb5 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/close-in-upgradeneeded.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/close-in-upgradeneeded.test.ts
@@ -1,44 +1,44 @@
import test from "ava";
-import { BridgeIDBCursor } from "..";
-import { BridgeIDBCursorWithValue } from "../bridge-idb";
-import { createdb } from "./wptsupport";
+import { createdb } from "./wptsupport.js";
// When db.close is called in upgradeneeded, the db is cleaned up on refresh
-test.cb("WPT test close-in-upgradeneeded.htm", (t) => {
- var db: any;
- var open_rq = createdb(t);
- var sawTransactionComplete = false;
-
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- t.deepEqual(db.version, 1);
-
- db.createObjectStore("os");
- db.close();
+test("WPT test close-in-upgradeneeded.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ var open_rq = createdb(t);
+ var sawTransactionComplete = false;
+
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ t.deepEqual(db.version, 1);
+
+ db.createObjectStore("os");
+ db.close();
+
+ e.target.transaction.oncomplete = function () {
+ sawTransactionComplete = true;
+ };
+ };
- e.target.transaction.oncomplete = function () {
- sawTransactionComplete = true;
+ open_rq.onerror = function (e: any) {
+ t.true(sawTransactionComplete, "saw transaction.complete");
+
+ t.deepEqual(e.target.error.name, "AbortError");
+ t.deepEqual(e.result, undefined);
+
+ t.true(!!db);
+ t.deepEqual(db.version, 1);
+ t.deepEqual(db.objectStoreNames.length, 1);
+ t.throws(
+ () => {
+ db.transaction("os");
+ },
+ {
+ name: "InvalidStateError",
+ },
+ );
+
+ resolve();
};
- };
-
- open_rq.onerror = function (e: any) {
- t.true(sawTransactionComplete, "saw transaction.complete");
-
- t.deepEqual(e.target.error.name, "AbortError");
- t.deepEqual(e.result, undefined);
-
- t.true(!!db);
- t.deepEqual(db.version, 1);
- t.deepEqual(db.objectStoreNames.length, 1);
- t.throws(
- () => {
- db.transaction("os");
- },
- {
- name: "InvalidStateError",
- },
- );
-
- t.end();
- };
+ });
});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts b/packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts
index c4bce8743..db2cdbca8 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts
@@ -1,117 +1,130 @@
import test from "ava";
-import { BridgeIDBCursor, BridgeIDBKeyRange } from "..";
-import { BridgeIDBCursorWithValue } from "../bridge-idb";
-import { IDBRequest } from "../idbtypes";
-import { createdb } from "./wptsupport";
+import { BridgeIDBKeyRange } from "../bridge-idb.js";
+import { IDBRequest } from "../idbtypes.js";
+import { createdb } from "./wptsupport.js";
const IDBKeyRange = BridgeIDBKeyRange;
// Validate the overloads of IDBObjectStore.openCursor(),
// IDBIndex.openCursor() and IDBIndex.openKeyCursor()
-test.cb("WPT test cursor-overloads.htm", (t) => {
- var db: any, store: any, index: any;
+test("WPT test cursor-overloads.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any, store: any, index: any;
- var request = createdb(t);
- request.onupgradeneeded = function (e: any) {
- db = request.result;
- store = db.createObjectStore("store");
- index = store.createIndex("index", "value");
- store.put({ value: 0 }, 0);
- const trans = request.transaction!;
- trans.oncomplete = verifyOverloads;
- };
+ var request = createdb(t);
+ request.onupgradeneeded = function (e: any) {
+ db = request.result;
+ store = db.createObjectStore("store");
+ index = store.createIndex("index", "value");
+ store.put({ value: 0 }, 0);
+ const trans = request.transaction!;
+ trans.oncomplete = verifyOverloads;
+ };
- async function verifyOverloads() {
- const trans = db.transaction("store");
- store = trans.objectStore("store");
- index = store.index("index");
+ async function verifyOverloads() {
+ const trans = db.transaction("store");
+ store = trans.objectStore("store");
+ index = store.index("index");
- await checkCursorDirection(store.openCursor(), "next");
- await checkCursorDirection(store.openCursor(0), "next");
- await checkCursorDirection(store.openCursor(0, "next"), "next");
- await checkCursorDirection(store.openCursor(0, "nextunique"), "nextunique");
- await checkCursorDirection(store.openCursor(0, "prev"), "prev");
- await checkCursorDirection(store.openCursor(0, "prevunique"), "prevunique");
+ await checkCursorDirection(store.openCursor(), "next");
+ await checkCursorDirection(store.openCursor(0), "next");
+ await checkCursorDirection(store.openCursor(0, "next"), "next");
+ await checkCursorDirection(
+ store.openCursor(0, "nextunique"),
+ "nextunique",
+ );
+ await checkCursorDirection(store.openCursor(0, "prev"), "prev");
+ await checkCursorDirection(
+ store.openCursor(0, "prevunique"),
+ "prevunique",
+ );
- await checkCursorDirection(store.openCursor(IDBKeyRange.only(0)), "next");
- await checkCursorDirection(
- store.openCursor(BridgeIDBKeyRange.only(0), "next"),
- "next",
- );
- await checkCursorDirection(
- store.openCursor(IDBKeyRange.only(0), "nextunique"),
- "nextunique",
- );
- await checkCursorDirection(
- store.openCursor(IDBKeyRange.only(0), "prev"),
- "prev",
- );
- await checkCursorDirection(
- store.openCursor(IDBKeyRange.only(0), "prevunique"),
- "prevunique",
- );
+ await checkCursorDirection(store.openCursor(IDBKeyRange.only(0)), "next");
+ await checkCursorDirection(
+ store.openCursor(BridgeIDBKeyRange.only(0), "next"),
+ "next",
+ );
+ await checkCursorDirection(
+ store.openCursor(IDBKeyRange.only(0), "nextunique"),
+ "nextunique",
+ );
+ await checkCursorDirection(
+ store.openCursor(IDBKeyRange.only(0), "prev"),
+ "prev",
+ );
+ await checkCursorDirection(
+ store.openCursor(IDBKeyRange.only(0), "prevunique"),
+ "prevunique",
+ );
- await checkCursorDirection(index.openCursor(), "next");
- await checkCursorDirection(index.openCursor(0), "next");
- await checkCursorDirection(index.openCursor(0, "next"), "next");
- await checkCursorDirection(index.openCursor(0, "nextunique"), "nextunique");
- await checkCursorDirection(index.openCursor(0, "prev"), "prev");
- await checkCursorDirection(index.openCursor(0, "prevunique"), "prevunique");
+ await checkCursorDirection(index.openCursor(), "next");
+ await checkCursorDirection(index.openCursor(0), "next");
+ await checkCursorDirection(index.openCursor(0, "next"), "next");
+ await checkCursorDirection(
+ index.openCursor(0, "nextunique"),
+ "nextunique",
+ );
+ await checkCursorDirection(index.openCursor(0, "prev"), "prev");
+ await checkCursorDirection(
+ index.openCursor(0, "prevunique"),
+ "prevunique",
+ );
- await checkCursorDirection(index.openCursor(IDBKeyRange.only(0)), "next");
- await checkCursorDirection(
- index.openCursor(IDBKeyRange.only(0), "next"),
- "next",
- );
- await checkCursorDirection(
- index.openCursor(IDBKeyRange.only(0), "nextunique"),
- "nextunique",
- );
- await checkCursorDirection(
- index.openCursor(IDBKeyRange.only(0), "prev"),
- "prev",
- );
- await checkCursorDirection(
- index.openCursor(IDBKeyRange.only(0), "prevunique"),
- "prevunique",
- );
+ await checkCursorDirection(index.openCursor(IDBKeyRange.only(0)), "next");
+ await checkCursorDirection(
+ index.openCursor(IDBKeyRange.only(0), "next"),
+ "next",
+ );
+ await checkCursorDirection(
+ index.openCursor(IDBKeyRange.only(0), "nextunique"),
+ "nextunique",
+ );
+ await checkCursorDirection(
+ index.openCursor(IDBKeyRange.only(0), "prev"),
+ "prev",
+ );
+ await checkCursorDirection(
+ index.openCursor(IDBKeyRange.only(0), "prevunique"),
+ "prevunique",
+ );
- await checkCursorDirection(index.openKeyCursor(), "next");
- await checkCursorDirection(index.openKeyCursor(0), "next");
- await checkCursorDirection(index.openKeyCursor(0, "next"), "next");
- await checkCursorDirection(
- index.openKeyCursor(0, "nextunique"),
- "nextunique",
- );
- await checkCursorDirection(index.openKeyCursor(0, "prev"), "prev");
- await checkCursorDirection(
- index.openKeyCursor(0, "prevunique"),
- "prevunique",
- );
+ await checkCursorDirection(index.openKeyCursor(), "next");
+ await checkCursorDirection(index.openKeyCursor(0), "next");
+ await checkCursorDirection(index.openKeyCursor(0, "next"), "next");
+ await checkCursorDirection(
+ index.openKeyCursor(0, "nextunique"),
+ "nextunique",
+ );
+ await checkCursorDirection(index.openKeyCursor(0, "prev"), "prev");
+ await checkCursorDirection(
+ index.openKeyCursor(0, "prevunique"),
+ "prevunique",
+ );
- await checkCursorDirection(
- index.openKeyCursor(IDBKeyRange.only(0)),
- "next",
- );
- await checkCursorDirection(
- index.openKeyCursor(IDBKeyRange.only(0), "next"),
- "next",
- );
- await checkCursorDirection(
- index.openKeyCursor(IDBKeyRange.only(0), "nextunique"),
- "nextunique",
- );
- await checkCursorDirection(
- index.openKeyCursor(IDBKeyRange.only(0), "prev"),
- "prev",
- );
- await checkCursorDirection(
- index.openKeyCursor(IDBKeyRange.only(0), "prevunique"),
- "prevunique",
- );
+ await checkCursorDirection(
+ index.openKeyCursor(IDBKeyRange.only(0)),
+ "next",
+ );
+ await checkCursorDirection(
+ index.openKeyCursor(IDBKeyRange.only(0), "next"),
+ "next",
+ );
+ await checkCursorDirection(
+ index.openKeyCursor(IDBKeyRange.only(0), "nextunique"),
+ "nextunique",
+ );
+ await checkCursorDirection(
+ index.openKeyCursor(IDBKeyRange.only(0), "prev"),
+ "prev",
+ );
+ await checkCursorDirection(
+ index.openKeyCursor(IDBKeyRange.only(0), "prevunique"),
+ "prevunique",
+ );
- t.end();
- }
+ resolve();
+ }
+ });
function checkCursorDirection(
request: IDBRequest,
diff --git a/packages/idb-bridge/src/idb-wpt-ported/event-dispatch-active-flag.test.ts b/packages/idb-bridge/src/idb-wpt-ported/event-dispatch-active-flag.test.ts
index b8151f465..acc2a7578 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/event-dispatch-active-flag.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/event-dispatch-active-flag.test.ts
@@ -1,11 +1,10 @@
import test from "ava";
-import { BridgeIDBRequest } from "..";
+import { BridgeIDBRequest } from "../bridge-idb.js";
import {
- createdb,
indexeddb_test,
is_transaction_active,
keep_alive,
-} from "./wptsupport";
+} from "./wptsupport.js";
test("WPT test abort-in-initial-upgradeneeded.htm (subtest 1)", async (t) => {
// Transactions are active during success handlers
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-advance-index.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-advance-index.test.ts
index fac047990..108e7c91c 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-advance-index.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-advance-index.test.ts
@@ -1,8 +1,6 @@
import test from "ava";
-import { BridgeIDBCursor } from "..";
-import { BridgeIDBRequest } from "../bridge-idb";
-import { InvalidStateError } from "../util/errors";
-import { createdb } from "./wptsupport";
+import { BridgeIDBCursor,BridgeIDBRequest } from "../bridge-idb.js";
+import { createdb } from "./wptsupport.js";
test("WPT test idbcursor_advance_index.htm", async (t) => {
await new Promise<void>((resolve, reject) => {
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-index.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-index.test.ts
index 9b96a2e91..f8b3a0f01 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-index.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-index.test.ts
@@ -1,385 +1,401 @@
import test from "ava";
-import { BridgeIDBCursor } from "..";
-import { BridgeIDBCursorWithValue } from "../bridge-idb";
-import { createdb } from "./wptsupport";
-
-test.cb("WPT test idbcursor_continue_index.htm", (t) => {
- var db: any;
- let count = 0;
- const records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- { pKey: "primaryKey_1-2", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db
- .transaction("test")
- .objectStore("test")
- .index("index")
- .openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- if (!cursor) {
- t.deepEqual(count, records.length, "cursor run count");
- t.end();
- return;
- }
+import { BridgeIDBCursor, BridgeIDBCursorWithValue } from "../bridge-idb.js";
+import { createdb } from "./wptsupport.js";
+
+test("WPT test idbcursor_continue_index.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ let count = 0;
+ const records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ { pKey: "primaryKey_1-2", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- var record = cursor.value;
- t.deepEqual(record.pKey, records[count].pKey, "primary key");
- t.deepEqual(record.iKey, records[count].iKey, "index key");
+ objStore.createIndex("index", "iKey");
- cursor.continue();
- count++;
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
};
- };
-});
-// IDBCursor.continue() - index - attempt to pass a key parameter that is not a valid key
-test.cb("WPT idbcursor-continue-index2.htm", (t) => {
- var db: any;
- let records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db
- .transaction("test")
- .objectStore("test")
- .index("index")
- .openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
-
- t.throws(
- () => {
- cursor.continue({ foo: "bar" });
- },
- { name: "DataError" },
- );
-
- t.true(cursor instanceof BridgeIDBCursorWithValue, "cursor");
-
- t.end();
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db
+ .transaction("test")
+ .objectStore("test")
+ .index("index")
+ .openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ if (!cursor) {
+ t.deepEqual(count, records.length, "cursor run count");
+ resolve();
+ return;
+ }
+
+ var record = cursor.value;
+ t.deepEqual(record.pKey, records[count].pKey, "primary key");
+ t.deepEqual(record.iKey, records[count].iKey, "index key");
+
+ cursor.continue();
+ count++;
+ };
};
- };
+ });
});
-// IDBCursor.continue() - index - attempt to iterate to the previous
-// record when the direction is set for the next record
-test.cb("WPT idbcursor-continue-index3.htm", (t) => {
- var db: any;
- const records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var count = 0;
- var cursor_rq = db
- .transaction("test")
- .objectStore("test")
- .index("index")
- .openCursor(undefined, "next"); // XXX: Fx has issue with "undefined"
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- if (!cursor) {
- t.deepEqual(count, 2, "ran number of times");
- t.end();
- return;
- }
+// IDBCursor.continue() - index - attempt to pass a key parameter that is not a valid key
+test("WPT idbcursor-continue-index2.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ let records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
- // First time checks key equal, second time checks key less than
- t.throws(
- () => {
- cursor.continue(records[0].iKey);
- },
- { name: "DataError" },
- );
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- cursor.continue();
+ objStore.createIndex("index", "iKey");
- count++;
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
};
- };
-});
-// IDBCursor.continue() - index - attempt to iterate to the next
-// record when the direction is set for the previous record
-test.cb("WPT idbcursor-continue-index4.htm", (t) => {
- var db: any;
- const records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- { pKey: "primaryKey_2", iKey: "indexKey_2" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var count = 0,
- cursor_rq = db
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db
.transaction("test")
.objectStore("test")
.index("index")
- .openCursor(undefined, "prev"); // XXX Fx issues w undefined
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result,
- record = cursor.value;
-
- switch (count) {
- case 0:
- t.deepEqual(record.pKey, records[2].pKey, "first pKey");
- t.deepEqual(record.iKey, records[2].iKey, "first iKey");
- cursor.continue();
- break;
-
- case 1:
- t.deepEqual(record.pKey, records[1].pKey, "second pKey");
- t.deepEqual(record.iKey, records[1].iKey, "second iKey");
- t.throws(
- () => {
- cursor.continue("indexKey_2");
- },
- { name: "DataError" },
- );
- t.end();
- break;
-
- default:
- t.fail("Unexpected count value: " + count);
- }
+ .openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+
+ t.throws(
+ () => {
+ cursor.continue({ foo: "bar" });
+ },
+ { name: "DataError" },
+ );
+
+ t.true(cursor instanceof BridgeIDBCursorWithValue, "cursor");
- count++;
+ resolve();
+ };
};
- };
+ });
});
-// IDBCursor.continue() - index - iterate using 'prevunique'
-test.cb("WPT idbcursor-continue-index5.htm", (t) => {
- var db: any;
- const records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- { pKey: "primaryKey_1-2", iKey: "indexKey_1" },
- { pKey: "primaryKey_2", iKey: "indexKey_2" },
- ];
- const expected = [
- { pKey: "primaryKey_2", iKey: "indexKey_2" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var count = 0,
- cursor_rq = db
- .transaction("test")
- .objectStore("test")
- .index("index")
- .openCursor(undefined, "prevunique");
+// IDBCursor.continue() - index - attempt to iterate to the previous
+// record when the direction is set for the next record
+test("WPT idbcursor-continue-index3.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ const records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
- cursor_rq.onsuccess = function (e: any) {
- if (!e.target.result) {
- t.deepEqual(count, expected.length, "count");
- t.end();
- return;
- }
- const cursor = e.target.result;
- const record = cursor.value;
- t.deepEqual(record.pKey, expected[count].pKey, "pKey #" + count);
- t.deepEqual(record.iKey, expected[count].iKey, "iKey #" + count);
-
- t.deepEqual(cursor.key, expected[count].iKey, "cursor.key #" + count);
- t.deepEqual(
- cursor.primaryKey,
- expected[count].pKey,
- "cursor.primaryKey #" + count,
- );
-
- count++;
- cursor.continue(expected[count] ? expected[count].iKey : undefined);
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+
+ objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
};
- };
-});
-// IDBCursor.continue() - index - iterate using nextunique
-test.cb("WPT idbcursor-continue-index6.htm", (t) => {
- var db: any;
- const records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- { pKey: "primaryKey_1-2", iKey: "indexKey_1" },
- { pKey: "primaryKey_2", iKey: "indexKey_2" },
- ];
- const expected = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- { pKey: "primaryKey_2", iKey: "indexKey_2" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var count = 0,
- cursor_rq = db
+ open_rq.onsuccess = function (e: any) {
+ var count = 0;
+ var cursor_rq = db
.transaction("test")
.objectStore("test")
.index("index")
- .openCursor(undefined, "nextunique");
+ .openCursor(undefined, "next"); // XXX: Fx has issue with "undefined"
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ if (!cursor) {
+ t.deepEqual(count, 2, "ran number of times");
+ resolve();
+ return;
+ }
+
+ // First time checks key equal, second time checks key less than
+ t.throws(
+ () => {
+ cursor.continue(records[0].iKey);
+ },
+ { name: "DataError" },
+ );
+
+ cursor.continue();
+
+ count++;
+ };
+ };
+ });
+});
- cursor_rq.onsuccess = function (e: any) {
- if (!e.target.result) {
- t.deepEqual(count, expected.length, "count");
- t.end();
- return;
- }
- var cursor = e.target.result,
- record = cursor.value;
+// IDBCursor.continue() - index - attempt to iterate to the next
+// record when the direction is set for the previous record
+test("WPT idbcursor-continue-index4.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ const records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ { pKey: "primaryKey_2", iKey: "indexKey_2" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- t.deepEqual(record.pKey, expected[count].pKey, "pKey #" + count);
- t.deepEqual(record.iKey, expected[count].iKey, "iKey #" + count);
+ objStore.createIndex("index", "iKey");
- t.deepEqual(cursor.key, expected[count].iKey, "cursor.key #" + count);
- t.deepEqual(
- cursor.primaryKey,
- expected[count].pKey,
- "cursor.primaryKey #" + count,
- );
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
- count++;
- cursor.continue(expected[count] ? expected[count].iKey : undefined);
+ open_rq.onsuccess = function (e: any) {
+ var count = 0,
+ cursor_rq = db
+ .transaction("test")
+ .objectStore("test")
+ .index("index")
+ .openCursor(undefined, "prev"); // XXX Fx issues w undefined
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result,
+ record = cursor.value;
+
+ switch (count) {
+ case 0:
+ t.deepEqual(record.pKey, records[2].pKey, "first pKey");
+ t.deepEqual(record.iKey, records[2].iKey, "first iKey");
+ cursor.continue();
+ break;
+
+ case 1:
+ t.deepEqual(record.pKey, records[1].pKey, "second pKey");
+ t.deepEqual(record.iKey, records[1].iKey, "second iKey");
+ t.throws(
+ () => {
+ cursor.continue("indexKey_2");
+ },
+ { name: "DataError" },
+ );
+ resolve();
+ break;
+
+ default:
+ t.fail("Unexpected count value: " + count);
+ }
+
+ count++;
+ };
};
- };
+ });
});
-// IDBCursor.continue() - index - throw TransactionInactiveError
-test.cb("WPT idbcursor-continue-index7.htm", (t) => {
- var db: any,
- records = [
+// IDBCursor.continue() - index - iterate using 'prevunique'
+test("WPT idbcursor-continue-index5.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ const records = [
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" },
+ { pKey: "primaryKey_1-2", iKey: "indexKey_1" },
+ { pKey: "primaryKey_2", iKey: "indexKey_2" },
+ ];
+ const expected = [
+ { pKey: "primaryKey_2", iKey: "indexKey_2" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
];
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (event: any) {
- db = event.target.result;
- var objStore = db.createObjectStore("store", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
- for (var i = 0; i < records.length; i++) {
- objStore.add(records[i]);
- }
- var rq = objStore.index("index").openCursor();
- rq.onsuccess = function (event: any) {
- var cursor = event.target.result;
- t.true(cursor instanceof BridgeIDBCursor);
-
- event.target.transaction.abort();
- t.throws(
- () => {
- cursor.continue();
- },
- { name: "TransactionInactiveError" },
- "Calling continue() should throws an exception TransactionInactiveError when the transaction is not active.",
- );
- t.end();
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+
+ objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var count = 0,
+ cursor_rq = db
+ .transaction("test")
+ .objectStore("test")
+ .index("index")
+ .openCursor(undefined, "prevunique");
+
+ cursor_rq.onsuccess = function (e: any) {
+ if (!e.target.result) {
+ t.deepEqual(count, expected.length, "count");
+ resolve();
+ return;
+ }
+ const cursor = e.target.result;
+ const record = cursor.value;
+ t.deepEqual(record.pKey, expected[count].pKey, "pKey #" + count);
+ t.deepEqual(record.iKey, expected[count].iKey, "iKey #" + count);
+
+ t.deepEqual(cursor.key, expected[count].iKey, "cursor.key #" + count);
+ t.deepEqual(
+ cursor.primaryKey,
+ expected[count].pKey,
+ "cursor.primaryKey #" + count,
+ );
+
+ count++;
+ cursor.continue(expected[count] ? expected[count].iKey : undefined);
+ };
};
- };
+ });
});
-// IDBCursor.continue() - index - throw InvalidStateError caused by object store been deleted
-test.cb("WPT idbcursor-continue-index8.htm", (t) => {
- var db: any,
- records = [
+// IDBCursor.continue() - index - iterate using nextunique
+test("WPT idbcursor-continue-index6.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ const records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ { pKey: "primaryKey_1-2", iKey: "indexKey_1" },
+ { pKey: "primaryKey_2", iKey: "indexKey_2" },
+ ];
+ const expected = [
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" },
+ { pKey: "primaryKey_2", iKey: "indexKey_2" },
];
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (event: any) {
- db = event.target.result;
- var objStore = db.createObjectStore("store", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
- for (var i = 0; i < records.length; i++) {
- objStore.add(records[i]);
- }
- var rq = objStore.index("index").openCursor();
- rq.onsuccess = function (event: any) {
- var cursor = event.target.result;
- t.true(cursor instanceof BridgeIDBCursor);
-
- db.deleteObjectStore("store");
-
- t.throws(
- () => {
- cursor.continue();
- },
- { name: "InvalidStateError" },
- "If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type InvalidStateError",
- );
-
- t.end();
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+
+ objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var count = 0,
+ cursor_rq = db
+ .transaction("test")
+ .objectStore("test")
+ .index("index")
+ .openCursor(undefined, "nextunique");
+
+ cursor_rq.onsuccess = function (e: any) {
+ if (!e.target.result) {
+ t.deepEqual(count, expected.length, "count");
+ resolve();
+ return;
+ }
+ var cursor = e.target.result,
+ record = cursor.value;
+
+ t.deepEqual(record.pKey, expected[count].pKey, "pKey #" + count);
+ t.deepEqual(record.iKey, expected[count].iKey, "iKey #" + count);
+
+ t.deepEqual(cursor.key, expected[count].iKey, "cursor.key #" + count);
+ t.deepEqual(
+ cursor.primaryKey,
+ expected[count].pKey,
+ "cursor.primaryKey #" + count,
+ );
+
+ count++;
+ cursor.continue(expected[count] ? expected[count].iKey : undefined);
+ };
+ };
+ });
+});
+
+// IDBCursor.continue() - index - throw TransactionInactiveError
+test("WPT idbcursor-continue-index7.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (event: any) {
+ db = event.target.result;
+ var objStore = db.createObjectStore("store", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+ for (var i = 0; i < records.length; i++) {
+ objStore.add(records[i]);
+ }
+ var rq = objStore.index("index").openCursor();
+ rq.onsuccess = function (event: any) {
+ var cursor = event.target.result;
+ t.true(cursor instanceof BridgeIDBCursor);
+
+ event.target.transaction.abort();
+ t.throws(
+ () => {
+ cursor.continue();
+ },
+ { name: "TransactionInactiveError" },
+ "Calling continue() should throws an exception TransactionInactiveError when the transaction is not active.",
+ );
+ resolve();
+ return;
+ };
+ };
+ });
+});
+
+// IDBCursor.continue() - index - throw InvalidStateError caused by object store been deleted
+test("WPT idbcursor-continue-index8.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (event: any) {
+ db = event.target.result;
+ var objStore = db.createObjectStore("store", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+ for (var i = 0; i < records.length; i++) {
+ objStore.add(records[i]);
+ }
+ var rq = objStore.index("index").openCursor();
+ rq.onsuccess = function (event: any) {
+ var cursor = event.target.result;
+ t.true(cursor instanceof BridgeIDBCursor);
+
+ db.deleteObjectStore("store");
+
+ t.throws(
+ () => {
+ cursor.continue();
+ },
+ { name: "InvalidStateError" },
+ "If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type InvalidStateError",
+ );
+
+ resolve();
+ };
};
- };
+ });
});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-objectstore.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-objectstore.test.ts
index 4843b13ab..e3169195f 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-objectstore.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-objectstore.test.ts
@@ -1,243 +1,264 @@
import test from "ava";
-import { BridgeIDBCursor } from "..";
-import { BridgeIDBCursorWithValue } from "../bridge-idb";
-import { IDBDatabase } from "../idbtypes";
-import { createdb } from "./wptsupport";
+import { BridgeIDBCursor } from "../bridge-idb.js";
+import { IDBDatabase } from "../idbtypes.js";
+import { createdb } from "./wptsupport.js";
// IDBCursor.continue() - object store - iterate to the next record
-test.cb("WPT test idbcursor_continue_objectstore.htm", (t) => {
- var db: any;
- let count = 0;
- const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", {
- autoIncrement: true,
- keyPath: "pKey",
- });
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var store = db.transaction("test").objectStore("test");
-
- var cursor_rq = store.openCursor();
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- if (!cursor) {
- t.deepEqual(count, records.length, "cursor run count");
- t.end();
- }
-
- var record = cursor.value;
- t.deepEqual(record.pKey, records[count].pKey, "primary key");
-
- cursor.continue();
- count++;
+test("WPT test idbcursor_continue_objectstore.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ let count = 0;
+ const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", {
+ autoIncrement: true,
+ keyPath: "pKey",
+ });
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
};
- };
+
+ open_rq.onsuccess = function (e: any) {
+ var store = db.transaction("test").objectStore("test");
+
+ var cursor_rq = store.openCursor();
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ if (!cursor) {
+ t.deepEqual(count, records.length, "cursor run count");
+ resolve();
+ return;
+ }
+
+ var record = cursor.value;
+ t.deepEqual(record.pKey, records[count].pKey, "primary key");
+
+ cursor.continue();
+ count++;
+ };
+ };
+ });
});
// IDBCursor.continue() - index - attempt to pass a
// key parameter that is not a valid key
-test.cb("WPT test idbcursor_continue_objectstore2.htm", (t) => {
- var db: any;
- const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
+test("WPT test idbcursor_continue_objectstore2.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db.transaction("test").objectStore("test").openCursor();
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db.transaction("test").objectStore("test").openCursor();
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exists");
- t.throws(
- () => {
- cursor.continue({ foo: "42" });
- },
- { name: "DataError" },
- );
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exists");
+ t.throws(
+ () => {
+ cursor.continue({ foo: "42" });
+ },
+ { name: "DataError" },
+ );
- t.end();
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.continue() - object store - attempt to iterate to the
// previous record when the direction is set for the next record
-test.cb("WPT test idbcursor_continue_objectstore3.htm", (t) => {
- var db: IDBDatabase;
- const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db
- .transaction("test")
- .objectStore("test")
- .openCursor(undefined, "next");
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
-
- t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
- t.throws(
- () => {
- cursor.continue(records[0].pKey);
- },
- {
- name: "DataError",
- },
- );
-
- t.end();
+test("WPT test idbcursor_continue_objectstore3.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: IDBDatabase;
+ const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db
+ .transaction("test")
+ .objectStore("test")
+ .openCursor(undefined, "next");
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
+ t.throws(
+ () => {
+ cursor.continue(records[0].pKey);
+ },
+ {
+ name: "DataError",
+ },
+ );
+
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.continue() - object store - attempt to iterate to the
// next record when the direction is set for the previous record
-test.cb("WPT test idbcursor_continue_objectstore4.htm", (t) => {
- var db: any;
- const records = [
- { pKey: "primaryKey_0" },
- { pKey: "primaryKey_1" },
- { pKey: "primaryKey_2" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var count = 0,
- cursor_rq = db
- .transaction("test")
- .objectStore("test")
- .openCursor(null, "prev");
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
-
- t.true(cursor != null, "cursor exist");
-
- switch (count) {
- case 0:
- t.deepEqual(cursor.value.pKey, records[2].pKey, "first cursor pkey");
- cursor.continue(records[1].pKey);
- break;
-
- case 1:
- t.deepEqual(cursor.value.pKey, records[1].pKey, "second cursor pkey");
- t.throws(
- () => {
- console.log("**** continuing cursor");
- cursor.continue(records[2].pKey);
- console.log("**** this should not happen");
- },
- {
- name: "DataError",
- },
- );
- t.end();
- break;
-
- default:
- t.fail("Unexpected count value: " + count);
- }
-
- count++;
+test("WPT test idbcursor_continue_objectstore4.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ const records = [
+ { pKey: "primaryKey_0" },
+ { pKey: "primaryKey_1" },
+ { pKey: "primaryKey_2" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var count = 0,
+ cursor_rq = db
+ .transaction("test")
+ .objectStore("test")
+ .openCursor(null, "prev");
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+
+ t.true(cursor != null, "cursor exist");
+
+ switch (count) {
+ case 0:
+ t.deepEqual(
+ cursor.value.pKey,
+ records[2].pKey,
+ "first cursor pkey",
+ );
+ cursor.continue(records[1].pKey);
+ break;
+
+ case 1:
+ t.deepEqual(
+ cursor.value.pKey,
+ records[1].pKey,
+ "second cursor pkey",
+ );
+ t.throws(
+ () => {
+ console.log("**** continuing cursor");
+ cursor.continue(records[2].pKey);
+ console.log("**** this should not happen");
+ },
+ {
+ name: "DataError",
+ },
+ );
+ resolve();
+ return;
+
+ default:
+ t.fail("Unexpected count value: " + count);
+ }
+
+ count++;
+ };
};
- };
+ });
});
// IDBCursor.continue() - object store - throw TransactionInactiveError
-test.cb("WPT test idbcursor_continue_objectstore5.htm", (t) => {
- var db: any;
- const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db.transaction("test").objectStore("test").openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exists");
-
- e.target.transaction.abort();
- t.throws(
- () => {
- cursor.continue();
- },
- {
- name: "TransactionInactiveError",
- },
- "Calling continue() should throw an exception TransactionInactiveError when the transaction is not active.",
- );
-
- t.end();
+test("WPT test idbcursor_continue_objectstore5.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db.transaction("test").objectStore("test").openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exists");
+
+ e.target.transaction.abort();
+ t.throws(
+ () => {
+ cursor.continue();
+ },
+ {
+ name: "TransactionInactiveError",
+ },
+ "Calling continue() should throw an exception TransactionInactiveError when the transaction is not active.",
+ );
+
+ resolve();
+ return;
+ };
};
- };
+ });
});
// IDBCursor.continue() - object store - throw InvalidStateError caused by object store been deleted
-test.cb("WPT test idbcursor_continue_objectstore6.htm", (t) => {
- var db: any;
- const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
-
- var cursor_rq = objStore.openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exists");
-
- db.deleteObjectStore("test");
- t.throws(
- () => {
- cursor.continue();
- },
- {
- name: "InvalidStateError",
- },
- "If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type InvalidStateError",
- );
-
- t.end();
+test("WPT test idbcursor_continue_objectstore6.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+
+ var cursor_rq = objStore.openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exists");
+
+ db.deleteObjectStore("test");
+ t.throws(
+ () => {
+ cursor.continue();
+ },
+ {
+ name: "InvalidStateError",
+ },
+ "If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type InvalidStateError",
+ );
+
+ resolve();
+ };
};
- };
+ });
});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-exception-order.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-exception-order.test.ts
index 604061acd..f771d19a2 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-exception-order.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-exception-order.test.ts
@@ -1,5 +1,5 @@
import test from "ava";
-import { createdb, indexeddb_test } from "./wptsupport";
+import { indexeddb_test } from "./wptsupport.js";
test("WPT idbcursor-delete-exception-order.htm", async (t) => {
// 'IDBCursor.delete exception order: TransactionInactiveError vs. ReadOnlyError'
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-index.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-index.test.ts
index 0b28a4d4d..0232cf247 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-index.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-index.test.ts
@@ -1,204 +1,214 @@
import test from "ava";
-import { BridgeIDBCursor } from "..";
-import { IDBCursor } from "../idbtypes";
-import { createdb, indexeddb_test } from "./wptsupport";
+import { BridgeIDBCursor } from "../bridge-idb.js";
+import { IDBCursor } from "../idbtypes.js";
+import { createdb } from "./wptsupport.js";
// IDBCursor.delete() - index - remove a record from the object store
-test.cb("WPT idbcursor-delete-index.htm", (t) => {
- var db: any;
- let count = 0,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
+test("WPT idbcursor-delete-index.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ let count = 0,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
- open_rq.onsuccess = CursorDeleteRecord;
+ open_rq.onsuccess = CursorDeleteRecord;
- function CursorDeleteRecord(e: any) {
- var txn = db.transaction("test", "readwrite"),
- cursor_rq = txn.objectStore("test").index("index").openCursor();
+ function CursorDeleteRecord(e: any) {
+ var txn = db.transaction("test", "readwrite"),
+ cursor_rq = txn.objectStore("test").index("index").openCursor();
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
- cursor.delete();
- };
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
+ cursor.delete();
+ };
- txn.oncomplete = VerifyRecordWasDeleted;
- }
+ txn.oncomplete = VerifyRecordWasDeleted;
+ }
- function VerifyRecordWasDeleted(e: any) {
- var cursor_rq = db.transaction("test").objectStore("test").openCursor();
+ function VerifyRecordWasDeleted(e: any) {
+ var cursor_rq = db.transaction("test").objectStore("test").openCursor();
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
- if (!cursor) {
- t.deepEqual(count, 1, "count");
- t.end();
- return;
- }
+ if (!cursor) {
+ t.deepEqual(count, 1, "count");
+ resolve();
+ return;
+ }
- t.deepEqual(cursor.value.pKey, records[1].pKey);
- t.deepEqual(cursor.value.iKey, records[1].iKey);
- cursor.continue();
- count++;
- };
- }
+ t.deepEqual(cursor.value.pKey, records[1].pKey);
+ t.deepEqual(cursor.value.iKey, records[1].iKey);
+ cursor.continue();
+ count++;
+ };
+ }
+ });
});
// IDBCursor.delete() - object store - attempt to remove a record in a read-only transaction
-test.cb("WPT idbcursor-delete-index2.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db.transaction("test").objectStore("test").openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
-
- t.true(cursor != null, "cursor exist");
- t.throws(
- () => {
- cursor.delete();
- },
- {
- name: "ReadOnlyError",
- },
- );
- t.end();
- };
- };
-});
+test("WPT idbcursor-delete-index2.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
-// IDBCursor.delete() - index - attempt to remove a record in an inactive transaction
-test.cb("WPT idbcursor-delete-index3.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- var index = objStore.createIndex("index", "iKey");
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
-
- var cursor_rq = index.openCursor();
-
- let myCursor: IDBCursor | undefined;
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
- myCursor = cursor;
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db.transaction("test").objectStore("test").openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+
+ t.true(cursor != null, "cursor exist");
+ t.throws(
+ () => {
+ cursor.delete();
+ },
+ {
+ name: "ReadOnlyError",
+ },
+ );
+ resolve();
+ };
};
+ });
+});
- e.target.transaction.oncomplete = function (e: any) {
- t.throws(
- () => {
- myCursor!.delete();
- },
- { name: "TransactionInactiveError" },
- );
- t.end();
+// IDBCursor.delete() - index - attempt to remove a record in an inactive transaction
+test("WPT idbcursor-delete-index3.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ var index = objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+
+ var cursor_rq = index.openCursor();
+
+ let myCursor: IDBCursor | undefined;
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
+ myCursor = cursor;
+ };
+
+ e.target.transaction.oncomplete = function (e: any) {
+ t.throws(
+ () => {
+ myCursor!.delete();
+ },
+ { name: "TransactionInactiveError" },
+ );
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.delete() - index - throw InvalidStateError caused by object store been deleted
-test.cb("WPT idbcursor-delete-index4.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (event: any) {
- db = event.target.result;
- var objStore = db.createObjectStore("store", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
- for (var i = 0; i < records.length; i++) {
- objStore.add(records[i]);
- }
- var rq = objStore.index("index").openCursor();
- rq.onsuccess = function (event: any) {
- var cursor = event.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
-
- db.deleteObjectStore("store");
- t.throws(
- function () {
- cursor.delete();
- },
- { name: "InvalidStateError" },
- "If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type InvalidStateError",
- );
-
- t.end();
+test("WPT idbcursor-delete-index4.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (event: any) {
+ db = event.target.result;
+ var objStore = db.createObjectStore("store", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+ for (var i = 0; i < records.length; i++) {
+ objStore.add(records[i]);
+ }
+ var rq = objStore.index("index").openCursor();
+ rq.onsuccess = function (event: any) {
+ var cursor = event.target.result;
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
+
+ db.deleteObjectStore("store");
+ t.throws(
+ function () {
+ cursor.delete();
+ },
+ { name: "InvalidStateError" },
+ "If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type InvalidStateError",
+ );
+
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.delete() - index - throw InvalidStateError when the cursor is being iterated
-test.cb("WPT idbcursor-delete-index5.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (event: any) {
- db = event.target.result;
- var objStore = db.createObjectStore("store", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
- for (var i = 0; i < records.length; i++) {
- objStore.add(records[i]);
- }
-
- var rq = objStore.index("index").openCursor();
- rq.onsuccess = function (event: any) {
- var cursor = event.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
-
- cursor.continue();
- t.throws(
- function () {
- cursor.delete();
- },
- { name: "InvalidStateError" },
- );
+test("WPT idbcursor-delete-index5.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (event: any) {
+ db = event.target.result;
+ var objStore = db.createObjectStore("store", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+ for (var i = 0; i < records.length; i++) {
+ objStore.add(records[i]);
+ }
- t.end();
+ var rq = objStore.index("index").openCursor();
+ rq.onsuccess = function (event: any) {
+ var cursor = event.target.result;
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
+
+ cursor.continue();
+ t.throws(
+ function () {
+ cursor.delete();
+ },
+ { name: "InvalidStateError" },
+ );
+
+ resolve();
+ };
};
- };
+ });
});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-objectstore.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-objectstore.test.ts
index 7afe1e483..9410ca79e 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-objectstore.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-objectstore.test.ts
@@ -1,194 +1,204 @@
import test from "ava";
-import { BridgeIDBCursor } from "..";
-import { IDBCursor } from "../idbtypes";
-import { createdb, indexeddb_test } from "./wptsupport";
+import { BridgeIDBCursor } from "../bridge-idb.js";
+import { createdb } from "./wptsupport.js";
// IDBCursor.delete() - object store - remove a record from the object store
-test.cb("WPT idbcursor-delete-objectstore.htm", (t) => {
- var db: any,
- count = 0,
- records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
+test("WPT idbcursor-delete-objectstore.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ count = 0,
+ records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
- open_rq.onsuccess = CursorDeleteRecord;
+ open_rq.onsuccess = CursorDeleteRecord;
- function CursorDeleteRecord(e: any) {
- var txn = db.transaction("test", "readwrite"),
- cursor_rq = txn.objectStore("test").openCursor();
+ function CursorDeleteRecord(e: any) {
+ var txn = db.transaction("test", "readwrite"),
+ cursor_rq = txn.objectStore("test").openCursor();
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
- t.true(cursor != null, "cursor exist");
- cursor.delete();
- };
+ t.true(cursor != null, "cursor exist");
+ cursor.delete();
+ };
- txn.oncomplete = VerifyRecordWasDeleted;
- }
+ txn.oncomplete = VerifyRecordWasDeleted;
+ }
- function VerifyRecordWasDeleted(e: any) {
- var cursor_rq = db.transaction("test").objectStore("test").openCursor();
+ function VerifyRecordWasDeleted(e: any) {
+ var cursor_rq = db.transaction("test").objectStore("test").openCursor();
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
- if (!cursor) {
- t.deepEqual(count, 1, "count");
- t.end();
- }
+ if (!cursor) {
+ t.deepEqual(count, 1, "count");
+ resolve();
+ return;
+ }
- t.deepEqual(cursor.value.pKey, records[1].pKey);
- count++;
- cursor.continue();
- };
- }
+ t.deepEqual(cursor.value.pKey, records[1].pKey);
+ count++;
+ cursor.continue();
+ };
+ }
+ });
});
// IDBCursor.delete() - object store - attempt to remove a record in a read-only transaction
-test.cb("WPT idbcursor-delete-objectstore2.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db.transaction("test").objectStore("test").openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
-
- t.true(cursor != null, "cursor exist");
- t.throws(
- function () {
- cursor.delete();
- },
- { name: "ReadOnlyError" },
- );
- t.end();
- };
- };
-});
-
-// IDBCursor.delete() - index - attempt to remove a record in an inactive transaction
-test.cb("WPT idbcursor-delete-objectstore3.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
+test("WPT idbcursor-delete-objectstore2.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- var cursor_rq = objStore.openCursor();
-
- const window: any = {};
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
- window.cursor = cursor;
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db.transaction("test").objectStore("test").openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+
+ t.true(cursor != null, "cursor exist");
+ t.throws(
+ function () {
+ cursor.delete();
+ },
+ { name: "ReadOnlyError" },
+ );
+ resolve();
+ };
};
+ });
+});
- e.target.transaction.oncomplete = function (e: any) {
- t.throws(
- function () {
- window.cursor.delete();
- },
- {
- name: "TransactionInactiveError",
- },
- );
- t.end();
+// IDBCursor.delete() - index - attempt to remove a record in an inactive transaction
+test("WPT idbcursor-delete-objectstore3.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+
+ var cursor_rq = objStore.openCursor();
+
+ const window: any = {};
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
+ window.cursor = cursor;
+ };
+
+ e.target.transaction.oncomplete = function (e: any) {
+ t.throws(
+ function () {
+ window.cursor.delete();
+ },
+ {
+ name: "TransactionInactiveError",
+ },
+ );
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.delete() - object store - throw InvalidStateError caused by object store been deleted
-test.cb("WPT idbcursor-delete-objectstore4.htm", (t) => {
- var db: any,
- records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (event: any) {
- db = event.target.result;
- var objStore = db.createObjectStore("store", { keyPath: "pKey" });
- for (var i = 0; i < records.length; i++) {
- objStore.add(records[i]);
- }
- var rq = objStore.openCursor();
- rq.onsuccess = function (event: any) {
- var cursor = event.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
-
- db.deleteObjectStore("store");
- t.throws(
- function () {
- cursor.delete();
- },
- { name: "InvalidStateError" },
- "If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type InvalidStateError",
- );
-
- t.end();
+test("WPT idbcursor-delete-objectstore4.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (event: any) {
+ db = event.target.result;
+ var objStore = db.createObjectStore("store", { keyPath: "pKey" });
+ for (var i = 0; i < records.length; i++) {
+ objStore.add(records[i]);
+ }
+ var rq = objStore.openCursor();
+ rq.onsuccess = function (event: any) {
+ var cursor = event.target.result;
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
+
+ db.deleteObjectStore("store");
+ t.throws(
+ function () {
+ cursor.delete();
+ },
+ { name: "InvalidStateError" },
+ "If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type InvalidStateError",
+ );
+
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.delete() - object store - throw InvalidStateError when the cursor is being iterated
-test.cb("WPT idbcursor-delete-objectstore5.htm", (t) => {
- var db: any,
- records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (event: any) {
- db = event.target.result;
- var objStore = db.createObjectStore("store", { keyPath: "pKey" });
- for (var i = 0; i < records.length; i++) {
- objStore.add(records[i]);
- }
- };
-
- open_rq.onsuccess = function (event: any) {
- var txn = db.transaction("store", "readwrite");
- var rq = txn.objectStore("store").openCursor();
- rq.onsuccess = function (event: any) {
- var cursor = event.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
-
- cursor.continue();
- t.throws(
- function () {
- cursor.delete();
- },
- {
- name: "InvalidStateError",
- },
- );
-
- t.end();
+test("WPT idbcursor-delete-objectstore5.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (event: any) {
+ db = event.target.result;
+ var objStore = db.createObjectStore("store", { keyPath: "pKey" });
+ for (var i = 0; i < records.length; i++) {
+ objStore.add(records[i]);
+ }
+ };
+
+ open_rq.onsuccess = function (event: any) {
+ var txn = db.transaction("store", "readwrite");
+ var rq = txn.objectStore("store").openCursor();
+ rq.onsuccess = function (event: any) {
+ var cursor = event.target.result;
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
+
+ cursor.continue();
+ t.throws(
+ function () {
+ cursor.delete();
+ },
+ {
+ name: "InvalidStateError",
+ },
+ );
+
+ resolve();
+ };
};
- };
+ });
});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.test.ts
index 3c2ee875d..54745802e 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.test.ts
@@ -1,5 +1,5 @@
import test from "ava";
-import { createdb } from "./wptsupport";
+import { createdb } from "./wptsupport.js";
test("WPT idbcursor-reused.htm", async (t) => {
await new Promise<void>((resolve, reject) => {
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-update-index.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-update-index.test.ts
index dcbee2b16..81a7cd753 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-update-index.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-update-index.test.ts
@@ -1,340 +1,356 @@
import test from "ava";
-import { BridgeIDBCursor, BridgeIDBKeyRange } from "..";
+import { BridgeIDBCursor, BridgeIDBKeyRange } from "../bridge-idb.js";
import {
createDatabase,
createdb,
promiseForRequest,
promiseForTransaction,
-} from "./wptsupport";
+} from "./wptsupport.js";
// IDBCursor.update() - index - modify a record in the object store
-test.cb("WPT test idbcursor_update_index.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
+test("WPT test idbcursor_update_index.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- // XXX: Gecko doesn't like this
- //e.target.transaction.oncomplete = t.step_func(CursorUpdateRecord);
- };
+ // XXX: Gecko doesn't like this
+ //e.target.transaction.oncomplete = t.step_func(CursorUpdateRecord);
+ };
- open_rq.onsuccess = CursorUpdateRecord;
+ open_rq.onsuccess = CursorUpdateRecord;
- function CursorUpdateRecord(e: any) {
- var txn = db.transaction("test", "readwrite"),
- cursor_rq = txn.objectStore("test").index("index").openCursor();
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
+ function CursorUpdateRecord(e: any) {
+ var txn = db.transaction("test", "readwrite"),
+ cursor_rq = txn.objectStore("test").index("index").openCursor();
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
- cursor.value.iKey += "_updated";
- cursor.update(cursor.value);
- };
+ cursor.value.iKey += "_updated";
+ cursor.update(cursor.value);
+ };
- txn.oncomplete = VerifyRecordWasUpdated;
- }
+ txn.oncomplete = VerifyRecordWasUpdated;
+ }
- function VerifyRecordWasUpdated(e: any) {
- var cursor_rq = db.transaction("test").objectStore("test").openCursor();
+ function VerifyRecordWasUpdated(e: any) {
+ var cursor_rq = db.transaction("test").objectStore("test").openCursor();
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
- t.deepEqual(cursor.value.iKey, records[0].iKey + "_updated");
- t.end();
- };
- }
+ t.deepEqual(cursor.value.iKey, records[0].iKey + "_updated");
+ resolve();
+ };
+ }
+ });
});
// IDBCursor.update() - index - attempt to modify a record in a read-only transaction
-test.cb("WPT test idbcursor_update_index2.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db
- .transaction("test")
- .objectStore("test")
- .index("index")
- .openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- t.throws(
- function () {
- cursor.update(cursor.value);
- },
- { name: "ReadOnlyError" },
- );
- t.end();
+test("WPT test idbcursor_update_index2.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
};
- };
-});
-//IDBCursor.update() - index - attempt to modify a record in an inactive transaction
-test.cb("WPT test idbcursor_update_index3.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- var index = objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
-
- var cursor_rq = index.openCursor();
-
- const window: any = {};
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
- window.cursor = cursor;
- window.record = cursor.value;
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db
+ .transaction("test")
+ .objectStore("test")
+ .index("index")
+ .openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.throws(
+ function () {
+ cursor.update(cursor.value);
+ },
+ { name: "ReadOnlyError" },
+ );
+ resolve();
+ };
};
+ });
+});
- e.target.transaction.oncomplete = function (e: any) {
- t.throws(
- function () {
- window.cursor.update(window.record);
- },
- { name: "TransactionInactiveError" },
- );
- t.end();
+//IDBCursor.update() - index - attempt to modify a record in an inactive transaction
+test("WPT test idbcursor_update_index3.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ var index = objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+
+ var cursor_rq = index.openCursor();
+
+ const window: any = {};
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
+ window.cursor = cursor;
+ window.record = cursor.value;
+ };
+
+ e.target.transaction.oncomplete = function (e: any) {
+ t.throws(
+ function () {
+ window.cursor.update(window.record);
+ },
+ { name: "TransactionInactiveError" },
+ );
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.update() - index - attempt to modify a record when object store been deleted
-test.cb("WPT test idbcursor_update_index4.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (event: any) {
- db = event.target.result;
- var objStore = db.createObjectStore("store", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
- for (var i = 0; i < records.length; i++) {
- objStore.add(records[i]);
- }
- var rq = objStore.index("index").openCursor();
- rq.onsuccess = function (event: any) {
- var cursor = event.target.result;
- t.true(cursor instanceof BridgeIDBCursor);
-
- db.deleteObjectStore("store");
- cursor.value.iKey += "_updated";
- t.throws(
- function () {
- cursor.update(cursor.value);
- },
- { name: "InvalidStateError" },
- "If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type InvalidStateError",
- );
-
- t.end();
+test("WPT test idbcursor_update_index4.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (event: any) {
+ db = event.target.result;
+ var objStore = db.createObjectStore("store", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+ for (var i = 0; i < records.length; i++) {
+ objStore.add(records[i]);
+ }
+ var rq = objStore.index("index").openCursor();
+ rq.onsuccess = function (event: any) {
+ var cursor = event.target.result;
+ t.true(cursor instanceof BridgeIDBCursor);
+
+ db.deleteObjectStore("store");
+ cursor.value.iKey += "_updated";
+ t.throws(
+ function () {
+ cursor.update(cursor.value);
+ },
+ { name: "InvalidStateError" },
+ "If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type InvalidStateError",
+ );
+
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.update() - index - throw DataCloneError
-test.cb("WPT test idbcursor_update_index5.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db
- .transaction("test", "readwrite")
- .objectStore("test")
- .index("index")
- .openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor);
-
- var record = cursor.value;
- // Original test uses different uncloneable value
- record.data = { foo: () => {} };
- t.throws(
- function () {
- cursor.update(record);
- },
- { name: "DataCloneError" },
- );
- t.end();
+test("WPT test idbcursor_update_index5.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db
+ .transaction("test", "readwrite")
+ .objectStore("test")
+ .index("index")
+ .openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.true(cursor instanceof BridgeIDBCursor);
+
+ var record = cursor.value;
+ // Original test uses different uncloneable value
+ record.data = { foo: () => {} };
+ t.throws(
+ function () {
+ cursor.update(record);
+ },
+ { name: "DataCloneError" },
+ );
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.update() - index - no argument
-test.cb("WPT test idbcursor_update_index6.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db
- .transaction("test")
- .objectStore("test")
- .index("index")
- .openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor);
-
- t.throws(
- function () {
- cursor.update();
- },
- {
- instanceOf: TypeError,
- },
- );
- t.end();
+test("WPT test idbcursor_update_index6.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db
+ .transaction("test")
+ .objectStore("test")
+ .index("index")
+ .openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.true(cursor instanceof BridgeIDBCursor);
+
+ t.throws(
+ function () {
+ cursor.update();
+ },
+ {
+ instanceOf: TypeError,
+ },
+ );
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.update() - index - throw DataError
-test.cb("WPT test idbcursor_update_index7.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var objStore = db.createObjectStore("test", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db
- .transaction("test", "readwrite")
- .objectStore("test")
- .index("index")
- .openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor);
-
- t.throws(
- function () {
- cursor.update(null);
- },
- { name: "DataError" },
- );
- t.end();
+test("WPT test idbcursor_update_index7.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+
+ var objStore = db.createObjectStore("test", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db
+ .transaction("test", "readwrite")
+ .objectStore("test")
+ .index("index")
+ .openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.true(cursor instanceof BridgeIDBCursor);
+
+ t.throws(
+ function () {
+ cursor.update(null);
+ },
+ { name: "DataError" },
+ );
+ resolve();
+ };
};
- };
+ });
});
// IDBCursor.update() - index - throw InvalidStateError when the cursor is being iterated
-test.cb("WPT test idbcursor_update_index8.htm", (t) => {
- var db: any,
- records = [
- { pKey: "primaryKey_0", iKey: "indexKey_0" },
- { pKey: "primaryKey_1", iKey: "indexKey_1" },
- ];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var objStore = db.createObjectStore("store", { keyPath: "pKey" });
- objStore.createIndex("index", "iKey");
-
- for (var i = 0; i < records.length; i++) objStore.add(records[i]);
- };
-
- open_rq.onsuccess = function (e: any) {
- var cursor_rq = db
- .transaction("store", "readwrite")
- .objectStore("store")
- .index("index")
- .openCursor();
-
- cursor_rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
- t.true(cursor instanceof BridgeIDBCursor, "cursor exists");
+test("WPT test idbcursor_update_index8.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+
+ var objStore = db.createObjectStore("store", { keyPath: "pKey" });
+ objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++) objStore.add(records[i]);
+ };
- cursor.continue();
- t.throws(
- function () {
- cursor.update({ pKey: "primaryKey_0", iKey: "indexKey_0_updated" });
- },
- {
- name: "InvalidStateError",
- },
- );
-
- t.end();
+ open_rq.onsuccess = function (e: any) {
+ var cursor_rq = db
+ .transaction("store", "readwrite")
+ .objectStore("store")
+ .index("index")
+ .openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.true(cursor instanceof BridgeIDBCursor, "cursor exists");
+
+ cursor.continue();
+ t.throws(
+ function () {
+ cursor.update({ pKey: "primaryKey_0", iKey: "indexKey_0_updated" });
+ },
+ {
+ name: "InvalidStateError",
+ },
+ );
+
+ resolve();
+ };
};
- };
+ });
});
// Index cursor - indexed values updated during iteration
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbfactory-cmp.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbfactory-cmp.test.ts
index c7a25a46b..a6cb97612 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbfactory-cmp.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbfactory-cmp.test.ts
@@ -1,5 +1,5 @@
import test from "ava";
-import { createdb, idbFactory } from "./wptsupport";
+import { idbFactory } from "./wptsupport.js";
test("WPT idbfactory-cmp*.html", async (t) => {
const indexedDB = idbFactory;
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts
index bba9c6e54..02618f171 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts
@@ -1,7 +1,7 @@
import test from "ava";
-import { BridgeIDBVersionChangeEvent } from "../bridge-idb";
-import FakeEvent from "../util/FakeEvent";
-import { createdb, format_value, idbFactory } from "./wptsupport";
+import { BridgeIDBVersionChangeEvent } from "../bridge-idb.js";
+import FakeEvent from "../util/FakeEvent.js";
+import { createdb, format_value, idbFactory } from "./wptsupport.js";
// IDBFactory.open() - request has no source
test("WPT idbfactory-open.htm", async (t) => {
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbindex-get.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbindex-get.test.ts
index 751b4f983..d3b6e844e 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbindex-get.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbindex-get.test.ts
@@ -1,7 +1,7 @@
import test from "ava";
-import { BridgeIDBKeyRange, BridgeIDBRequest } from "..";
-import { IDBDatabase } from "../idbtypes";
-import { createdb } from "./wptsupport";
+import { BridgeIDBKeyRange } from "../bridge-idb.js";
+import { IDBDatabase } from "../idbtypes.js";
+import { createdb } from "./wptsupport.js";
// IDBIndex.get() - returns the record
test("WPT idbindex_get.htm", async (t) => {
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbindex-openCursor.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbindex-openCursor.test.ts
index f4515b69e..765bcf06a 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbindex-openCursor.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbindex-openCursor.test.ts
@@ -1,82 +1,85 @@
import test from "ava";
-import { BridgeIDBCursor } from "..";
-import { BridgeIDBCursorWithValue } from "../bridge-idb";
-import { IDBDatabase } from "../idbtypes";
-import { createdb } from "./wptsupport";
+import { createdb } from "./wptsupport.js";
// IDBIndex.openCursor() - throw InvalidStateError when the index is deleted
-test.cb("WPT test idbindex-openCursor.htm", (t) => {
- var db;
+test("WPT test idbindex-openCursor.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db;
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var store = db.createObjectStore("store", { keyPath: "key" });
- var index = store.createIndex("index", "indexedProperty");
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var store = db.createObjectStore("store", { keyPath: "key" });
+ var index = store.createIndex("index", "indexedProperty");
- store.add({ key: 1, indexedProperty: "data" });
- store.deleteIndex("index");
+ store.add({ key: 1, indexedProperty: "data" });
+ store.deleteIndex("index");
- t.throws(
- () => {
- index.openCursor();
- },
- { name: "InvalidStateError" },
- );
+ t.throws(
+ () => {
+ index.openCursor();
+ },
+ { name: "InvalidStateError" },
+ );
- t.end();
- };
+ resolve();
+ };
+ });
});
// IDBIndex.openCursor() - throw TransactionInactiveError on aborted transaction
-test.cb("WPT test idbindex-openCursor2.htm", (t) => {
- var db;
+test("WPT test idbindex-openCursor2.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db;
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var store = db.createObjectStore("store", { keyPath: "key" });
- var index = store.createIndex("index", "indexedProperty");
- store.add({ key: 1, indexedProperty: "data" });
- };
- open_rq.onsuccess = function (e: any) {
- db = e.target.result;
- var tx = db.transaction("store");
- var index = tx.objectStore("store").index("index");
- tx.abort();
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var store = db.createObjectStore("store", { keyPath: "key" });
+ var index = store.createIndex("index", "indexedProperty");
+ store.add({ key: 1, indexedProperty: "data" });
+ };
+ open_rq.onsuccess = function (e: any) {
+ db = e.target.result;
+ var tx = db.transaction("store");
+ var index = tx.objectStore("store").index("index");
+ tx.abort();
- t.throws(
- () => {
- index.openCursor();
- },
- { name: "TransactionInactiveError" },
- );
+ t.throws(
+ () => {
+ index.openCursor();
+ },
+ { name: "TransactionInactiveError" },
+ );
- t.end();
- };
+ resolve();
+ };
+ });
});
// IDBIndex.openCursor() - throw InvalidStateError on index deleted by aborted upgrade
-test.cb("WPT test idbindex-openCursor3.htm", (t) => {
- var db;
+test("WPT test idbindex-openCursor3.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db;
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var store = db.createObjectStore("store", { keyPath: "key" });
- var index = store.createIndex("index", "indexedProperty");
- store.add({ key: 1, indexedProperty: "data" });
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var store = db.createObjectStore("store", { keyPath: "key" });
+ var index = store.createIndex("index", "indexedProperty");
+ store.add({ key: 1, indexedProperty: "data" });
- e.target.transaction.abort();
+ e.target.transaction.abort();
- t.throws(
- () => {
- console.log("index before openCursor", index);
- index.openCursor();
- },
- { name: "InvalidStateError" },
- );
+ t.throws(
+ () => {
+ console.log("index before openCursor", index);
+ index.openCursor();
+ },
+ { name: "InvalidStateError" },
+ );
- t.end();
- };
+ resolve();
+ };
+ });
});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add-put-exception-order.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add-put-exception-order.test.ts
index a3aead9db..901eda89c 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add-put-exception-order.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add-put-exception-order.test.ts
@@ -1,8 +1,5 @@
import test, { ExecutionContext } from "ava";
-import { BridgeIDBCursor } from "..";
-import { BridgeIDBRequest } from "../bridge-idb";
-import { InvalidStateError } from "../util/errors";
-import { createdb, indexeddb_test } from "./wptsupport";
+import { indexeddb_test } from "./wptsupport.js";
async function t1(t: ExecutionContext, method: string): Promise<void> {
await indexeddb_test(
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add.test.ts
index 02f05f468..e8bc17471 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add.test.ts
@@ -1,7 +1,7 @@
import test from "ava";
-import { BridgeIDBRequest } from "..";
-import { IDBDatabase } from "../idbtypes";
-import { createdb } from "./wptsupport";
+import { BridgeIDBRequest } from "../bridge-idb.js";
+import { IDBDatabase } from "../idbtypes.js";
+import { createdb } from "./wptsupport.js";
// IDBObjectStore.add() - add with an inline key
test("WPT idbobjectstore_add.htm", async (t) => {
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-get.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-get.test.ts
index 0c9d30b7d..79064d19d 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-get.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-get.test.ts
@@ -1,159 +1,172 @@
import test from "ava";
-import { BridgeIDBKeyRange, BridgeIDBRequest } from "..";
-import { IDBDatabase } from "../idbtypes";
-import { createdb } from "./wptsupport";
+import { BridgeIDBKeyRange } from "../bridge-idb.js";
+import { createdb } from "./wptsupport.js";
// IDBObjectStore.get() - key is a number
-test.cb("WPT idbobjectstore_get.htm", (t) => {
- var db: any,
- record = { key: 3.14159265, property: "data" };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- db.createObjectStore("store", { keyPath: "key" }).add(record);
- };
-
- open_rq.onsuccess = function (e: any) {
- var rq = db.transaction("store").objectStore("store").get(record.key);
-
- rq.onsuccess = function (e: any) {
- t.deepEqual(e.target.result.key, record.key);
- t.deepEqual(e.target.result.property, record.property);
- t.end();
+test("WPT idbobjectstore_get.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { key: 3.14159265, property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ db.createObjectStore("store", { keyPath: "key" }).add(record);
};
- };
+
+ open_rq.onsuccess = function (e: any) {
+ var rq = db.transaction("store").objectStore("store").get(record.key);
+
+ rq.onsuccess = function (e: any) {
+ t.deepEqual(e.target.result.key, record.key);
+ t.deepEqual(e.target.result.property, record.property);
+ resolve();
+ };
+ };
+ });
});
// IDBObjectStore.get() - key is a string
-test.cb("WPT idbobjectstore_get2.htm", (t) => {
- var db: any,
- record = { key: "this is a key that's a string", property: "data" };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- db.createObjectStore("store", { keyPath: "key" }).add(record);
- };
-
- open_rq.onsuccess = function (e: any) {
- var rq = db.transaction("store").objectStore("store").get(record.key);
-
- rq.onsuccess = function (e: any) {
- t.deepEqual(e.target.result.key, record.key);
- t.deepEqual(e.target.result.property, record.property);
- t.end();
+test("WPT idbobjectstore_get2.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { key: "this is a key that's a string", property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ db.createObjectStore("store", { keyPath: "key" }).add(record);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var rq = db.transaction("store").objectStore("store").get(record.key);
+
+ rq.onsuccess = function (e: any) {
+ t.deepEqual(e.target.result.key, record.key);
+ t.deepEqual(e.target.result.property, record.property);
+ resolve();
+ };
};
- };
+ });
});
// IDBObjectStore.get() - key is a date
-test.cb("WPT idbobjectstore_get3.htm", (t) => {
- var db: any;
- const record = { key: new Date(), property: "data" };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- db.createObjectStore("store", { keyPath: "key" }).add(record);
- };
-
- open_rq.onsuccess = function (e: any) {
- var rq = db.transaction("store").objectStore("store").get(record.key);
-
- rq.onsuccess = function (e: any) {
- t.deepEqual(e.target.result.key.valueOf(), record.key.valueOf());
- t.deepEqual(e.target.result.property, record.property);
- t.end();
+test("WPT idbobjectstore_get3.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ const record = { key: new Date(), property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ db.createObjectStore("store", { keyPath: "key" }).add(record);
};
- };
+
+ open_rq.onsuccess = function (e: any) {
+ var rq = db.transaction("store").objectStore("store").get(record.key);
+
+ rq.onsuccess = function (e: any) {
+ t.deepEqual(e.target.result.key.valueOf(), record.key.valueOf());
+ t.deepEqual(e.target.result.property, record.property);
+ resolve();
+ };
+ };
+ });
});
// IDBObjectStore.get() - attempt to retrieve a record that doesn't exist
-test.cb("WPT idbobjectstore_get4.htm", (t) => {
- var db: any;
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var rq = db.createObjectStore("store", { keyPath: "key" }).get(1);
- rq.onsuccess = function (e: any) {
- t.deepEqual(e.target.results, undefined);
- setTimeout(function () {
- t.end();
- }, 10);
+test("WPT idbobjectstore_get4.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var rq = db.createObjectStore("store", { keyPath: "key" }).get(1);
+ rq.onsuccess = function (e: any) {
+ t.deepEqual(e.target.results, undefined);
+ setTimeout(function () {
+ resolve();
+ }, 10);
+ };
};
- };
- open_rq.onsuccess = function () {};
+ open_rq.onsuccess = function () {};
+ });
});
// IDBObjectStore.get() - returns the record with the first key in the range
-test.cb("WPT idbobjectstore_get5.htm", (t) => {
- var db: any;
- var open_rq = createdb(t);
-
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var os = db.createObjectStore("store");
-
- for (var i = 0; i < 10; i++) os.add("data" + i, i);
- };
-
- open_rq.onsuccess = function (e: any) {
- db
- .transaction("store")
- .objectStore("store")
- .get(BridgeIDBKeyRange.bound(3, 6)).onsuccess = function (e: any) {
- t.deepEqual(e.target.result, "data3", "get(3-6)");
- t.end();
+test("WPT idbobjectstore_get5.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+ var open_rq = createdb(t);
+
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var os = db.createObjectStore("store");
+
+ for (var i = 0; i < 10; i++) os.add("data" + i, i);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ db
+ .transaction("store")
+ .objectStore("store")
+ .get(BridgeIDBKeyRange.bound(3, 6)).onsuccess = function (e: any) {
+ t.deepEqual(e.target.result, "data3", "get(3-6)");
+ resolve();
+ };
};
- };
+ });
});
// IDBObjectStore.get() - throw TransactionInactiveError on aborted transaction
-test.cb("WPT idbobjectstore_get6.htm", (t) => {
- var db: any;
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- db.createObjectStore("store", { keyPath: "key" });
- };
-
- open_rq.onsuccess = function (e: any) {
- var store = db.transaction("store").objectStore("store");
- store.transaction.abort();
- t.throws(
- function () {
- store.get(1);
- },
- { name: "TransactionInactiveError" },
- "throw TransactionInactiveError on aborted transaction.",
- );
- t.end();
- };
+test("WPT idbobjectstore_get6.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ db.createObjectStore("store", { keyPath: "key" });
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var store = db.transaction("store").objectStore("store");
+ store.transaction.abort();
+ t.throws(
+ function () {
+ store.get(1);
+ },
+ { name: "TransactionInactiveError" },
+ "throw TransactionInactiveError on aborted transaction.",
+ );
+ resolve();
+ };
+ });
});
// IDBObjectStore.get() - throw DataError when using invalid key
-test.cb("WPT idbobjectstore_get7.htm", (t) => {
- var db: any;
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- db.createObjectStore("store", { keyPath: "key" });
- };
-
- open_rq.onsuccess = function (e: any) {
- var store = db.transaction("store").objectStore("store");
- t.throws(
- function () {
- store.get(null);
- },
- { name: "DataError" },
- "throw DataError when using invalid key.",
- );
- t.end();
- };
+test("WPT idbobjectstore_get7.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ db.createObjectStore("store", { keyPath: "key" });
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var store = db.transaction("store").objectStore("store");
+ t.throws(
+ function () {
+ store.get(null);
+ },
+ { name: "DataError" },
+ "throw DataError when using invalid key.",
+ );
+ resolve();
+ };
+ });
});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-put.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-put.test.ts
index 3ca1b8ecb..152e3a9c1 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-put.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-put.test.ts
@@ -1,449 +1,483 @@
import test from "ava";
-import { BridgeIDBKeyRange, BridgeIDBRequest } from "..";
-import { IDBDatabase } from "../idbtypes";
-import { createdb } from "./wptsupport";
+import { BridgeIDBRequest } from "../bridge-idb.js";
+import { createdb } from "./wptsupport.js";
// IDBObjectStore.put() - put with an inline key
-test.cb("WPT idbobjectstore_put.htm", (t) => {
- var db: any,
- record = { key: 1, property: "data" };
+test("WPT idbobjectstore_put.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { key: 1, property: "data" };
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("store", { keyPath: "key" });
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("store", { keyPath: "key" });
- objStore.put(record);
- };
+ objStore.put(record);
+ };
- open_rq.onsuccess = function (e: any) {
- var rq = db.transaction("store").objectStore("store").get(record.key);
+ open_rq.onsuccess = function (e: any) {
+ var rq = db.transaction("store").objectStore("store").get(record.key);
- rq.onsuccess = function (e: any) {
- t.deepEqual(e.target.result.property, record.property);
- t.deepEqual(e.target.result.key, record.key);
- t.end();
+ rq.onsuccess = function (e: any) {
+ t.deepEqual(e.target.result.property, record.property);
+ t.deepEqual(e.target.result.key, record.key);
+ resolve();
+ };
};
- };
+ });
});
// IDBObjectStore.put() - put with an out-of-line key
-test.cb("WPT idbobjectstore_put2.htm", (t) => {
- var db: any,
- key = 1,
- record = { property: "data" };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("store");
-
- objStore.put(record, key);
- };
+test("WPT idbobjectstore_put2.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ key = 1,
+ record = { property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("store");
+
+ objStore.put(record, key);
+ };
- open_rq.onsuccess = function (e: any) {
- var rq = db.transaction("store").objectStore("store").get(key);
+ open_rq.onsuccess = function (e: any) {
+ var rq = db.transaction("store").objectStore("store").get(key);
- rq.onsuccess = function (e: any) {
- t.deepEqual(e.target.result.property, record.property);
+ rq.onsuccess = function (e: any) {
+ t.deepEqual(e.target.result.property, record.property);
- t.end();
+ resolve();
+ };
};
- };
+ });
});
// IDBObjectStore.put() - put with an out-of-line key
-test.cb("WPT idbobjectstore_put3.htm", (t) => {
- var db: any,
- success_event: any,
- record = { key: 1, property: "data" },
- record_put = { key: 1, property: "changed", more: ["stuff", 2] };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("store", { keyPath: "key" });
- objStore.put(record);
-
- var rq = objStore.put(record_put);
- rq.onerror = () => t.fail("error on put");
-
- rq.onsuccess = function (e: any) {
- success_event = true;
+test("WPT idbobjectstore_put3.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ success_event: any,
+ record = { key: 1, property: "data" },
+ record_put = { key: 1, property: "changed", more: ["stuff", 2] };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("store", { keyPath: "key" });
+ objStore.put(record);
+
+ var rq = objStore.put(record_put);
+ rq.onerror = () => t.fail("error on put");
+
+ rq.onsuccess = function (e: any) {
+ success_event = true;
+ };
};
- };
- open_rq.onsuccess = function (e: any) {
- t.true(success_event);
+ open_rq.onsuccess = function (e: any) {
+ t.true(success_event);
- var rq = db.transaction("store").objectStore("store").get(1);
+ var rq = db.transaction("store").objectStore("store").get(1);
- rq.onsuccess = function (e: any) {
- var rec = e.target.result;
+ rq.onsuccess = function (e: any) {
+ var rec = e.target.result;
- t.deepEqual(rec.key, record_put.key);
- t.deepEqual(rec.property, record_put.property);
- t.deepEqual(rec.more, record_put.more);
+ t.deepEqual(rec.key, record_put.key);
+ t.deepEqual(rec.property, record_put.property);
+ t.deepEqual(rec.more, record_put.more);
- t.end();
+ resolve();
+ };
};
- };
+ });
});
// IDBObjectStore.put() - put where an index has unique:true specified
-test.cb("WPT idbobjectstore_put4.htm", (t) => {
- var db: any,
- record = { key: 1, property: "data" };
+test("WPT idbobjectstore_put4.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { key: 1, property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("store", { autoIncrement: true });
+ objStore.createIndex("i1", "property", { unique: true });
+ objStore.put(record);
+
+ var rq = objStore.put(record);
+ rq.onsuccess = () =>
+ t.fail("success on putting duplicate indexed record");
+
+ rq.onerror = function (e: any) {
+ t.deepEqual(rq.error.name, "ConstraintError");
+ t.deepEqual(e.target.error.name, "ConstraintError");
+
+ t.deepEqual(e.type, "error");
+
+ e.preventDefault();
+ e.stopPropagation();
+ };
+ };
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("store", { autoIncrement: true });
- objStore.createIndex("i1", "property", { unique: true });
- objStore.put(record);
+ // Defer done, giving a spurious rq.onsuccess a chance to run
+ open_rq.onsuccess = function (e: any) {
+ resolve();
+ };
+ });
+});
- var rq = objStore.put(record);
- rq.onsuccess = () => t.fail("success on putting duplicate indexed record");
+// IDBObjectStore.put() - object store's key path is an object attribute
+test("WPT idbobjectstore_put5.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { test: { obj: { key: 1 } }, property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("store", { keyPath: "test.obj.key" });
+ objStore.put(record);
+ };
- rq.onerror = function (e: any) {
- t.deepEqual(rq.error.name, "ConstraintError");
- t.deepEqual(e.target.error.name, "ConstraintError");
+ open_rq.onsuccess = function (e: any) {
+ var rq = db
+ .transaction("store")
+ .objectStore("store")
+ .get(record.test.obj.key);
- t.deepEqual(e.type, "error");
+ rq.onsuccess = function (e: any) {
+ t.deepEqual(e.target.result.property, record.property);
- e.preventDefault();
- e.stopPropagation();
+ resolve();
+ };
};
- };
-
- // Defer done, giving a spurious rq.onsuccess a chance to run
- open_rq.onsuccess = function (e: any) {
- t.end();
- };
+ });
});
-// IDBObjectStore.put() - object store's key path is an object attribute
-test.cb("WPT idbobjectstore_put5.htm", (t) => {
- var db: any,
- record = { test: { obj: { key: 1 } }, property: "data" };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("store", { keyPath: "test.obj.key" });
- objStore.put(record);
- };
-
- open_rq.onsuccess = function (e: any) {
- var rq = db
- .transaction("store")
- .objectStore("store")
- .get(record.test.obj.key);
-
- rq.onsuccess = function (e: any) {
- t.deepEqual(e.target.result.property, record.property);
-
- t.end();
+// IDBObjectStore.put() - autoIncrement and inline keys
+test("WPT idbobjectstore_put6.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { property: "data" },
+ expected_keys = [1, 2, 3, 4];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("store", {
+ keyPath: "key",
+ autoIncrement: true,
+ });
+
+ objStore.put(record);
+ objStore.put(record);
+ objStore.put(record);
+ objStore.put(record);
};
- };
-});
-// IDBObjectStore.put() - autoIncrement and inline keys
-test.cb("WPT idbobjectstore_put6.htm", (t) => {
- var db: any,
- record = { property: "data" },
- expected_keys = [1, 2, 3, 4];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("store", {
- keyPath: "key",
- autoIncrement: true,
- });
-
- objStore.put(record);
- objStore.put(record);
- objStore.put(record);
- objStore.put(record);
- };
-
- open_rq.onsuccess = function (e: any) {
- var actual_keys: any[] = [],
- rq = db.transaction("store").objectStore("store").openCursor();
-
- rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
-
- if (cursor) {
- actual_keys.push(cursor.value.key);
- cursor.continue();
- } else {
- t.deepEqual(actual_keys, expected_keys);
- t.end();
- }
+ open_rq.onsuccess = function (e: any) {
+ var actual_keys: any[] = [],
+ rq = db.transaction("store").objectStore("store").openCursor();
+
+ rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+
+ if (cursor) {
+ actual_keys.push(cursor.value.key);
+ cursor.continue();
+ } else {
+ t.deepEqual(actual_keys, expected_keys);
+ resolve();
+ return;
+ }
+ };
};
- };
+ });
});
// IDBObjectStore.put() - autoIncrement and out-of-line keys
-test.cb("WPT idbobjectstore_put7.htm", (t) => {
- var db: any,
- record = { property: "data" },
- expected_keys = [1, 2, 3, 4];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("store", { autoIncrement: true });
-
- objStore.put(record);
- objStore.put(record);
- objStore.put(record);
- objStore.put(record);
- };
-
- open_rq.onsuccess = function (e) {
- var actual_keys: any[] = [],
- rq = db.transaction("store").objectStore("store").openCursor();
-
- rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
-
- if (cursor) {
- actual_keys.push(cursor.key);
- cursor.continue();
- } else {
- t.deepEqual(actual_keys, expected_keys);
- t.end();
- }
+test("WPT idbobjectstore_put7.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { property: "data" },
+ expected_keys = [1, 2, 3, 4];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("store", { autoIncrement: true });
+
+ objStore.put(record);
+ objStore.put(record);
+ objStore.put(record);
+ objStore.put(record);
};
- };
+
+ open_rq.onsuccess = function (e) {
+ var actual_keys: any[] = [],
+ rq = db.transaction("store").objectStore("store").openCursor();
+
+ rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+
+ if (cursor) {
+ actual_keys.push(cursor.key);
+ cursor.continue();
+ } else {
+ t.deepEqual(actual_keys, expected_keys);
+ resolve();
+ }
+ };
+ };
+ });
});
// IDBObjectStore.put() - object store has autoIncrement:true and the key path is an object attribute
-test.cb("WPT idbobjectstore_put8.htm", (t) => {
- var db: any,
- record = { property: "data" },
- expected_keys = [1, 2, 3, 4];
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
- var objStore = db.createObjectStore("store", {
- keyPath: "test.obj.key",
- autoIncrement: true,
- });
-
- objStore.put(record);
- objStore.put(record);
- objStore.put(record);
- objStore.put(record);
- };
-
- open_rq.onsuccess = function (e: any) {
- var actual_keys: any[] = [],
- rq = db.transaction("store").objectStore("store").openCursor();
-
- rq.onsuccess = function (e: any) {
- var cursor = e.target.result;
-
- if (cursor) {
- actual_keys.push(cursor.value.test.obj.key);
- cursor.continue();
- } else {
- t.deepEqual(actual_keys, expected_keys);
- t.end();
- }
+test("WPT idbobjectstore_put8.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { property: "data" },
+ expected_keys = [1, 2, 3, 4];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("store", {
+ keyPath: "test.obj.key",
+ autoIncrement: true,
+ });
+
+ objStore.put(record);
+ objStore.put(record);
+ objStore.put(record);
+ objStore.put(record);
+ };
+
+ open_rq.onsuccess = function (e: any) {
+ var actual_keys: any[] = [],
+ rq = db.transaction("store").objectStore("store").openCursor();
+
+ rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+
+ if (cursor) {
+ actual_keys.push(cursor.value.test.obj.key);
+ cursor.continue();
+ } else {
+ t.deepEqual(actual_keys, expected_keys);
+ resolve();
+ return;
+ }
+ };
};
- };
+ });
});
//IDBObjectStore.put() - Attempt to put a record that does not meet the constraints of an object store's inline key requirements
-test.cb("WPT idbobjectstore_put9.htm", (t) => {
- var record = { key: 1, property: "data" };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- var rq,
- db = e.target.result,
- objStore = db.createObjectStore("store", { keyPath: "key" });
-
- t.throws(
- function () {
- rq = objStore.put(record, 1);
- },
- { name: "DataError" },
- );
-
- t.deepEqual(rq, undefined);
- t.end();
- };
+test("WPT idbobjectstore_put9.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var record = { key: 1, property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ var rq,
+ db = e.target.result,
+ objStore = db.createObjectStore("store", { keyPath: "key" });
+
+ t.throws(
+ function () {
+ rq = objStore.put(record, 1);
+ },
+ { name: "DataError" },
+ );
+
+ t.deepEqual(rq, undefined);
+ resolve();
+ };
+ });
});
//IDBObjectStore.put() - Attempt to call 'put' without an key parameter when the object store uses out-of-line keys
-test.cb("WPT idbobjectstore_put10.htm", (t) => {
- var db: any,
- record = { property: "data" };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var rq,
- objStore = db.createObjectStore("store", { keyPath: "key" });
-
- t.throws(
- function () {
- rq = objStore.put(record);
- },
- { name: "DataError" },
- );
-
- t.deepEqual(rq, undefined);
- t.end();
- };
+test("WPT idbobjectstore_put10.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+
+ var rq,
+ objStore = db.createObjectStore("store", { keyPath: "key" });
+
+ t.throws(
+ function () {
+ rq = objStore.put(record);
+ },
+ { name: "DataError" },
+ );
+
+ t.deepEqual(rq, undefined);
+ resolve();
+ };
+ });
});
// IDBObjectStore.put() - Attempt to put a record where the record's key does not meet the constraints of a valid key
-test.cb("WPT idbobjectstore_put11.htm", (t) => {
- var db: any,
- record = { key: { value: 1 }, property: "data" };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var rq,
- objStore = db.createObjectStore("store", { keyPath: "key" });
-
- t.throws(
- function () {
- rq = objStore.put(record);
- },
- { name: "DataError" },
- );
-
- t.deepEqual(rq, undefined);
- t.end();
- };
+test("WPT idbobjectstore_put11.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { key: { value: 1 }, property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+
+ var rq,
+ objStore = db.createObjectStore("store", { keyPath: "key" });
+
+ t.throws(
+ function () {
+ rq = objStore.put(record);
+ },
+ { name: "DataError" },
+ );
+
+ t.deepEqual(rq, undefined);
+ resolve();
+ };
+ });
});
// IDBObjectStore.put() - Attempt to put a record where the record's in-line key is not defined
-test.cb("WPT idbobjectstore_put12.htm", (t) => {
- var db: any,
- record = { property: "data" };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var rq,
- objStore = db.createObjectStore("store", { keyPath: "key" });
-
- t.throws(
- function () {
- rq = objStore.put(record);
- },
- { name: "DataError" },
- );
-
- t.deepEqual(rq, undefined);
- t.end();
- };
+test("WPT idbobjectstore_put12.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+
+ var rq,
+ objStore = db.createObjectStore("store", { keyPath: "key" });
+
+ t.throws(
+ function () {
+ rq = objStore.put(record);
+ },
+ { name: "DataError" },
+ );
+
+ t.deepEqual(rq, undefined);
+ resolve();
+ };
+ });
});
// IDBObjectStore.put() - Attempt to put a record where the out of line key provided does not meet the constraints of a valid key
-test.cb("WPT idbobjectstore_put13.htm", (t) => {
- var db: any,
- record = { property: "data" };
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
-
- var rq,
- objStore = db.createObjectStore("store");
-
- t.throws(
- function () {
- rq = objStore.put(record, { value: 1 });
- },
- {
- name: "DataError",
- },
- );
-
- t.deepEqual(rq, undefined);
- t.end();
- };
+test("WPT idbobjectstore_put13.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { property: "data" };
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+
+ var rq,
+ objStore = db.createObjectStore("store");
+
+ t.throws(
+ function () {
+ rq = objStore.put(record, { value: 1 });
+ },
+ {
+ name: "DataError",
+ },
+ );
+
+ t.deepEqual(rq, undefined);
+ resolve();
+ };
+ });
});
// IDBObjectStore.put() - Put a record where a value being indexed does not meet the constraints of a valid key
-test.cb("WPT idbobjectstore_put14.htm", (t) => {
- var db: any,
- record = { key: 1, indexedProperty: { property: "data" } };
+test("WPT idbobjectstore_put14.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any,
+ record = { key: 1, indexedProperty: { property: "data" } };
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (e: any) {
- db = e.target.result;
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
- var rq,
- objStore = db.createObjectStore("store", { keyPath: "key" });
+ var rq,
+ objStore = db.createObjectStore("store", { keyPath: "key" });
- objStore.createIndex("index", "indexedProperty");
+ objStore.createIndex("index", "indexedProperty");
- rq = objStore.put(record);
+ rq = objStore.put(record);
- t.true(rq instanceof BridgeIDBRequest);
- rq.onsuccess = function () {
- t.end();
+ t.true(rq instanceof BridgeIDBRequest);
+ rq.onsuccess = function () {
+ resolve();
+ };
};
- };
+ });
});
// IDBObjectStore.put() - If the transaction this IDBObjectStore belongs to has its mode set to readonly, throw ReadOnlyError
-test.cb("WPT idbobjectstore_put15.htm", (t) => {
- var db: any;
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (event: any) {
- db = event.target.result;
- db.createObjectStore("store", { keyPath: "pKey" });
- };
-
- open_rq.onsuccess = function (event: any) {
- var txn = db.transaction("store");
- var ostore = txn.objectStore("store");
- t.throws(
- function () {
- ostore.put({ pKey: "primaryKey_0" });
- },
- {
- name: "ReadOnlyError",
- },
- );
- t.end();
- };
+test("WPT idbobjectstore_put15.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any;
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (event: any) {
+ db = event.target.result;
+ db.createObjectStore("store", { keyPath: "pKey" });
+ };
+
+ open_rq.onsuccess = function (event: any) {
+ var txn = db.transaction("store");
+ var ostore = txn.objectStore("store");
+ t.throws(
+ function () {
+ ostore.put({ pKey: "primaryKey_0" });
+ },
+ {
+ name: "ReadOnlyError",
+ },
+ );
+ resolve();
+ };
+ });
});
// IDBObjectStore.put() - If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError
-test.cb("WPT idbobjectstore_put16.htm", (t) => {
- var db: any, ostore: any;
-
- var open_rq = createdb(t);
- open_rq.onupgradeneeded = function (event: any) {
- db = event.target.result;
- ostore = db.createObjectStore("store", { keyPath: "pKey" });
- db.deleteObjectStore("store");
- t.throws(
- function () {
- ostore.put({ pKey: "primaryKey_0" });
- },
- {
- name: "InvalidStateError",
- },
- );
- t.end();
- };
+test("WPT idbobjectstore_put16.htm", (t) => {
+ return new Promise((resolve, reject) => {
+ var db: any, ostore: any;
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (event: any) {
+ db = event.target.result;
+ ostore = db.createObjectStore("store", { keyPath: "pKey" });
+ db.deleteObjectStore("store");
+ t.throws(
+ function () {
+ ostore.put({ pKey: "primaryKey_0" });
+ },
+ {
+ name: "InvalidStateError",
+ },
+ );
+ resolve();
+ };
+ });
});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-rename-store.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-rename-store.test.ts
index b60e932b9..a8aab828a 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-rename-store.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-rename-store.test.ts
@@ -7,7 +7,7 @@ import {
createDatabase,
createNotBooksStore,
migrateDatabase,
-} from "./wptsupport";
+} from "./wptsupport.js";
// IndexedDB: object store renaming support
// IndexedDB object store rename in new transaction
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbtransaction-oncomplete.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbtransaction-oncomplete.test.ts
index 8f54fb7cb..a501ff2c9 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbtransaction-oncomplete.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbtransaction-oncomplete.test.ts
@@ -1,5 +1,5 @@
import test from "ava";
-import { createdb } from "./wptsupport";
+import { createdb } from "./wptsupport.js";
// IDBTransaction - complete event
test("WPT idbtransaction-oncomplete.htm", async (t) => {
diff --git a/packages/idb-bridge/src/idb-wpt-ported/keypath.test.ts b/packages/idb-bridge/src/idb-wpt-ported/keypath.test.ts
index 20ec6f3fa..7ef1301f7 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/keypath.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/keypath.test.ts
@@ -1,5 +1,5 @@
import test from "ava";
-import { assert_key_equals, createdb } from "./wptsupport";
+import { assert_key_equals, createdb } from "./wptsupport.js";
test("WPT test keypath.htm", async (t) => {
function keypath(
diff --git a/packages/idb-bridge/src/idb-wpt-ported/request-bubble-and-capture.test.ts b/packages/idb-bridge/src/idb-wpt-ported/request-bubble-and-capture.test.ts
index a7541a683..526c06784 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/request-bubble-and-capture.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/request-bubble-and-capture.test.ts
@@ -1,7 +1,6 @@
import test from "ava";
-import { BridgeIDBRequest } from "..";
-import { EventTarget, IDBDatabase } from "../idbtypes";
-import { createdb } from "./wptsupport";
+import { EventTarget } from "../idbtypes.js";
+import { createdb } from "./wptsupport.js";
// Bubbling and capturing of request events
test("WPT request_bubble-and-capture.htm", async (t) => {
diff --git a/packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.test.ts b/packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.test.ts
index 707bb5255..9d76e79f2 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.test.ts
@@ -1,5 +1,5 @@
import test from "ava";
-import { createdb } from "./wptsupport";
+import { createdb } from "./wptsupport.js";
// Transactions have a request queue
test("transaction-requestqueue.htm", async (t) => {
@@ -72,7 +72,7 @@ test("transaction-requestqueue.htm", async (t) => {
"os2: 1",
"os2: 1",
"os1: 2",
- ],
+ ] as any,
"transaction keys",
);
@@ -93,7 +93,7 @@ test("transaction-requestqueue.htm", async (t) => {
"os3: 1",
"os1: 2",
"os4: 5",
- ],
+ ] as any,
"transaction 2 keys",
);
diff --git a/packages/idb-bridge/src/idb-wpt-ported/value.test.ts b/packages/idb-bridge/src/idb-wpt-ported/value.test.ts
index acae2fe63..a80ec2b5a 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/value.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/value.test.ts
@@ -1,47 +1,51 @@
import test from "ava";
-import { IDBVersionChangeEvent } from "../idbtypes";
-import { createdb } from "./wptsupport";
+import { IDBVersionChangeEvent } from "../idbtypes.js";
+import { createdb } from "./wptsupport.js";
-test.cb("WPT test value.htm, array", (t) => {
- const value = new Array();
- const _instanceof = Array;
+test("WPT test value.htm, array", (t) => {
+ return new Promise((resolve, reject) => {
+ const value = new Array();
+ const _instanceof = Array;
- t.plan(1);
+ t.plan(1);
- createdb(t).onupgradeneeded = function (e: IDBVersionChangeEvent) {
- (e.target as any).result.createObjectStore("store").add(value, 1);
- (e.target as any).onsuccess = (e: any) => {
- console.log("in first onsuccess");
- e.target.result
- .transaction("store")
- .objectStore("store")
- .get(1).onsuccess = (e: any) => {
- t.assert(e.target.result instanceof _instanceof, "instanceof");
- t.end();
+ createdb(t).onupgradeneeded = function (e: IDBVersionChangeEvent) {
+ (e.target as any).result.createObjectStore("store").add(value, 1);
+ (e.target as any).onsuccess = (e: any) => {
+ console.log("in first onsuccess");
+ e.target.result
+ .transaction("store")
+ .objectStore("store")
+ .get(1).onsuccess = (e: any) => {
+ t.assert(e.target.result instanceof _instanceof, "instanceof");
+ resolve();
+ };
};
};
- };
+ });
});
-test.cb("WPT test value.htm, date", (t) => {
- const value = new Date();
- const _instanceof = Date;
+test("WPT test value.htm, date", (t) => {
+ return new Promise((resolve, reject) => {
+ const value = new Date();
+ const _instanceof = Date;
- t.plan(1);
+ t.plan(1);
- createdb(t).onupgradeneeded = function (e: IDBVersionChangeEvent) {
- (e.target as any).result.createObjectStore("store").add(value, 1);
- (e.target as any).onsuccess = (e: any) => {
- console.log("in first onsuccess");
- e.target.result
- .transaction("store")
- .objectStore("store")
- .get(1).onsuccess = (e: any) => {
- console.log("target", e.target);
- console.log("result", e.target.result);
- t.assert(e.target.result instanceof _instanceof, "instanceof");
- t.end();
+ createdb(t).onupgradeneeded = function (e: IDBVersionChangeEvent) {
+ (e.target as any).result.createObjectStore("store").add(value, 1);
+ (e.target as any).onsuccess = (e: any) => {
+ console.log("in first onsuccess");
+ e.target.result
+ .transaction("store")
+ .objectStore("store")
+ .get(1).onsuccess = (e: any) => {
+ console.log("target", e.target);
+ console.log("result", e.target.result);
+ t.assert(e.target.result instanceof _instanceof, "instanceof");
+ resolve();
+ };
};
};
- };
+ });
});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/wptsupport.ts b/packages/idb-bridge/src/idb-wpt-ported/wptsupport.ts
index 38b44bbec..7f68a53e8 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/wptsupport.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/wptsupport.ts
@@ -1,5 +1,5 @@
-import test, { ExecutionContext } from "ava";
-import { BridgeIDBFactory, BridgeIDBRequest } from "..";
+import { ExecutionContext } from "ava";
+import { BridgeIDBFactory, BridgeIDBRequest } from "../bridge-idb.js";
import {
IDBDatabase,
IDBIndex,
@@ -7,10 +7,9 @@ import {
IDBOpenDBRequest,
IDBRequest,
IDBTransaction,
- IDBTransactionMode,
-} from "../idbtypes";
-import { MemoryBackend } from "../MemoryBackend";
-import { compareKeys } from "../util/cmp";
+} from "../idbtypes.js";
+import { MemoryBackend } from "../MemoryBackend.js";
+import { compareKeys } from "../util/cmp.js";
BridgeIDBFactory.enableTracing = true;
const backend = new MemoryBackend();
diff --git a/packages/idb-bridge/src/util/FakeEvent.ts b/packages/idb-bridge/src/util/FakeEvent.ts
index c16a58fd3..e3ba864ed 100644
--- a/packages/idb-bridge/src/util/FakeEvent.ts
+++ b/packages/idb-bridge/src/util/FakeEvent.ts
@@ -14,8 +14,8 @@
permissions and limitations under the License.
*/
-import FakeEventTarget from "./FakeEventTarget";
-import { Event, EventTarget } from "../idbtypes";
+import FakeEventTarget from "./FakeEventTarget.js";
+import { Event, EventTarget } from "../idbtypes.js";
/** @public */
export type EventType =
diff --git a/packages/idb-bridge/src/util/FakeEventTarget.ts b/packages/idb-bridge/src/util/FakeEventTarget.ts
index 95489b4ac..7ff220711 100644
--- a/packages/idb-bridge/src/util/FakeEventTarget.ts
+++ b/packages/idb-bridge/src/util/FakeEventTarget.ts
@@ -14,8 +14,8 @@
permissions and limitations under the License.
*/
-import { InvalidStateError } from "./errors";
-import FakeEvent, { EventType } from "./FakeEvent";
+import { InvalidStateError } from "./errors.js";
+import FakeEvent, { EventType } from "./FakeEvent.js";
import {
EventTarget,
Event,
diff --git a/packages/idb-bridge/src/util/canInjectKey.test.ts b/packages/idb-bridge/src/util/canInjectKey.test.ts
index b57dd1c9a..c73552ea6 100644
--- a/packages/idb-bridge/src/util/canInjectKey.test.ts
+++ b/packages/idb-bridge/src/util/canInjectKey.test.ts
@@ -16,7 +16,7 @@
*/
import test from "ava";
-import { canInjectKey } from "./canInjectKey";
+import { canInjectKey } from "./canInjectKey.js";
test("canInjectKey", (t) => {
t.false(canInjectKey("foo", null));
diff --git a/packages/idb-bridge/src/util/canInjectKey.ts b/packages/idb-bridge/src/util/canInjectKey.ts
index 903a9d3de..e2927b70f 100644
--- a/packages/idb-bridge/src/util/canInjectKey.ts
+++ b/packages/idb-bridge/src/util/canInjectKey.ts
@@ -15,7 +15,7 @@
permissions and limitations under the License.
*/
-import { IDBKeyPath } from "../idbtypes";
+import { IDBKeyPath } from "../idbtypes.js";
/**
* Check that a key could be injected into a value.
diff --git a/packages/idb-bridge/src/util/cmp.ts b/packages/idb-bridge/src/util/cmp.ts
index e7f26bf1a..19e1d01b4 100644
--- a/packages/idb-bridge/src/util/cmp.ts
+++ b/packages/idb-bridge/src/util/cmp.ts
@@ -14,8 +14,8 @@
permissions and limitations under the License.
*/
-import { DataError } from "./errors";
-import { valueToKey } from "./valueToKey";
+import { DataError } from "./errors.js";
+import { valueToKey } from "./valueToKey.js";
const getType = (x: any) => {
if (typeof x === "number") {
diff --git a/packages/idb-bridge/src/util/extractKey.ts b/packages/idb-bridge/src/util/extractKey.ts
index 09306ddec..b768ed92a 100644
--- a/packages/idb-bridge/src/util/extractKey.ts
+++ b/packages/idb-bridge/src/util/extractKey.ts
@@ -15,8 +15,8 @@
permissions and limitations under the License.
*/
-import { IDBKeyPath, IDBValidKey } from "../idbtypes";
-import { valueToKey } from "./valueToKey";
+import { IDBKeyPath, IDBValidKey } from "../idbtypes.js";
+import { valueToKey } from "./valueToKey.js";
// http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#dfn-steps-for-extracting-a-key-from-a-value-using-a-key-path
export const extractKey = (keyPath: IDBKeyPath | IDBKeyPath[], value: any) => {
diff --git a/packages/idb-bridge/src/util/fakeDOMStringList.ts b/packages/idb-bridge/src/util/fakeDOMStringList.ts
index 0549e1283..92785f9e1 100644
--- a/packages/idb-bridge/src/util/fakeDOMStringList.ts
+++ b/packages/idb-bridge/src/util/fakeDOMStringList.ts
@@ -14,7 +14,6 @@
* permissions and limitations under the License.
*/
-import { DOMStringList } from "../idbtypes";
/** @public */
export interface FakeDOMStringList extends Array<string> {
diff --git a/packages/idb-bridge/src/util/getIndexKeys.test.ts b/packages/idb-bridge/src/util/getIndexKeys.test.ts
index 782b3da2f..d3bbd519a 100644
--- a/packages/idb-bridge/src/util/getIndexKeys.test.ts
+++ b/packages/idb-bridge/src/util/getIndexKeys.test.ts
@@ -16,7 +16,7 @@
*/
import test from "ava";
-import { getIndexKeys } from "./getIndexKeys";
+import { getIndexKeys } from "./getIndexKeys.js";
test("basics", (t) => {
t.deepEqual(getIndexKeys({ foo: 42 }, "foo", false), [42]);
@@ -31,10 +31,10 @@ test("basics", (t) => {
});
t.deepEqual(getIndexKeys({ foo: 42 }, "foo", true), [42]);
- t.deepEqual(getIndexKeys({ foo: 42, bar: 10 }, ["foo", "bar"], true), [
- 42,
- 10,
- ]);
+ t.deepEqual(
+ getIndexKeys({ foo: 42, bar: 10 }, ["foo", "bar"], true),
+ [42, 10],
+ );
t.deepEqual(getIndexKeys({ foo: 42, bar: 10 }, ["foo", "bar"], false), [
[42, 10],
]);
diff --git a/packages/idb-bridge/src/util/getIndexKeys.ts b/packages/idb-bridge/src/util/getIndexKeys.ts
index 8515d79ea..17e77e636 100644
--- a/packages/idb-bridge/src/util/getIndexKeys.ts
+++ b/packages/idb-bridge/src/util/getIndexKeys.ts
@@ -15,9 +15,9 @@
permissions and limitations under the License.
*/
-import { IDBKeyPath, IDBValidKey } from "../idbtypes";
-import { extractKey } from "./extractKey";
-import { valueToKey } from "./valueToKey";
+import { IDBKeyPath, IDBValidKey } from "../idbtypes.js";
+import { extractKey } from "./extractKey.js";
+import { valueToKey } from "./valueToKey.js";
export function getIndexKeys(
value: any,
diff --git a/packages/idb-bridge/src/util/makeStoreKeyValue.test.ts b/packages/idb-bridge/src/util/makeStoreKeyValue.test.ts
index df9748316..971697021 100644
--- a/packages/idb-bridge/src/util/makeStoreKeyValue.test.ts
+++ b/packages/idb-bridge/src/util/makeStoreKeyValue.test.ts
@@ -15,7 +15,7 @@
*/
import test from "ava";
-import { makeStoreKeyValue } from "./makeStoreKeyValue";
+import { makeStoreKeyValue } from "./makeStoreKeyValue.js";
test("basics", (t) => {
let result;
diff --git a/packages/idb-bridge/src/util/makeStoreKeyValue.ts b/packages/idb-bridge/src/util/makeStoreKeyValue.ts
index c0fdb19a7..4c7dab8d2 100644
--- a/packages/idb-bridge/src/util/makeStoreKeyValue.ts
+++ b/packages/idb-bridge/src/util/makeStoreKeyValue.ts
@@ -14,11 +14,11 @@
permissions and limitations under the License.
*/
-import { extractKey } from "./extractKey";
-import { DataCloneError, DataError } from "./errors";
-import { valueToKey } from "./valueToKey";
-import { structuredClone } from "./structuredClone";
-import { IDBKeyPath, IDBValidKey } from "../idbtypes";
+import { extractKey } from "./extractKey.js";
+import { DataCloneError, DataError } from "./errors.js";
+import { valueToKey } from "./valueToKey.js";
+import { structuredClone } from "./structuredClone.js";
+import { IDBKeyPath, IDBValidKey } from "../idbtypes.js";
export interface StoreKeyResult {
updatedKeyGenerator: number;
diff --git a/packages/idb-bridge/src/util/structuredClone.test.ts b/packages/idb-bridge/src/util/structuredClone.test.ts
index a14260daa..0c613e6cc 100644
--- a/packages/idb-bridge/src/util/structuredClone.test.ts
+++ b/packages/idb-bridge/src/util/structuredClone.test.ts
@@ -15,7 +15,7 @@
*/
import test, { ExecutionContext } from "ava";
-import { structuredClone } from "./structuredClone";
+import { structuredClone } from "./structuredClone.js";
function checkClone(t: ExecutionContext, x: any): void {
t.deepEqual(structuredClone(x), x);
diff --git a/packages/idb-bridge/src/util/validateKeyPath.ts b/packages/idb-bridge/src/util/validateKeyPath.ts
index 8c29c1d57..1c614fcca 100644
--- a/packages/idb-bridge/src/util/validateKeyPath.ts
+++ b/packages/idb-bridge/src/util/validateKeyPath.ts
@@ -14,7 +14,7 @@
permissions and limitations under the License.
*/
-import { IDBKeyPath } from "../idbtypes";
+import { IDBKeyPath } from "../idbtypes.js";
// http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#dfn-valid-key-path
export const validateKeyPath = (
diff --git a/packages/idb-bridge/src/util/valueToKey.ts b/packages/idb-bridge/src/util/valueToKey.ts
index c65604df1..6df82af81 100644
--- a/packages/idb-bridge/src/util/valueToKey.ts
+++ b/packages/idb-bridge/src/util/valueToKey.ts
@@ -14,8 +14,8 @@
permissions and limitations under the License.
*/
-import { IDBValidKey } from "..";
-import { DataError } from "./errors";
+import { IDBValidKey } from "../idbtypes.js";
+import { DataError } from "./errors.js";
// https://www.w3.org/TR/IndexedDB-2/#convert-a-value-to-a-key
export function valueToKey(