idb-bridge: update tests for ava 4.x
This commit is contained in:
parent
1de423834d
commit
5ff3b44550
@ -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"
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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) => {
|
||||
|
@ -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;
|
||||
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);
|
||||
open_rq.onupgradeneeded = function (e: any) {
|
||||
db = e.target.result;
|
||||
t.deepEqual(db.version, 1);
|
||||
|
||||
db.createObjectStore("os");
|
||||
db.close();
|
||||
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");
|
||||
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.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.true(!!db);
|
||||
t.deepEqual(db.version, 1);
|
||||
t.deepEqual(db.objectStoreNames.length, 1);
|
||||
t.throws(
|
||||
() => {
|
||||
db.transaction("os");
|
||||
},
|
||||
{
|
||||
name: "InvalidStateError",
|
||||
},
|
||||
);
|
||||
|
||||
t.end();
|
||||
};
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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) => {
|
||||
|
@ -1,385 +1,401 @@
|
||||
import test from "ava";
|
||||
import { BridgeIDBCursor } from "..";
|
||||
import { BridgeIDBCursorWithValue } from "../bridge-idb";
|
||||
import { createdb } from "./wptsupport";
|
||||
import { BridgeIDBCursor, BridgeIDBCursorWithValue } from "../bridge-idb.js";
|
||||
import { createdb } from "./wptsupport.js";
|
||||
|
||||
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" },
|
||||
];
|
||||
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 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");
|
||||
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;
|
||||
}
|
||||
|
||||
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++;
|
||||
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");
|
||||
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 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" },
|
||||
];
|
||||
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" },
|
||||
];
|
||||
|
||||
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" });
|
||||
|
||||
objStore.createIndex("index", "iKey");
|
||||
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();
|
||||
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");
|
||||
|
||||
resolve();
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// 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" },
|
||||
];
|
||||
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" },
|
||||
];
|
||||
|
||||
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" });
|
||||
|
||||
objStore.createIndex("index", "iKey");
|
||||
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;
|
||||
}
|
||||
|
||||
// First time checks key equal, second time checks key less than
|
||||
t.throws(
|
||||
() => {
|
||||
cursor.continue(records[0].iKey);
|
||||
},
|
||||
{ name: "DataError" },
|
||||
);
|
||||
|
||||
cursor.continue();
|
||||
|
||||
count++;
|
||||
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");
|
||||
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++;
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// 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" },
|
||||
];
|
||||
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" });
|
||||
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");
|
||||
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, "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);
|
||||
}
|
||||
|
||||
count++;
|
||||
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, "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 - 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" },
|
||||
];
|
||||
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 (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" });
|
||||
|
||||
objStore.createIndex("index", "iKey");
|
||||
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");
|
||||
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);
|
||||
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 - 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" },
|
||||
];
|
||||
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 (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" });
|
||||
|
||||
objStore.createIndex("index", "iKey");
|
||||
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");
|
||||
t.end();
|
||||
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);
|
||||
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.cb("WPT idbcursor-continue-index7.htm", (t) => {
|
||||
var db: any,
|
||||
records = [
|
||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||
{ pKey: "primaryKey_1", iKey: "indexKey_1" },
|
||||
];
|
||||
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);
|
||||
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();
|
||||
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.cb("WPT idbcursor-continue-index8.htm", (t) => {
|
||||
var db: any,
|
||||
records = [
|
||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||
{ pKey: "primaryKey_1", iKey: "indexKey_1" },
|
||||
];
|
||||
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);
|
||||
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");
|
||||
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.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();
|
||||
resolve();
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@ -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" }];
|
||||
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",
|
||||
});
|
||||
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++;
|
||||
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]);
|
||||
};
|
||||
|
||||
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");
|
||||
t.throws(
|
||||
() => {
|
||||
cursor.continue({ foo: "42" });
|
||||
},
|
||||
{ name: "DataError" },
|
||||
);
|
||||
|
||||
t.end();
|
||||
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");
|
||||
t.throws(
|
||||
() => {
|
||||
cursor.continue({ foo: "42" });
|
||||
},
|
||||
{ name: "DataError" },
|
||||
);
|
||||
|
||||
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" }];
|
||||
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" });
|
||||
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();
|
||||
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" },
|
||||
];
|
||||
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" });
|
||||
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++;
|
||||
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" }];
|
||||
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" });
|
||||
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();
|
||||
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" }];
|
||||
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" });
|
||||
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]);
|
||||
|
||||
var cursor_rq = objStore.openCursor();
|
||||
var cursor_rq = objStore.openCursor();
|
||||
|
||||
cursor_rq.onsuccess = function (e: any) {
|
||||
var cursor = e.target.result;
|
||||
t.true(cursor instanceof BridgeIDBCursor, "cursor exists");
|
||||
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",
|
||||
);
|
||||
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();
|
||||
resolve();
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@ -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'
|
||||
|
@ -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" },
|
||||
];
|
||||
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 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]);
|
||||
};
|
||||
|
||||
open_rq.onsuccess = CursorDeleteRecord;
|
||||
|
||||
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;
|
||||
|
||||
t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
|
||||
cursor.delete();
|
||||
for (var i = 0; i < records.length; i++) objStore.add(records[i]);
|
||||
};
|
||||
|
||||
txn.oncomplete = VerifyRecordWasDeleted;
|
||||
}
|
||||
open_rq.onsuccess = CursorDeleteRecord;
|
||||
|
||||
function VerifyRecordWasDeleted(e: any) {
|
||||
var cursor_rq = db.transaction("test").objectStore("test").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;
|
||||
|
||||
if (!cursor) {
|
||||
t.deepEqual(count, 1, "count");
|
||||
t.end();
|
||||
return;
|
||||
}
|
||||
t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
|
||||
cursor.delete();
|
||||
};
|
||||
|
||||
t.deepEqual(cursor.value.pKey, records[1].pKey);
|
||||
t.deepEqual(cursor.value.iKey, records[1].iKey);
|
||||
cursor.continue();
|
||||
count++;
|
||||
};
|
||||
}
|
||||
txn.oncomplete = VerifyRecordWasDeleted;
|
||||
}
|
||||
|
||||
function VerifyRecordWasDeleted(e: any) {
|
||||
var cursor_rq = db.transaction("test").objectStore("test").openCursor();
|
||||
|
||||
cursor_rq.onsuccess = function (e: any) {
|
||||
var cursor = e.target.result;
|
||||
|
||||
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++;
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 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" },
|
||||
];
|
||||
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" },
|
||||
];
|
||||
|
||||
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]);
|
||||
};
|
||||
|
||||
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();
|
||||
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",
|
||||
},
|
||||
);
|
||||
resolve();
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// 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" },
|
||||
];
|
||||
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");
|
||||
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]);
|
||||
for (var i = 0; i < records.length; i++) objStore.add(records[i]);
|
||||
|
||||
var cursor_rq = index.openCursor();
|
||||
var cursor_rq = index.openCursor();
|
||||
|
||||
let myCursor: IDBCursor | undefined;
|
||||
let myCursor: IDBCursor | undefined;
|
||||
|
||||
cursor_rq.onsuccess = function (e: any) {
|
||||
var cursor = e.target.result;
|
||||
t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
|
||||
myCursor = cursor;
|
||||
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();
|
||||
};
|
||||
};
|
||||
|
||||
e.target.transaction.oncomplete = function (e: any) {
|
||||
t.throws(
|
||||
() => {
|
||||
myCursor!.delete();
|
||||
},
|
||||
{ name: "TransactionInactiveError" },
|
||||
);
|
||||
t.end();
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// 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" },
|
||||
];
|
||||
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");
|
||||
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",
|
||||
);
|
||||
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();
|
||||
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" },
|
||||
];
|
||||
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]);
|
||||
}
|
||||
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");
|
||||
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" },
|
||||
);
|
||||
cursor.continue();
|
||||
t.throws(
|
||||
function () {
|
||||
cursor.delete();
|
||||
},
|
||||
{ name: "InvalidStateError" },
|
||||
);
|
||||
|
||||
t.end();
|
||||
resolve();
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@ -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]);
|
||||
};
|
||||
|
||||
open_rq.onsuccess = CursorDeleteRecord;
|
||||
|
||||
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;
|
||||
|
||||
t.true(cursor != null, "cursor exist");
|
||||
cursor.delete();
|
||||
for (var i = 0; i < records.length; i++) objStore.add(records[i]);
|
||||
};
|
||||
|
||||
txn.oncomplete = VerifyRecordWasDeleted;
|
||||
}
|
||||
open_rq.onsuccess = CursorDeleteRecord;
|
||||
|
||||
function VerifyRecordWasDeleted(e: any) {
|
||||
var cursor_rq = db.transaction("test").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;
|
||||
|
||||
if (!cursor) {
|
||||
t.deepEqual(count, 1, "count");
|
||||
t.end();
|
||||
}
|
||||
t.true(cursor != null, "cursor exist");
|
||||
cursor.delete();
|
||||
};
|
||||
|
||||
t.deepEqual(cursor.value.pKey, records[1].pKey);
|
||||
count++;
|
||||
cursor.continue();
|
||||
};
|
||||
}
|
||||
txn.oncomplete = VerifyRecordWasDeleted;
|
||||
}
|
||||
|
||||
function VerifyRecordWasDeleted(e: any) {
|
||||
var cursor_rq = db.transaction("test").objectStore("test").openCursor();
|
||||
|
||||
cursor_rq.onsuccess = function (e: any) {
|
||||
var cursor = e.target.result;
|
||||
|
||||
if (!cursor) {
|
||||
t.deepEqual(count, 1, "count");
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
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" },
|
||||
];
|
||||
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 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]);
|
||||
};
|
||||
|
||||
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();
|
||||
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" },
|
||||
);
|
||||
resolve();
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// 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-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" });
|
||||
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]);
|
||||
|
||||
var cursor_rq = objStore.openCursor();
|
||||
var cursor_rq = objStore.openCursor();
|
||||
|
||||
const window: any = {};
|
||||
const window: any = {};
|
||||
|
||||
cursor_rq.onsuccess = function (e: any) {
|
||||
var cursor = e.target.result;
|
||||
t.true(cursor instanceof BridgeIDBCursor, "cursor exist");
|
||||
window.cursor = cursor;
|
||||
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();
|
||||
};
|
||||
};
|
||||
|
||||
e.target.transaction.oncomplete = function (e: any) {
|
||||
t.throws(
|
||||
function () {
|
||||
window.cursor.delete();
|
||||
},
|
||||
{
|
||||
name: "TransactionInactiveError",
|
||||
},
|
||||
);
|
||||
t.end();
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// 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" }];
|
||||
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");
|
||||
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",
|
||||
);
|
||||
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();
|
||||
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" }];
|
||||
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",
|
||||
},
|
||||
);
|
||||
|
||||
t.end();
|
||||
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();
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@ -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) => {
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
cursor.value.iKey += "_updated";
|
||||
cursor.update(cursor.value);
|
||||
// XXX: Gecko doesn't like this
|
||||
//e.target.transaction.oncomplete = t.step_func(CursorUpdateRecord);
|
||||
};
|
||||
|
||||
txn.oncomplete = VerifyRecordWasUpdated;
|
||||
}
|
||||
open_rq.onsuccess = CursorUpdateRecord;
|
||||
|
||||
function VerifyRecordWasUpdated(e: any) {
|
||||
var cursor_rq = db.transaction("test").objectStore("test").openCursor();
|
||||
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_rq.onsuccess = function (e: any) {
|
||||
var cursor = e.target.result;
|
||||
cursor.value.iKey += "_updated";
|
||||
cursor.update(cursor.value);
|
||||
};
|
||||
|
||||
t.deepEqual(cursor.value.iKey, records[0].iKey + "_updated");
|
||||
t.end();
|
||||
};
|
||||
}
|
||||
txn.oncomplete = VerifyRecordWasUpdated;
|
||||
}
|
||||
|
||||
function VerifyRecordWasUpdated(e: any) {
|
||||
var cursor_rq = db.transaction("test").objectStore("test").openCursor();
|
||||
|
||||
cursor_rq.onsuccess = function (e: any) {
|
||||
var cursor = e.target.result;
|
||||
|
||||
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" },
|
||||
];
|
||||
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 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]);
|
||||
};
|
||||
|
||||
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();
|
||||
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" },
|
||||
);
|
||||
resolve();
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
//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" },
|
||||
];
|
||||
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");
|
||||
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]);
|
||||
for (var i = 0; i < records.length; i++) objStore.add(records[i]);
|
||||
|
||||
var cursor_rq = index.openCursor();
|
||||
var cursor_rq = index.openCursor();
|
||||
|
||||
const window: any = {};
|
||||
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;
|
||||
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();
|
||||
};
|
||||
};
|
||||
|
||||
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 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" },
|
||||
];
|
||||
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);
|
||||
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",
|
||||
);
|
||||
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();
|
||||
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" },
|
||||
];
|
||||
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 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]);
|
||||
};
|
||||
|
||||
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();
|
||||
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" },
|
||||
];
|
||||
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 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]);
|
||||
};
|
||||
|
||||
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();
|
||||
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" },
|
||||
];
|
||||
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 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]);
|
||||
};
|
||||
|
||||
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();
|
||||
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" },
|
||||
];
|
||||
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 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");
|
||||
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");
|
||||
|
||||
cursor.continue();
|
||||
t.throws(
|
||||
function () {
|
||||
cursor.update({ pKey: "primaryKey_0", iKey: "indexKey_0_updated" });
|
||||
},
|
||||
{
|
||||
name: "InvalidStateError",
|
||||
},
|
||||
);
|
||||
|
||||
t.end();
|
||||
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");
|
||||
|
||||
cursor.continue();
|
||||
t.throws(
|
||||
function () {
|
||||
cursor.update({ pKey: "primaryKey_0", iKey: "indexKey_0_updated" });
|
||||
},
|
||||
{
|
||||
name: "InvalidStateError",
|
||||
},
|
||||
);
|
||||
|
||||
resolve();
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// Index cursor - indexed values updated during iteration
|
||||
|
@ -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;
|
||||
|
@ -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) => {
|
||||
|
@ -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) => {
|
||||
|
@ -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();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@ -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(
|
||||
|
@ -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) => {
|
||||
|
@ -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" };
|
||||
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);
|
||||
t.end();
|
||||
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" };
|
||||
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);
|
||||
t.end();
|
||||
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" };
|
||||
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);
|
||||
t.end();
|
||||
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;
|
||||
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 () {
|
||||
t.end();
|
||||
}, 10);
|
||||
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);
|
||||
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");
|
||||
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();
|
||||
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;
|
||||
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" });
|
||||
};
|
||||
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();
|
||||
};
|
||||
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;
|
||||
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" });
|
||||
};
|
||||
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();
|
||||
};
|
||||
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();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
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();
|
||||
objStore.put(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.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" };
|
||||
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");
|
||||
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);
|
||||
|
||||
rq.onsuccess = function (e: any) {
|
||||
t.deepEqual(e.target.result.property, record.property);
|
||||
|
||||
t.end();
|
||||
objStore.put(record, 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);
|
||||
|
||||
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] };
|
||||
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 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");
|
||||
var rq = objStore.put(record_put);
|
||||
rq.onerror = () => t.fail("error on put");
|
||||
|
||||
rq.onsuccess = function (e: any) {
|
||||
success_event = true;
|
||||
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 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");
|
||||
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");
|
||||
rq.onerror = function (e: any) {
|
||||
t.deepEqual(rq.error.name, "ConstraintError");
|
||||
t.deepEqual(e.target.error.name, "ConstraintError");
|
||||
|
||||
t.deepEqual(e.type, "error");
|
||||
t.deepEqual(e.type, "error");
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Defer done, giving a spurious rq.onsuccess a chance to run
|
||||
open_rq.onsuccess = function (e: any) {
|
||||
t.end();
|
||||
};
|
||||
// Defer done, giving a spurious rq.onsuccess a chance to run
|
||||
open_rq.onsuccess = function (e: any) {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// 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" };
|
||||
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);
|
||||
};
|
||||
|
||||
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();
|
||||
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);
|
||||
|
||||
resolve();
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// 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];
|
||||
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,
|
||||
});
|
||||
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();
|
||||
}
|
||||
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);
|
||||
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];
|
||||
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 });
|
||||
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();
|
||||
}
|
||||
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];
|
||||
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,
|
||||
});
|
||||
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();
|
||||
}
|
||||
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" };
|
||||
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" });
|
||||
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.throws(
|
||||
function () {
|
||||
rq = objStore.put(record, 1);
|
||||
},
|
||||
{ name: "DataError" },
|
||||
);
|
||||
|
||||
t.deepEqual(rq, undefined);
|
||||
t.end();
|
||||
};
|
||||
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" };
|
||||
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 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" });
|
||||
|
||||
t.throws(
|
||||
function () {
|
||||
rq = objStore.put(record);
|
||||
},
|
||||
{ name: "DataError" },
|
||||
);
|
||||
t.throws(
|
||||
function () {
|
||||
rq = objStore.put(record);
|
||||
},
|
||||
{ name: "DataError" },
|
||||
);
|
||||
|
||||
t.deepEqual(rq, undefined);
|
||||
t.end();
|
||||
};
|
||||
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" };
|
||||
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 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" });
|
||||
|
||||
t.throws(
|
||||
function () {
|
||||
rq = objStore.put(record);
|
||||
},
|
||||
{ name: "DataError" },
|
||||
);
|
||||
t.throws(
|
||||
function () {
|
||||
rq = objStore.put(record);
|
||||
},
|
||||
{ name: "DataError" },
|
||||
);
|
||||
|
||||
t.deepEqual(rq, undefined);
|
||||
t.end();
|
||||
};
|
||||
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" };
|
||||
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 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" });
|
||||
|
||||
t.throws(
|
||||
function () {
|
||||
rq = objStore.put(record);
|
||||
},
|
||||
{ name: "DataError" },
|
||||
);
|
||||
t.throws(
|
||||
function () {
|
||||
rq = objStore.put(record);
|
||||
},
|
||||
{ name: "DataError" },
|
||||
);
|
||||
|
||||
t.deepEqual(rq, undefined);
|
||||
t.end();
|
||||
};
|
||||
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" };
|
||||
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 open_rq = createdb(t);
|
||||
open_rq.onupgradeneeded = function (e: any) {
|
||||
db = e.target.result;
|
||||
|
||||
var rq,
|
||||
objStore = db.createObjectStore("store");
|
||||
var rq,
|
||||
objStore = db.createObjectStore("store");
|
||||
|
||||
t.throws(
|
||||
function () {
|
||||
rq = objStore.put(record, { value: 1 });
|
||||
},
|
||||
{
|
||||
name: "DataError",
|
||||
},
|
||||
);
|
||||
t.throws(
|
||||
function () {
|
||||
rq = objStore.put(record, { value: 1 });
|
||||
},
|
||||
{
|
||||
name: "DataError",
|
||||
},
|
||||
);
|
||||
|
||||
t.deepEqual(rq, undefined);
|
||||
t.end();
|
||||
};
|
||||
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;
|
||||
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" });
|
||||
};
|
||||
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();
|
||||
};
|
||||
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;
|
||||
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",
|
||||
},
|
||||
);
|
||||
t.end();
|
||||
};
|
||||
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();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@ -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
|
||||
|
@ -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) => {
|
||||
|
@ -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(
|
||||
|
@ -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) => {
|
||||
|
@ -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",
|
||||
);
|
||||
|
||||
|
@ -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();
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@ -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();
|
||||
|
@ -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 =
|
||||
|
@ -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,
|
||||
|
@ -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));
|
||||
|
@ -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.
|
||||
|
@ -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") {
|
||||
|
@ -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) => {
|
||||
|
@ -14,7 +14,6 @@
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
import { DOMStringList } from "../idbtypes";
|
||||
|
||||
/** @public */
|
||||
export interface FakeDOMStringList extends Array<string> {
|
||||
|
@ -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],
|
||||
]);
|
||||
|
@ -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,
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import test from "ava";
|
||||
import { makeStoreKeyValue } from "./makeStoreKeyValue";
|
||||
import { makeStoreKeyValue } from "./makeStoreKeyValue.js";
|
||||
|
||||
test("basics", (t) => {
|
||||
let result;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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 = (
|
||||
|
@ -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(
|
||||
|
@ -125,27 +125,27 @@ importers:
|
||||
'@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
|
||||
rollup: ^2.67.2
|
||||
tslib: ^2.3.1
|
||||
typescript: ^4.5.4
|
||||
typescript: ^4.5.5
|
||||
dependencies:
|
||||
tslib: 2.3.1
|
||||
devDependencies:
|
||||
'@rollup/plugin-commonjs': 21.0.1_rollup@2.63.0
|
||||
'@rollup/plugin-json': 4.1.0_rollup@2.63.0
|
||||
'@rollup/plugin-node-resolve': 13.1.3_rollup@2.63.0
|
||||
'@types/node': 17.0.8
|
||||
ava: 3.15.0
|
||||
'@rollup/plugin-commonjs': 21.0.1_rollup@2.67.2
|
||||
'@rollup/plugin-json': 4.1.0_rollup@2.67.2
|
||||
'@rollup/plugin-node-resolve': 13.1.3_rollup@2.67.2
|
||||
'@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
|
||||
|
||||
packages/pogen:
|
||||
specifiers:
|
||||
@ -10125,7 +10125,6 @@ packages:
|
||||
|
||||
/@types/node/17.0.17:
|
||||
resolution: {integrity: sha512-e8PUNQy1HgJGV3iU/Bp2+D/DXh3PYeyli8LgIwsQcs1Ar1LoaWHSIT6Rw+H2rNJmiq6SNWiDytfx8+gYj7wDHw==}
|
||||
dev: false
|
||||
|
||||
/@types/node/17.0.8:
|
||||
resolution: {integrity: sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==}
|
||||
@ -10189,7 +10188,7 @@ packages:
|
||||
/@types/resolve/1.17.1:
|
||||
resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==}
|
||||
dependencies:
|
||||
'@types/node': 17.0.8
|
||||
'@types/node': 17.0.17
|
||||
dev: true
|
||||
|
||||
/@types/scheduler/0.16.2:
|
||||
|
Loading…
Reference in New Issue
Block a user