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",
|
"description": "IndexedDB implementation that uses SQLite3 as storage",
|
||||||
"main": "./dist/idb-bridge.js",
|
"main": "./dist/idb-bridge.js",
|
||||||
"module": "./lib/index.js",
|
"module": "./lib/index.js",
|
||||||
|
"type": "module",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
"author": "Florian Dold",
|
"author": "Florian Dold",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
@ -19,13 +20,13 @@
|
|||||||
"@rollup/plugin-commonjs": "^21.0.1",
|
"@rollup/plugin-commonjs": "^21.0.1",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^13.1.3",
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
||||||
"@types/node": "^17.0.8",
|
"@types/node": "^17.0.17",
|
||||||
"ava": "^3.15.0",
|
"ava": "^4.0.1",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.5.1",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rollup": "^2.63.0",
|
"rollup": "^2.67.2",
|
||||||
"typescript": "^4.5.4"
|
"typescript": "^4.5.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^2.3.1"
|
"tslib": "^2.3.1"
|
||||||
|
@ -22,14 +22,14 @@ import {
|
|||||||
BridgeIDBKeyRange,
|
BridgeIDBKeyRange,
|
||||||
BridgeIDBRequest,
|
BridgeIDBRequest,
|
||||||
BridgeIDBTransaction,
|
BridgeIDBTransaction,
|
||||||
} from "./bridge-idb";
|
} from "./bridge-idb.js";
|
||||||
import {
|
import {
|
||||||
IDBCursorDirection,
|
IDBCursorDirection,
|
||||||
IDBCursorWithValue,
|
IDBCursorWithValue,
|
||||||
IDBKeyRange,
|
IDBKeyRange,
|
||||||
IDBValidKey,
|
IDBValidKey,
|
||||||
} from "./idbtypes.js";
|
} from "./idbtypes.js";
|
||||||
import { MemoryBackend } from "./MemoryBackend";
|
import { MemoryBackend } from "./MemoryBackend.js";
|
||||||
|
|
||||||
function promiseFromRequest(request: BridgeIDBRequest): Promise<any> {
|
function promiseFromRequest(request: BridgeIDBRequest): Promise<any> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -150,7 +150,7 @@ test("Spec: Example 1 Part 3", async (t) => {
|
|||||||
|
|
||||||
await promiseFromRequest(request3);
|
await promiseFromRequest(request3);
|
||||||
|
|
||||||
let cursor: BridgeIDBCursorWithValue;
|
let cursor: BridgeIDBCursorWithValue | null;
|
||||||
cursor = request3.result as BridgeIDBCursorWithValue;
|
cursor = request3.result as BridgeIDBCursorWithValue;
|
||||||
t.is(cursor.value.author, "Fred");
|
t.is(cursor.value.author, "Fred");
|
||||||
t.is(cursor.value.isbn, 123456);
|
t.is(cursor.value.isbn, 123456);
|
||||||
@ -172,6 +172,9 @@ test("Spec: Example 1 Part 3", async (t) => {
|
|||||||
await promiseFromRequest(request4);
|
await promiseFromRequest(request4);
|
||||||
|
|
||||||
cursor = request4.result;
|
cursor = request4.result;
|
||||||
|
if (!cursor) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
t.is(cursor.value.isbn, 123456);
|
t.is(cursor.value.isbn, 123456);
|
||||||
|
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
@ -179,6 +182,9 @@ test("Spec: Example 1 Part 3", async (t) => {
|
|||||||
await promiseFromRequest(request4);
|
await promiseFromRequest(request4);
|
||||||
|
|
||||||
cursor = request4.result;
|
cursor = request4.result;
|
||||||
|
if (!cursor) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
t.is(cursor.value.isbn, 234567);
|
t.is(cursor.value.isbn, 234567);
|
||||||
|
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
@ -186,6 +192,9 @@ test("Spec: Example 1 Part 3", async (t) => {
|
|||||||
await promiseFromRequest(request4);
|
await promiseFromRequest(request4);
|
||||||
|
|
||||||
cursor = request4.result;
|
cursor = request4.result;
|
||||||
|
if (!cursor) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
t.is(cursor.value.isbn, 345678);
|
t.is(cursor.value.isbn, 345678);
|
||||||
|
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
@ -203,16 +212,25 @@ test("Spec: Example 1 Part 3", async (t) => {
|
|||||||
|
|
||||||
await promiseFromRequest(request5);
|
await promiseFromRequest(request5);
|
||||||
cursor = request5.result;
|
cursor = request5.result;
|
||||||
|
if (!cursor) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
t.is(cursor.value.author, "Barney");
|
t.is(cursor.value.author, "Barney");
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
|
|
||||||
await promiseFromRequest(request5);
|
await promiseFromRequest(request5);
|
||||||
cursor = request5.result;
|
cursor = request5.result;
|
||||||
|
if (!cursor) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
t.is(cursor.value.author, "Fred");
|
t.is(cursor.value.author, "Fred");
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
|
|
||||||
await promiseFromRequest(request5);
|
await promiseFromRequest(request5);
|
||||||
cursor = request5.result;
|
cursor = request5.result;
|
||||||
|
if (!cursor) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
t.is(cursor.value.author, "Fred");
|
t.is(cursor.value.author, "Fred");
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
|
|
||||||
@ -224,11 +242,17 @@ test("Spec: Example 1 Part 3", async (t) => {
|
|||||||
|
|
||||||
await promiseFromRequest(request6);
|
await promiseFromRequest(request6);
|
||||||
cursor = request6.result;
|
cursor = request6.result;
|
||||||
|
if (!cursor) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
t.is(cursor.value.author, "Barney");
|
t.is(cursor.value.author, "Barney");
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
|
|
||||||
await promiseFromRequest(request6);
|
await promiseFromRequest(request6);
|
||||||
cursor = request6.result;
|
cursor = request6.result;
|
||||||
|
if (!cursor) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
t.is(cursor.value.author, "Fred");
|
t.is(cursor.value.author, "Fred");
|
||||||
t.is(cursor.value.isbn, 123456);
|
t.is(cursor.value.isbn, 123456);
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
@ -240,12 +264,18 @@ test("Spec: Example 1 Part 3", async (t) => {
|
|||||||
const request7 = index5.openCursor(null, "prevunique");
|
const request7 = index5.openCursor(null, "prevunique");
|
||||||
await promiseFromRequest(request7);
|
await promiseFromRequest(request7);
|
||||||
cursor = request7.result;
|
cursor = request7.result;
|
||||||
|
if (!cursor) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
t.is(cursor.value.author, "Fred");
|
t.is(cursor.value.author, "Fred");
|
||||||
t.is(cursor.value.isbn, 123456);
|
t.is(cursor.value.isbn, 123456);
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
|
|
||||||
await promiseFromRequest(request7);
|
await promiseFromRequest(request7);
|
||||||
cursor = request7.result;
|
cursor = request7.result;
|
||||||
|
if (!cursor) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
t.is(cursor.value.author, "Barney");
|
t.is(cursor.value.author, "Barney");
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
|
|
||||||
|
@ -26,20 +26,20 @@ import {
|
|||||||
ResultLevel,
|
ResultLevel,
|
||||||
StoreLevel,
|
StoreLevel,
|
||||||
RecordStoreResponse,
|
RecordStoreResponse,
|
||||||
} from "./backend-interface";
|
} from "./backend-interface.js";
|
||||||
import {
|
import {
|
||||||
structuredClone,
|
structuredClone,
|
||||||
structuredEncapsulate,
|
structuredEncapsulate,
|
||||||
structuredRevive,
|
structuredRevive,
|
||||||
} from "./util/structuredClone";
|
} from "./util/structuredClone.js";
|
||||||
import { ConstraintError, DataError } from "./util/errors";
|
import { ConstraintError, DataError } from "./util/errors.js";
|
||||||
import BTree, { ISortedMapF, ISortedSetF } from "./tree/b+tree";
|
import BTree, { ISortedMapF, ISortedSetF } from "./tree/b+tree.js";
|
||||||
import { compareKeys } from "./util/cmp";
|
import { compareKeys } from "./util/cmp.js";
|
||||||
import { StoreKeyResult, makeStoreKeyValue } from "./util/makeStoreKeyValue";
|
import { StoreKeyResult, makeStoreKeyValue } from "./util/makeStoreKeyValue.js";
|
||||||
import { getIndexKeys } from "./util/getIndexKeys";
|
import { getIndexKeys } from "./util/getIndexKeys.js";
|
||||||
import { openPromise } from "./util/openPromise";
|
import { openPromise } from "./util/openPromise.js";
|
||||||
import { IDBKeyRange, IDBTransactionMode, IDBValidKey } from "./idbtypes";
|
import { IDBKeyRange, IDBTransactionMode, IDBValidKey } from "./idbtypes.js";
|
||||||
import { BridgeIDBKeyRange } from "./bridge-idb";
|
import { BridgeIDBKeyRange } from "./bridge-idb.js";
|
||||||
|
|
||||||
type Key = IDBValidKey;
|
type Key = IDBValidKey;
|
||||||
type Value = unknown;
|
type Value = unknown;
|
||||||
|
@ -14,12 +14,12 @@
|
|||||||
permissions and limitations under the License.
|
permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BridgeIDBDatabaseInfo, BridgeIDBKeyRange } from "./bridge-idb";
|
import { BridgeIDBDatabaseInfo, BridgeIDBKeyRange } from "./bridge-idb.js";
|
||||||
import {
|
import {
|
||||||
IDBCursorDirection,
|
IDBCursorDirection,
|
||||||
IDBTransactionMode,
|
IDBTransactionMode,
|
||||||
IDBValidKey,
|
IDBValidKey,
|
||||||
} from "./idbtypes";
|
} from "./idbtypes.js";
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export interface ObjectStoreProperties {
|
export interface ObjectStoreProperties {
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
ResultLevel,
|
ResultLevel,
|
||||||
Schema,
|
Schema,
|
||||||
StoreLevel,
|
StoreLevel,
|
||||||
} from "./backend-interface";
|
} from "./backend-interface.js";
|
||||||
import {
|
import {
|
||||||
DOMException,
|
DOMException,
|
||||||
DOMStringList,
|
DOMStringList,
|
||||||
@ -41,10 +41,10 @@ import {
|
|||||||
IDBTransaction,
|
IDBTransaction,
|
||||||
IDBTransactionMode,
|
IDBTransactionMode,
|
||||||
IDBValidKey,
|
IDBValidKey,
|
||||||
} from "./idbtypes";
|
} from "./idbtypes.js";
|
||||||
import { canInjectKey } from "./util/canInjectKey";
|
import { canInjectKey } from "./util/canInjectKey.js";
|
||||||
import { compareKeys } from "./util/cmp";
|
import { compareKeys } from "./util/cmp.js";
|
||||||
import { enforceRange } from "./util/enforceRange";
|
import { enforceRange } from "./util/enforceRange.js";
|
||||||
import {
|
import {
|
||||||
AbortError,
|
AbortError,
|
||||||
ConstraintError,
|
ConstraintError,
|
||||||
@ -56,20 +56,19 @@ import {
|
|||||||
ReadOnlyError,
|
ReadOnlyError,
|
||||||
TransactionInactiveError,
|
TransactionInactiveError,
|
||||||
VersionError,
|
VersionError,
|
||||||
} from "./util/errors";
|
} from "./util/errors.js";
|
||||||
import { FakeDOMStringList, fakeDOMStringList } from "./util/fakeDOMStringList";
|
import { FakeDOMStringList, fakeDOMStringList } from "./util/fakeDOMStringList.js";
|
||||||
import FakeEvent from "./util/FakeEvent";
|
import FakeEvent from "./util/FakeEvent.js";
|
||||||
import FakeEventTarget from "./util/FakeEventTarget";
|
import FakeEventTarget from "./util/FakeEventTarget.js";
|
||||||
import { makeStoreKeyValue } from "./util/makeStoreKeyValue";
|
import { makeStoreKeyValue } from "./util/makeStoreKeyValue.js";
|
||||||
import { normalizeKeyPath } from "./util/normalizeKeyPath";
|
import { normalizeKeyPath } from "./util/normalizeKeyPath.js";
|
||||||
import { openPromise } from "./util/openPromise";
|
import { openPromise } from "./util/openPromise.js";
|
||||||
import queueTask from "./util/queueTask";
|
import queueTask from "./util/queueTask.js";
|
||||||
import {
|
import {
|
||||||
checkStructuredCloneOrThrow,
|
checkStructuredCloneOrThrow,
|
||||||
structuredClone,
|
} from "./util/structuredClone.js";
|
||||||
} from "./util/structuredClone";
|
import { validateKeyPath } from "./util/validateKeyPath.js";
|
||||||
import { validateKeyPath } from "./util/validateKeyPath";
|
import { valueToKey } from "./util/valueToKey.js";
|
||||||
import { valueToKey } from "./util/valueToKey";
|
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export type CursorSource = BridgeIDBIndex | BridgeIDBObjectStore;
|
export type CursorSource = BridgeIDBIndex | BridgeIDBObjectStore;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { createdb } from "./wptsupport";
|
import { createdb } from "./wptsupport.js";
|
||||||
|
|
||||||
test("WPT test abort-in-initial-upgradeneeded.htm", async (t) => {
|
test("WPT test abort-in-initial-upgradeneeded.htm", async (t) => {
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBCursor } from "..";
|
import { createdb } from "./wptsupport.js";
|
||||||
import { BridgeIDBCursorWithValue } from "../bridge-idb";
|
|
||||||
import { createdb } from "./wptsupport";
|
|
||||||
|
|
||||||
// When db.close is called in upgradeneeded, the db is cleaned up on refresh
|
// When db.close is called in upgradeneeded, the db is cleaned up on refresh
|
||||||
test.cb("WPT test close-in-upgradeneeded.htm", (t) => {
|
test("WPT test close-in-upgradeneeded.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
var sawTransactionComplete = false;
|
var sawTransactionComplete = false;
|
||||||
@ -39,6 +38,7 @@ test.cb("WPT test close-in-upgradeneeded.htm", (t) => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBCursor, BridgeIDBKeyRange } from "..";
|
import { BridgeIDBKeyRange } from "../bridge-idb.js";
|
||||||
import { BridgeIDBCursorWithValue } from "../bridge-idb";
|
import { IDBRequest } from "../idbtypes.js";
|
||||||
import { IDBRequest } from "../idbtypes";
|
import { createdb } from "./wptsupport.js";
|
||||||
import { createdb } from "./wptsupport";
|
|
||||||
|
|
||||||
const IDBKeyRange = BridgeIDBKeyRange;
|
const IDBKeyRange = BridgeIDBKeyRange;
|
||||||
|
|
||||||
// Validate the overloads of IDBObjectStore.openCursor(),
|
// Validate the overloads of IDBObjectStore.openCursor(),
|
||||||
// IDBIndex.openCursor() and IDBIndex.openKeyCursor()
|
// IDBIndex.openCursor() and IDBIndex.openKeyCursor()
|
||||||
test.cb("WPT test cursor-overloads.htm", (t) => {
|
test("WPT test cursor-overloads.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any, store: any, index: any;
|
var db: any, store: any, index: any;
|
||||||
|
|
||||||
var request = createdb(t);
|
var request = createdb(t);
|
||||||
@ -29,9 +29,15 @@ test.cb("WPT test cursor-overloads.htm", (t) => {
|
|||||||
await checkCursorDirection(store.openCursor(), "next");
|
await checkCursorDirection(store.openCursor(), "next");
|
||||||
await checkCursorDirection(store.openCursor(0), "next");
|
await checkCursorDirection(store.openCursor(0), "next");
|
||||||
await checkCursorDirection(store.openCursor(0, "next"), "next");
|
await checkCursorDirection(store.openCursor(0, "next"), "next");
|
||||||
await checkCursorDirection(store.openCursor(0, "nextunique"), "nextunique");
|
await checkCursorDirection(
|
||||||
|
store.openCursor(0, "nextunique"),
|
||||||
|
"nextunique",
|
||||||
|
);
|
||||||
await checkCursorDirection(store.openCursor(0, "prev"), "prev");
|
await checkCursorDirection(store.openCursor(0, "prev"), "prev");
|
||||||
await checkCursorDirection(store.openCursor(0, "prevunique"), "prevunique");
|
await checkCursorDirection(
|
||||||
|
store.openCursor(0, "prevunique"),
|
||||||
|
"prevunique",
|
||||||
|
);
|
||||||
|
|
||||||
await checkCursorDirection(store.openCursor(IDBKeyRange.only(0)), "next");
|
await checkCursorDirection(store.openCursor(IDBKeyRange.only(0)), "next");
|
||||||
await checkCursorDirection(
|
await checkCursorDirection(
|
||||||
@ -54,9 +60,15 @@ test.cb("WPT test cursor-overloads.htm", (t) => {
|
|||||||
await checkCursorDirection(index.openCursor(), "next");
|
await checkCursorDirection(index.openCursor(), "next");
|
||||||
await checkCursorDirection(index.openCursor(0), "next");
|
await checkCursorDirection(index.openCursor(0), "next");
|
||||||
await checkCursorDirection(index.openCursor(0, "next"), "next");
|
await checkCursorDirection(index.openCursor(0, "next"), "next");
|
||||||
await checkCursorDirection(index.openCursor(0, "nextunique"), "nextunique");
|
await checkCursorDirection(
|
||||||
|
index.openCursor(0, "nextunique"),
|
||||||
|
"nextunique",
|
||||||
|
);
|
||||||
await checkCursorDirection(index.openCursor(0, "prev"), "prev");
|
await checkCursorDirection(index.openCursor(0, "prev"), "prev");
|
||||||
await checkCursorDirection(index.openCursor(0, "prevunique"), "prevunique");
|
await checkCursorDirection(
|
||||||
|
index.openCursor(0, "prevunique"),
|
||||||
|
"prevunique",
|
||||||
|
);
|
||||||
|
|
||||||
await checkCursorDirection(index.openCursor(IDBKeyRange.only(0)), "next");
|
await checkCursorDirection(index.openCursor(IDBKeyRange.only(0)), "next");
|
||||||
await checkCursorDirection(
|
await checkCursorDirection(
|
||||||
@ -110,8 +122,9 @@ test.cb("WPT test cursor-overloads.htm", (t) => {
|
|||||||
"prevunique",
|
"prevunique",
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function checkCursorDirection(
|
function checkCursorDirection(
|
||||||
request: IDBRequest,
|
request: IDBRequest,
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBRequest } from "..";
|
import { BridgeIDBRequest } from "../bridge-idb.js";
|
||||||
import {
|
import {
|
||||||
createdb,
|
|
||||||
indexeddb_test,
|
indexeddb_test,
|
||||||
is_transaction_active,
|
is_transaction_active,
|
||||||
keep_alive,
|
keep_alive,
|
||||||
} from "./wptsupport";
|
} from "./wptsupport.js";
|
||||||
|
|
||||||
test("WPT test abort-in-initial-upgradeneeded.htm (subtest 1)", async (t) => {
|
test("WPT test abort-in-initial-upgradeneeded.htm (subtest 1)", async (t) => {
|
||||||
// Transactions are active during success handlers
|
// Transactions are active during success handlers
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBCursor } from "..";
|
import { BridgeIDBCursor,BridgeIDBRequest } from "../bridge-idb.js";
|
||||||
import { BridgeIDBRequest } from "../bridge-idb";
|
import { createdb } from "./wptsupport.js";
|
||||||
import { InvalidStateError } from "../util/errors";
|
|
||||||
import { createdb } from "./wptsupport";
|
|
||||||
|
|
||||||
test("WPT test idbcursor_advance_index.htm", async (t) => {
|
test("WPT test idbcursor_advance_index.htm", async (t) => {
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBCursor } from "..";
|
import { BridgeIDBCursor, BridgeIDBCursorWithValue } from "../bridge-idb.js";
|
||||||
import { BridgeIDBCursorWithValue } from "../bridge-idb";
|
import { createdb } from "./wptsupport.js";
|
||||||
import { createdb } from "./wptsupport";
|
|
||||||
|
|
||||||
test.cb("WPT test idbcursor_continue_index.htm", (t) => {
|
test("WPT test idbcursor_continue_index.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const records = [
|
const records = [
|
||||||
@ -33,7 +33,7 @@ test.cb("WPT test idbcursor_continue_index.htm", (t) => {
|
|||||||
var cursor = e.target.result;
|
var cursor = e.target.result;
|
||||||
if (!cursor) {
|
if (!cursor) {
|
||||||
t.deepEqual(count, records.length, "cursor run count");
|
t.deepEqual(count, records.length, "cursor run count");
|
||||||
t.end();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,10 +45,12 @@ test.cb("WPT test idbcursor_continue_index.htm", (t) => {
|
|||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - index - attempt to pass a key parameter that is not a valid key
|
// IDBCursor.continue() - index - attempt to pass a key parameter that is not a valid key
|
||||||
test.cb("WPT idbcursor-continue-index2.htm", (t) => {
|
test("WPT idbcursor-continue-index2.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
let records = [
|
let records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -84,14 +86,16 @@ test.cb("WPT idbcursor-continue-index2.htm", (t) => {
|
|||||||
|
|
||||||
t.true(cursor instanceof BridgeIDBCursorWithValue, "cursor");
|
t.true(cursor instanceof BridgeIDBCursorWithValue, "cursor");
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - index - attempt to iterate to the previous
|
// IDBCursor.continue() - index - attempt to iterate to the previous
|
||||||
// record when the direction is set for the next record
|
// record when the direction is set for the next record
|
||||||
test.cb("WPT idbcursor-continue-index3.htm", (t) => {
|
test("WPT idbcursor-continue-index3.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
const records = [
|
const records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -120,7 +124,7 @@ test.cb("WPT idbcursor-continue-index3.htm", (t) => {
|
|||||||
var cursor = e.target.result;
|
var cursor = e.target.result;
|
||||||
if (!cursor) {
|
if (!cursor) {
|
||||||
t.deepEqual(count, 2, "ran number of times");
|
t.deepEqual(count, 2, "ran number of times");
|
||||||
t.end();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,11 +141,13 @@ test.cb("WPT idbcursor-continue-index3.htm", (t) => {
|
|||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - index - attempt to iterate to the next
|
// IDBCursor.continue() - index - attempt to iterate to the next
|
||||||
// record when the direction is set for the previous record
|
// record when the direction is set for the previous record
|
||||||
test.cb("WPT idbcursor-continue-index4.htm", (t) => {
|
test("WPT idbcursor-continue-index4.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
const records = [
|
const records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -187,7 +193,7 @@ test.cb("WPT idbcursor-continue-index4.htm", (t) => {
|
|||||||
},
|
},
|
||||||
{ name: "DataError" },
|
{ name: "DataError" },
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -197,10 +203,12 @@ test.cb("WPT idbcursor-continue-index4.htm", (t) => {
|
|||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - index - iterate using 'prevunique'
|
// IDBCursor.continue() - index - iterate using 'prevunique'
|
||||||
test.cb("WPT idbcursor-continue-index5.htm", (t) => {
|
test("WPT idbcursor-continue-index5.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
const records = [
|
const records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -235,7 +243,7 @@ test.cb("WPT idbcursor-continue-index5.htm", (t) => {
|
|||||||
cursor_rq.onsuccess = function (e: any) {
|
cursor_rq.onsuccess = function (e: any) {
|
||||||
if (!e.target.result) {
|
if (!e.target.result) {
|
||||||
t.deepEqual(count, expected.length, "count");
|
t.deepEqual(count, expected.length, "count");
|
||||||
t.end();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const cursor = e.target.result;
|
const cursor = e.target.result;
|
||||||
@ -254,10 +262,12 @@ test.cb("WPT idbcursor-continue-index5.htm", (t) => {
|
|||||||
cursor.continue(expected[count] ? expected[count].iKey : undefined);
|
cursor.continue(expected[count] ? expected[count].iKey : undefined);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - index - iterate using nextunique
|
// IDBCursor.continue() - index - iterate using nextunique
|
||||||
test.cb("WPT idbcursor-continue-index6.htm", (t) => {
|
test("WPT idbcursor-continue-index6.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
const records = [
|
const records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -292,7 +302,7 @@ test.cb("WPT idbcursor-continue-index6.htm", (t) => {
|
|||||||
cursor_rq.onsuccess = function (e: any) {
|
cursor_rq.onsuccess = function (e: any) {
|
||||||
if (!e.target.result) {
|
if (!e.target.result) {
|
||||||
t.deepEqual(count, expected.length, "count");
|
t.deepEqual(count, expected.length, "count");
|
||||||
t.end();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var cursor = e.target.result,
|
var cursor = e.target.result,
|
||||||
@ -312,10 +322,12 @@ test.cb("WPT idbcursor-continue-index6.htm", (t) => {
|
|||||||
cursor.continue(expected[count] ? expected[count].iKey : undefined);
|
cursor.continue(expected[count] ? expected[count].iKey : undefined);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - index - throw TransactionInactiveError
|
// IDBCursor.continue() - index - throw TransactionInactiveError
|
||||||
test.cb("WPT idbcursor-continue-index7.htm", (t) => {
|
test("WPT idbcursor-continue-index7.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -343,13 +355,16 @@ test.cb("WPT idbcursor-continue-index7.htm", (t) => {
|
|||||||
{ name: "TransactionInactiveError" },
|
{ name: "TransactionInactiveError" },
|
||||||
"Calling continue() should throws an exception TransactionInactiveError when the transaction is not active.",
|
"Calling continue() should throws an exception TransactionInactiveError when the transaction is not active.",
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
|
return;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - index - throw InvalidStateError caused by object store been deleted
|
// IDBCursor.continue() - index - throw InvalidStateError caused by object store been deleted
|
||||||
test.cb("WPT idbcursor-continue-index8.htm", (t) => {
|
test("WPT idbcursor-continue-index8.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -379,7 +394,8 @@ test.cb("WPT idbcursor-continue-index8.htm", (t) => {
|
|||||||
"If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type 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,11 +1,11 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBCursor } from "..";
|
import { BridgeIDBCursor } from "../bridge-idb.js";
|
||||||
import { BridgeIDBCursorWithValue } from "../bridge-idb";
|
import { IDBDatabase } from "../idbtypes.js";
|
||||||
import { IDBDatabase } from "../idbtypes";
|
import { createdb } from "./wptsupport.js";
|
||||||
import { createdb } from "./wptsupport";
|
|
||||||
|
|
||||||
// IDBCursor.continue() - object store - iterate to the next record
|
// IDBCursor.continue() - object store - iterate to the next record
|
||||||
test.cb("WPT test idbcursor_continue_objectstore.htm", (t) => {
|
test("WPT test idbcursor_continue_objectstore.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
||||||
@ -29,7 +29,8 @@ test.cb("WPT test idbcursor_continue_objectstore.htm", (t) => {
|
|||||||
var cursor = e.target.result;
|
var cursor = e.target.result;
|
||||||
if (!cursor) {
|
if (!cursor) {
|
||||||
t.deepEqual(count, records.length, "cursor run count");
|
t.deepEqual(count, records.length, "cursor run count");
|
||||||
t.end();
|
resolve();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var record = cursor.value;
|
var record = cursor.value;
|
||||||
@ -39,11 +40,13 @@ test.cb("WPT test idbcursor_continue_objectstore.htm", (t) => {
|
|||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - index - attempt to pass a
|
// IDBCursor.continue() - index - attempt to pass a
|
||||||
// key parameter that is not a valid key
|
// key parameter that is not a valid key
|
||||||
test.cb("WPT test idbcursor_continue_objectstore2.htm", (t) => {
|
test("WPT test idbcursor_continue_objectstore2.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
||||||
|
|
||||||
@ -69,14 +72,16 @@ test.cb("WPT test idbcursor_continue_objectstore2.htm", (t) => {
|
|||||||
{ name: "DataError" },
|
{ name: "DataError" },
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - object store - attempt to iterate to the
|
// IDBCursor.continue() - object store - attempt to iterate to the
|
||||||
// previous record when the direction is set for the next record
|
// previous record when the direction is set for the next record
|
||||||
test.cb("WPT test idbcursor_continue_objectstore3.htm", (t) => {
|
test("WPT test idbcursor_continue_objectstore3.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: IDBDatabase;
|
var db: IDBDatabase;
|
||||||
const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
||||||
|
|
||||||
@ -107,14 +112,16 @@ test.cb("WPT test idbcursor_continue_objectstore3.htm", (t) => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - object store - attempt to iterate to the
|
// IDBCursor.continue() - object store - attempt to iterate to the
|
||||||
// next record when the direction is set for the previous record
|
// next record when the direction is set for the previous record
|
||||||
test.cb("WPT test idbcursor_continue_objectstore4.htm", (t) => {
|
test("WPT test idbcursor_continue_objectstore4.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
const records = [
|
const records = [
|
||||||
{ pKey: "primaryKey_0" },
|
{ pKey: "primaryKey_0" },
|
||||||
@ -144,12 +151,20 @@ test.cb("WPT test idbcursor_continue_objectstore4.htm", (t) => {
|
|||||||
|
|
||||||
switch (count) {
|
switch (count) {
|
||||||
case 0:
|
case 0:
|
||||||
t.deepEqual(cursor.value.pKey, records[2].pKey, "first cursor pkey");
|
t.deepEqual(
|
||||||
|
cursor.value.pKey,
|
||||||
|
records[2].pKey,
|
||||||
|
"first cursor pkey",
|
||||||
|
);
|
||||||
cursor.continue(records[1].pKey);
|
cursor.continue(records[1].pKey);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
t.deepEqual(cursor.value.pKey, records[1].pKey, "second cursor pkey");
|
t.deepEqual(
|
||||||
|
cursor.value.pKey,
|
||||||
|
records[1].pKey,
|
||||||
|
"second cursor pkey",
|
||||||
|
);
|
||||||
t.throws(
|
t.throws(
|
||||||
() => {
|
() => {
|
||||||
console.log("**** continuing cursor");
|
console.log("**** continuing cursor");
|
||||||
@ -160,8 +175,8 @@ test.cb("WPT test idbcursor_continue_objectstore4.htm", (t) => {
|
|||||||
name: "DataError",
|
name: "DataError",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
break;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
t.fail("Unexpected count value: " + count);
|
t.fail("Unexpected count value: " + count);
|
||||||
@ -170,10 +185,12 @@ test.cb("WPT test idbcursor_continue_objectstore4.htm", (t) => {
|
|||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - object store - throw TransactionInactiveError
|
// IDBCursor.continue() - object store - throw TransactionInactiveError
|
||||||
test.cb("WPT test idbcursor_continue_objectstore5.htm", (t) => {
|
test("WPT test idbcursor_continue_objectstore5.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
||||||
|
|
||||||
@ -203,13 +220,16 @@ test.cb("WPT test idbcursor_continue_objectstore5.htm", (t) => {
|
|||||||
"Calling continue() should throw an exception TransactionInactiveError when the transaction is not active.",
|
"Calling continue() should throw an exception TransactionInactiveError when the transaction is not active.",
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
|
return;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.continue() - object store - throw InvalidStateError caused by object store been deleted
|
// IDBCursor.continue() - object store - throw InvalidStateError caused by object store been deleted
|
||||||
test.cb("WPT test idbcursor_continue_objectstore6.htm", (t) => {
|
test("WPT test idbcursor_continue_objectstore6.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
||||||
|
|
||||||
@ -237,7 +257,8 @@ test.cb("WPT test idbcursor_continue_objectstore6.htm", (t) => {
|
|||||||
"If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type 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 test from "ava";
|
||||||
import { createdb, indexeddb_test } from "./wptsupport";
|
import { indexeddb_test } from "./wptsupport.js";
|
||||||
|
|
||||||
test("WPT idbcursor-delete-exception-order.htm", async (t) => {
|
test("WPT idbcursor-delete-exception-order.htm", async (t) => {
|
||||||
// 'IDBCursor.delete exception order: TransactionInactiveError vs. ReadOnlyError'
|
// 'IDBCursor.delete exception order: TransactionInactiveError vs. ReadOnlyError'
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBCursor } from "..";
|
import { BridgeIDBCursor } from "../bridge-idb.js";
|
||||||
import { IDBCursor } from "../idbtypes";
|
import { IDBCursor } from "../idbtypes.js";
|
||||||
import { createdb, indexeddb_test } from "./wptsupport";
|
import { createdb } from "./wptsupport.js";
|
||||||
|
|
||||||
// IDBCursor.delete() - index - remove a record from the object store
|
// IDBCursor.delete() - index - remove a record from the object store
|
||||||
test.cb("WPT idbcursor-delete-index.htm", (t) => {
|
test("WPT idbcursor-delete-index.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
let count = 0,
|
let count = 0,
|
||||||
records = [
|
records = [
|
||||||
@ -46,7 +47,7 @@ test.cb("WPT idbcursor-delete-index.htm", (t) => {
|
|||||||
|
|
||||||
if (!cursor) {
|
if (!cursor) {
|
||||||
t.deepEqual(count, 1, "count");
|
t.deepEqual(count, 1, "count");
|
||||||
t.end();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,10 +57,12 @@ test.cb("WPT idbcursor-delete-index.htm", (t) => {
|
|||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.delete() - object store - attempt to remove a record in a read-only transaction
|
// IDBCursor.delete() - object store - attempt to remove a record in a read-only transaction
|
||||||
test.cb("WPT idbcursor-delete-index2.htm", (t) => {
|
test("WPT idbcursor-delete-index2.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -90,13 +93,15 @@ test.cb("WPT idbcursor-delete-index2.htm", (t) => {
|
|||||||
name: "ReadOnlyError",
|
name: "ReadOnlyError",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.delete() - index - attempt to remove a record in an inactive transaction
|
// IDBCursor.delete() - index - attempt to remove a record in an inactive transaction
|
||||||
test.cb("WPT idbcursor-delete-index3.htm", (t) => {
|
test("WPT idbcursor-delete-index3.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -128,13 +133,15 @@ test.cb("WPT idbcursor-delete-index3.htm", (t) => {
|
|||||||
},
|
},
|
||||||
{ name: "TransactionInactiveError" },
|
{ name: "TransactionInactiveError" },
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.delete() - index - throw InvalidStateError caused by object store been deleted
|
// IDBCursor.delete() - index - throw InvalidStateError caused by object store been deleted
|
||||||
test.cb("WPT idbcursor-delete-index4.htm", (t) => {
|
test("WPT idbcursor-delete-index4.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -163,13 +170,15 @@ test.cb("WPT idbcursor-delete-index4.htm", (t) => {
|
|||||||
"If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type 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
|
// IDBCursor.delete() - index - throw InvalidStateError when the cursor is being iterated
|
||||||
test.cb("WPT idbcursor-delete-index5.htm", (t) => {
|
test("WPT idbcursor-delete-index5.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -198,7 +207,8 @@ test.cb("WPT idbcursor-delete-index5.htm", (t) => {
|
|||||||
{ name: "InvalidStateError" },
|
{ name: "InvalidStateError" },
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBCursor } from "..";
|
import { BridgeIDBCursor } from "../bridge-idb.js";
|
||||||
import { IDBCursor } from "../idbtypes";
|
import { createdb } from "./wptsupport.js";
|
||||||
import { createdb, indexeddb_test } from "./wptsupport";
|
|
||||||
|
|
||||||
// IDBCursor.delete() - object store - remove a record from the object store
|
// IDBCursor.delete() - object store - remove a record from the object store
|
||||||
test.cb("WPT idbcursor-delete-objectstore.htm", (t) => {
|
test("WPT idbcursor-delete-objectstore.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
count = 0,
|
count = 0,
|
||||||
records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
||||||
@ -42,7 +42,8 @@ test.cb("WPT idbcursor-delete-objectstore.htm", (t) => {
|
|||||||
|
|
||||||
if (!cursor) {
|
if (!cursor) {
|
||||||
t.deepEqual(count, 1, "count");
|
t.deepEqual(count, 1, "count");
|
||||||
t.end();
|
resolve();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
t.deepEqual(cursor.value.pKey, records[1].pKey);
|
t.deepEqual(cursor.value.pKey, records[1].pKey);
|
||||||
@ -50,10 +51,12 @@ test.cb("WPT idbcursor-delete-objectstore.htm", (t) => {
|
|||||||
cursor.continue();
|
cursor.continue();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.delete() - object store - attempt to remove a record in a read-only transaction
|
// IDBCursor.delete() - object store - attempt to remove a record in a read-only transaction
|
||||||
test.cb("WPT idbcursor-delete-objectstore2.htm", (t) => {
|
test("WPT idbcursor-delete-objectstore2.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -82,13 +85,15 @@ test.cb("WPT idbcursor-delete-objectstore2.htm", (t) => {
|
|||||||
},
|
},
|
||||||
{ name: "ReadOnlyError" },
|
{ name: "ReadOnlyError" },
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.delete() - index - attempt to remove a record in an inactive transaction
|
// IDBCursor.delete() - index - attempt to remove a record in an inactive transaction
|
||||||
test.cb("WPT idbcursor-delete-objectstore3.htm", (t) => {
|
test("WPT idbcursor-delete-objectstore3.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -121,13 +126,15 @@ test.cb("WPT idbcursor-delete-objectstore3.htm", (t) => {
|
|||||||
name: "TransactionInactiveError",
|
name: "TransactionInactiveError",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.delete() - object store - throw InvalidStateError caused by object store been deleted
|
// IDBCursor.delete() - object store - throw InvalidStateError caused by object store been deleted
|
||||||
test.cb("WPT idbcursor-delete-objectstore4.htm", (t) => {
|
test("WPT idbcursor-delete-objectstore4.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
||||||
|
|
||||||
@ -152,13 +159,15 @@ test.cb("WPT idbcursor-delete-objectstore4.htm", (t) => {
|
|||||||
"If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type 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
|
// IDBCursor.delete() - object store - throw InvalidStateError when the cursor is being iterated
|
||||||
test.cb("WPT idbcursor-delete-objectstore5.htm", (t) => {
|
test("WPT idbcursor-delete-objectstore5.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }];
|
||||||
|
|
||||||
@ -188,7 +197,8 @@ test.cb("WPT idbcursor-delete-objectstore5.htm", (t) => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { createdb } from "./wptsupport";
|
import { createdb } from "./wptsupport.js";
|
||||||
|
|
||||||
test("WPT idbcursor-reused.htm", async (t) => {
|
test("WPT idbcursor-reused.htm", async (t) => {
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBCursor, BridgeIDBKeyRange } from "..";
|
import { BridgeIDBCursor, BridgeIDBKeyRange } from "../bridge-idb.js";
|
||||||
import {
|
import {
|
||||||
createDatabase,
|
createDatabase,
|
||||||
createdb,
|
createdb,
|
||||||
promiseForRequest,
|
promiseForRequest,
|
||||||
promiseForTransaction,
|
promiseForTransaction,
|
||||||
} from "./wptsupport";
|
} from "./wptsupport.js";
|
||||||
|
|
||||||
// IDBCursor.update() - index - modify a record in the object store
|
// IDBCursor.update() - index - modify a record in the object store
|
||||||
test.cb("WPT test idbcursor_update_index.htm", (t) => {
|
test("WPT test idbcursor_update_index.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -50,13 +51,15 @@ test.cb("WPT test idbcursor_update_index.htm", (t) => {
|
|||||||
var cursor = e.target.result;
|
var cursor = e.target.result;
|
||||||
|
|
||||||
t.deepEqual(cursor.value.iKey, records[0].iKey + "_updated");
|
t.deepEqual(cursor.value.iKey, records[0].iKey + "_updated");
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.update() - index - attempt to modify a record in a read-only transaction
|
// IDBCursor.update() - index - attempt to modify a record in a read-only transaction
|
||||||
test.cb("WPT test idbcursor_update_index2.htm", (t) => {
|
test("WPT test idbcursor_update_index2.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -88,13 +91,15 @@ test.cb("WPT test idbcursor_update_index2.htm", (t) => {
|
|||||||
},
|
},
|
||||||
{ name: "ReadOnlyError" },
|
{ name: "ReadOnlyError" },
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//IDBCursor.update() - index - attempt to modify a record in an inactive transaction
|
//IDBCursor.update() - index - attempt to modify a record in an inactive transaction
|
||||||
test.cb("WPT test idbcursor_update_index3.htm", (t) => {
|
test("WPT test idbcursor_update_index3.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -127,13 +132,15 @@ test.cb("WPT test idbcursor_update_index3.htm", (t) => {
|
|||||||
},
|
},
|
||||||
{ name: "TransactionInactiveError" },
|
{ name: "TransactionInactiveError" },
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.update() - index - attempt to modify a record when object store been deleted
|
// IDBCursor.update() - index - attempt to modify a record when object store been deleted
|
||||||
test.cb("WPT test idbcursor_update_index4.htm", (t) => {
|
test("WPT test idbcursor_update_index4.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -163,13 +170,15 @@ test.cb("WPT test idbcursor_update_index4.htm", (t) => {
|
|||||||
"If the cursor's source or effective object store has been deleted, the implementation MUST throw a DOMException of type 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
|
// IDBCursor.update() - index - throw DataCloneError
|
||||||
test.cb("WPT test idbcursor_update_index5.htm", (t) => {
|
test("WPT test idbcursor_update_index5.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -206,13 +215,15 @@ test.cb("WPT test idbcursor_update_index5.htm", (t) => {
|
|||||||
},
|
},
|
||||||
{ name: "DataCloneError" },
|
{ name: "DataCloneError" },
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.update() - index - no argument
|
// IDBCursor.update() - index - no argument
|
||||||
test.cb("WPT test idbcursor_update_index6.htm", (t) => {
|
test("WPT test idbcursor_update_index6.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -248,13 +259,15 @@ test.cb("WPT test idbcursor_update_index6.htm", (t) => {
|
|||||||
instanceOf: TypeError,
|
instanceOf: TypeError,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.update() - index - throw DataError
|
// IDBCursor.update() - index - throw DataError
|
||||||
test.cb("WPT test idbcursor_update_index7.htm", (t) => {
|
test("WPT test idbcursor_update_index7.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -288,13 +301,15 @@ test.cb("WPT test idbcursor_update_index7.htm", (t) => {
|
|||||||
},
|
},
|
||||||
{ name: "DataError" },
|
{ name: "DataError" },
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBCursor.update() - index - throw InvalidStateError when the cursor is being iterated
|
// IDBCursor.update() - index - throw InvalidStateError when the cursor is being iterated
|
||||||
test.cb("WPT test idbcursor_update_index8.htm", (t) => {
|
test("WPT test idbcursor_update_index8.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
records = [
|
records = [
|
||||||
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
{ pKey: "primaryKey_0", iKey: "indexKey_0" },
|
||||||
@ -332,9 +347,10 @@ test.cb("WPT test idbcursor_update_index8.htm", (t) => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Index cursor - indexed values updated during iteration
|
// Index cursor - indexed values updated during iteration
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { createdb, idbFactory } from "./wptsupport";
|
import { idbFactory } from "./wptsupport.js";
|
||||||
|
|
||||||
test("WPT idbfactory-cmp*.html", async (t) => {
|
test("WPT idbfactory-cmp*.html", async (t) => {
|
||||||
const indexedDB = idbFactory;
|
const indexedDB = idbFactory;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBVersionChangeEvent } from "../bridge-idb";
|
import { BridgeIDBVersionChangeEvent } from "../bridge-idb.js";
|
||||||
import FakeEvent from "../util/FakeEvent";
|
import FakeEvent from "../util/FakeEvent.js";
|
||||||
import { createdb, format_value, idbFactory } from "./wptsupport";
|
import { createdb, format_value, idbFactory } from "./wptsupport.js";
|
||||||
|
|
||||||
// IDBFactory.open() - request has no source
|
// IDBFactory.open() - request has no source
|
||||||
test("WPT idbfactory-open.htm", async (t) => {
|
test("WPT idbfactory-open.htm", async (t) => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBKeyRange, BridgeIDBRequest } from "..";
|
import { BridgeIDBKeyRange } from "../bridge-idb.js";
|
||||||
import { IDBDatabase } from "../idbtypes";
|
import { IDBDatabase } from "../idbtypes.js";
|
||||||
import { createdb } from "./wptsupport";
|
import { createdb } from "./wptsupport.js";
|
||||||
|
|
||||||
// IDBIndex.get() - returns the record
|
// IDBIndex.get() - returns the record
|
||||||
test("WPT idbindex_get.htm", async (t) => {
|
test("WPT idbindex_get.htm", async (t) => {
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBCursor } from "..";
|
import { createdb } from "./wptsupport.js";
|
||||||
import { BridgeIDBCursorWithValue } from "../bridge-idb";
|
|
||||||
import { IDBDatabase } from "../idbtypes";
|
|
||||||
import { createdb } from "./wptsupport";
|
|
||||||
|
|
||||||
// IDBIndex.openCursor() - throw InvalidStateError when the index is deleted
|
// IDBIndex.openCursor() - throw InvalidStateError when the index is deleted
|
||||||
test.cb("WPT test idbindex-openCursor.htm", (t) => {
|
test("WPT test idbindex-openCursor.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db;
|
var db;
|
||||||
|
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
@ -24,12 +22,14 @@ test.cb("WPT test idbindex-openCursor.htm", (t) => {
|
|||||||
{ name: "InvalidStateError" },
|
{ name: "InvalidStateError" },
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBIndex.openCursor() - throw TransactionInactiveError on aborted transaction
|
// IDBIndex.openCursor() - throw TransactionInactiveError on aborted transaction
|
||||||
test.cb("WPT test idbindex-openCursor2.htm", (t) => {
|
test("WPT test idbindex-openCursor2.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db;
|
var db;
|
||||||
|
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
@ -52,12 +52,14 @@ test.cb("WPT test idbindex-openCursor2.htm", (t) => {
|
|||||||
{ name: "TransactionInactiveError" },
|
{ name: "TransactionInactiveError" },
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBIndex.openCursor() - throw InvalidStateError on index deleted by aborted upgrade
|
// IDBIndex.openCursor() - throw InvalidStateError on index deleted by aborted upgrade
|
||||||
test.cb("WPT test idbindex-openCursor3.htm", (t) => {
|
test("WPT test idbindex-openCursor3.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db;
|
var db;
|
||||||
|
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
@ -77,6 +79,7 @@ test.cb("WPT test idbindex-openCursor3.htm", (t) => {
|
|||||||
{ name: "InvalidStateError" },
|
{ name: "InvalidStateError" },
|
||||||
);
|
);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import test, { ExecutionContext } from "ava";
|
import test, { ExecutionContext } from "ava";
|
||||||
import { BridgeIDBCursor } from "..";
|
import { indexeddb_test } from "./wptsupport.js";
|
||||||
import { BridgeIDBRequest } from "../bridge-idb";
|
|
||||||
import { InvalidStateError } from "../util/errors";
|
|
||||||
import { createdb, indexeddb_test } from "./wptsupport";
|
|
||||||
|
|
||||||
async function t1(t: ExecutionContext, method: string): Promise<void> {
|
async function t1(t: ExecutionContext, method: string): Promise<void> {
|
||||||
await indexeddb_test(
|
await indexeddb_test(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBRequest } from "..";
|
import { BridgeIDBRequest } from "../bridge-idb.js";
|
||||||
import { IDBDatabase } from "../idbtypes";
|
import { IDBDatabase } from "../idbtypes.js";
|
||||||
import { createdb } from "./wptsupport";
|
import { createdb } from "./wptsupport.js";
|
||||||
|
|
||||||
// IDBObjectStore.add() - add with an inline key
|
// IDBObjectStore.add() - add with an inline key
|
||||||
test("WPT idbobjectstore_add.htm", async (t) => {
|
test("WPT idbobjectstore_add.htm", async (t) => {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBKeyRange, BridgeIDBRequest } from "..";
|
import { BridgeIDBKeyRange } from "../bridge-idb.js";
|
||||||
import { IDBDatabase } from "../idbtypes";
|
import { createdb } from "./wptsupport.js";
|
||||||
import { createdb } from "./wptsupport";
|
|
||||||
|
|
||||||
// IDBObjectStore.get() - key is a number
|
// IDBObjectStore.get() - key is a number
|
||||||
test.cb("WPT idbobjectstore_get.htm", (t) => {
|
test("WPT idbobjectstore_get.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { key: 3.14159265, property: "data" };
|
record = { key: 3.14159265, property: "data" };
|
||||||
|
|
||||||
@ -20,13 +20,15 @@ test.cb("WPT idbobjectstore_get.htm", (t) => {
|
|||||||
rq.onsuccess = function (e: any) {
|
rq.onsuccess = function (e: any) {
|
||||||
t.deepEqual(e.target.result.key, record.key);
|
t.deepEqual(e.target.result.key, record.key);
|
||||||
t.deepEqual(e.target.result.property, record.property);
|
t.deepEqual(e.target.result.property, record.property);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.get() - key is a string
|
// IDBObjectStore.get() - key is a string
|
||||||
test.cb("WPT idbobjectstore_get2.htm", (t) => {
|
test("WPT idbobjectstore_get2.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { key: "this is a key that's a string", property: "data" };
|
record = { key: "this is a key that's a string", property: "data" };
|
||||||
|
|
||||||
@ -42,13 +44,15 @@ test.cb("WPT idbobjectstore_get2.htm", (t) => {
|
|||||||
rq.onsuccess = function (e: any) {
|
rq.onsuccess = function (e: any) {
|
||||||
t.deepEqual(e.target.result.key, record.key);
|
t.deepEqual(e.target.result.key, record.key);
|
||||||
t.deepEqual(e.target.result.property, record.property);
|
t.deepEqual(e.target.result.property, record.property);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.get() - key is a date
|
// IDBObjectStore.get() - key is a date
|
||||||
test.cb("WPT idbobjectstore_get3.htm", (t) => {
|
test("WPT idbobjectstore_get3.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
const record = { key: new Date(), property: "data" };
|
const record = { key: new Date(), property: "data" };
|
||||||
|
|
||||||
@ -64,13 +68,15 @@ test.cb("WPT idbobjectstore_get3.htm", (t) => {
|
|||||||
rq.onsuccess = function (e: any) {
|
rq.onsuccess = function (e: any) {
|
||||||
t.deepEqual(e.target.result.key.valueOf(), record.key.valueOf());
|
t.deepEqual(e.target.result.key.valueOf(), record.key.valueOf());
|
||||||
t.deepEqual(e.target.result.property, record.property);
|
t.deepEqual(e.target.result.property, record.property);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.get() - attempt to retrieve a record that doesn't exist
|
// IDBObjectStore.get() - attempt to retrieve a record that doesn't exist
|
||||||
test.cb("WPT idbobjectstore_get4.htm", (t) => {
|
test("WPT idbobjectstore_get4.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
|
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
@ -80,16 +86,18 @@ test.cb("WPT idbobjectstore_get4.htm", (t) => {
|
|||||||
rq.onsuccess = function (e: any) {
|
rq.onsuccess = function (e: any) {
|
||||||
t.deepEqual(e.target.results, undefined);
|
t.deepEqual(e.target.results, undefined);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
t.end();
|
resolve();
|
||||||
}, 10);
|
}, 10);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
open_rq.onsuccess = function () {};
|
open_rq.onsuccess = function () {};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.get() - returns the record with the first key in the range
|
// IDBObjectStore.get() - returns the record with the first key in the range
|
||||||
test.cb("WPT idbobjectstore_get5.htm", (t) => {
|
test("WPT idbobjectstore_get5.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
|
|
||||||
@ -106,13 +114,15 @@ test.cb("WPT idbobjectstore_get5.htm", (t) => {
|
|||||||
.objectStore("store")
|
.objectStore("store")
|
||||||
.get(BridgeIDBKeyRange.bound(3, 6)).onsuccess = function (e: any) {
|
.get(BridgeIDBKeyRange.bound(3, 6)).onsuccess = function (e: any) {
|
||||||
t.deepEqual(e.target.result, "data3", "get(3-6)");
|
t.deepEqual(e.target.result, "data3", "get(3-6)");
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.get() - throw TransactionInactiveError on aborted transaction
|
// IDBObjectStore.get() - throw TransactionInactiveError on aborted transaction
|
||||||
test.cb("WPT idbobjectstore_get6.htm", (t) => {
|
test("WPT idbobjectstore_get6.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
|
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
@ -131,12 +141,14 @@ test.cb("WPT idbobjectstore_get6.htm", (t) => {
|
|||||||
{ name: "TransactionInactiveError" },
|
{ name: "TransactionInactiveError" },
|
||||||
"throw TransactionInactiveError on aborted transaction.",
|
"throw TransactionInactiveError on aborted transaction.",
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.get() - throw DataError when using invalid key
|
// IDBObjectStore.get() - throw DataError when using invalid key
|
||||||
test.cb("WPT idbobjectstore_get7.htm", (t) => {
|
test("WPT idbobjectstore_get7.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
|
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
@ -154,6 +166,7 @@ test.cb("WPT idbobjectstore_get7.htm", (t) => {
|
|||||||
{ name: "DataError" },
|
{ name: "DataError" },
|
||||||
"throw DataError when using invalid key.",
|
"throw DataError when using invalid key.",
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBKeyRange, BridgeIDBRequest } from "..";
|
import { BridgeIDBRequest } from "../bridge-idb.js";
|
||||||
import { IDBDatabase } from "../idbtypes";
|
import { createdb } from "./wptsupport.js";
|
||||||
import { createdb } from "./wptsupport";
|
|
||||||
|
|
||||||
// IDBObjectStore.put() - put with an inline key
|
// IDBObjectStore.put() - put with an inline key
|
||||||
test.cb("WPT idbobjectstore_put.htm", (t) => {
|
test("WPT idbobjectstore_put.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { key: 1, property: "data" };
|
record = { key: 1, property: "data" };
|
||||||
|
|
||||||
@ -22,13 +22,15 @@ test.cb("WPT idbobjectstore_put.htm", (t) => {
|
|||||||
rq.onsuccess = function (e: any) {
|
rq.onsuccess = function (e: any) {
|
||||||
t.deepEqual(e.target.result.property, record.property);
|
t.deepEqual(e.target.result.property, record.property);
|
||||||
t.deepEqual(e.target.result.key, record.key);
|
t.deepEqual(e.target.result.key, record.key);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - put with an out-of-line key
|
// IDBObjectStore.put() - put with an out-of-line key
|
||||||
test.cb("WPT idbobjectstore_put2.htm", (t) => {
|
test("WPT idbobjectstore_put2.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
key = 1,
|
key = 1,
|
||||||
record = { property: "data" };
|
record = { property: "data" };
|
||||||
@ -47,13 +49,15 @@ test.cb("WPT idbobjectstore_put2.htm", (t) => {
|
|||||||
rq.onsuccess = function (e: any) {
|
rq.onsuccess = function (e: any) {
|
||||||
t.deepEqual(e.target.result.property, record.property);
|
t.deepEqual(e.target.result.property, record.property);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - put with an out-of-line key
|
// IDBObjectStore.put() - put with an out-of-line key
|
||||||
test.cb("WPT idbobjectstore_put3.htm", (t) => {
|
test("WPT idbobjectstore_put3.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
success_event: any,
|
success_event: any,
|
||||||
record = { key: 1, property: "data" },
|
record = { key: 1, property: "data" },
|
||||||
@ -85,13 +89,15 @@ test.cb("WPT idbobjectstore_put3.htm", (t) => {
|
|||||||
t.deepEqual(rec.property, record_put.property);
|
t.deepEqual(rec.property, record_put.property);
|
||||||
t.deepEqual(rec.more, record_put.more);
|
t.deepEqual(rec.more, record_put.more);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - put where an index has unique:true specified
|
// IDBObjectStore.put() - put where an index has unique:true specified
|
||||||
test.cb("WPT idbobjectstore_put4.htm", (t) => {
|
test("WPT idbobjectstore_put4.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { key: 1, property: "data" };
|
record = { key: 1, property: "data" };
|
||||||
|
|
||||||
@ -103,7 +109,8 @@ test.cb("WPT idbobjectstore_put4.htm", (t) => {
|
|||||||
objStore.put(record);
|
objStore.put(record);
|
||||||
|
|
||||||
var rq = objStore.put(record);
|
var rq = objStore.put(record);
|
||||||
rq.onsuccess = () => t.fail("success on putting duplicate indexed record");
|
rq.onsuccess = () =>
|
||||||
|
t.fail("success on putting duplicate indexed record");
|
||||||
|
|
||||||
rq.onerror = function (e: any) {
|
rq.onerror = function (e: any) {
|
||||||
t.deepEqual(rq.error.name, "ConstraintError");
|
t.deepEqual(rq.error.name, "ConstraintError");
|
||||||
@ -118,12 +125,14 @@ test.cb("WPT idbobjectstore_put4.htm", (t) => {
|
|||||||
|
|
||||||
// Defer done, giving a spurious rq.onsuccess a chance to run
|
// Defer done, giving a spurious rq.onsuccess a chance to run
|
||||||
open_rq.onsuccess = function (e: any) {
|
open_rq.onsuccess = function (e: any) {
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - object store's key path is an object attribute
|
// IDBObjectStore.put() - object store's key path is an object attribute
|
||||||
test.cb("WPT idbobjectstore_put5.htm", (t) => {
|
test("WPT idbobjectstore_put5.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { test: { obj: { key: 1 } }, property: "data" };
|
record = { test: { obj: { key: 1 } }, property: "data" };
|
||||||
|
|
||||||
@ -143,13 +152,15 @@ test.cb("WPT idbobjectstore_put5.htm", (t) => {
|
|||||||
rq.onsuccess = function (e: any) {
|
rq.onsuccess = function (e: any) {
|
||||||
t.deepEqual(e.target.result.property, record.property);
|
t.deepEqual(e.target.result.property, record.property);
|
||||||
|
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - autoIncrement and inline keys
|
// IDBObjectStore.put() - autoIncrement and inline keys
|
||||||
test.cb("WPT idbobjectstore_put6.htm", (t) => {
|
test("WPT idbobjectstore_put6.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { property: "data" },
|
record = { property: "data" },
|
||||||
expected_keys = [1, 2, 3, 4];
|
expected_keys = [1, 2, 3, 4];
|
||||||
@ -180,14 +191,17 @@ test.cb("WPT idbobjectstore_put6.htm", (t) => {
|
|||||||
cursor.continue();
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
t.deepEqual(actual_keys, expected_keys);
|
t.deepEqual(actual_keys, expected_keys);
|
||||||
t.end();
|
resolve();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - autoIncrement and out-of-line keys
|
// IDBObjectStore.put() - autoIncrement and out-of-line keys
|
||||||
test.cb("WPT idbobjectstore_put7.htm", (t) => {
|
test("WPT idbobjectstore_put7.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { property: "data" },
|
record = { property: "data" },
|
||||||
expected_keys = [1, 2, 3, 4];
|
expected_keys = [1, 2, 3, 4];
|
||||||
@ -215,14 +229,16 @@ test.cb("WPT idbobjectstore_put7.htm", (t) => {
|
|||||||
cursor.continue();
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
t.deepEqual(actual_keys, expected_keys);
|
t.deepEqual(actual_keys, expected_keys);
|
||||||
t.end();
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - object store has autoIncrement:true and the key path is an object attribute
|
// IDBObjectStore.put() - object store has autoIncrement:true and the key path is an object attribute
|
||||||
test.cb("WPT idbobjectstore_put8.htm", (t) => {
|
test("WPT idbobjectstore_put8.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { property: "data" },
|
record = { property: "data" },
|
||||||
expected_keys = [1, 2, 3, 4];
|
expected_keys = [1, 2, 3, 4];
|
||||||
@ -253,14 +269,17 @@ test.cb("WPT idbobjectstore_put8.htm", (t) => {
|
|||||||
cursor.continue();
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
t.deepEqual(actual_keys, expected_keys);
|
t.deepEqual(actual_keys, expected_keys);
|
||||||
t.end();
|
resolve();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//IDBObjectStore.put() - Attempt to put a record that does not meet the constraints of an object store's inline key requirements
|
//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) => {
|
test("WPT idbobjectstore_put9.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var record = { key: 1, property: "data" };
|
var record = { key: 1, property: "data" };
|
||||||
|
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
@ -277,12 +296,14 @@ test.cb("WPT idbobjectstore_put9.htm", (t) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
t.deepEqual(rq, undefined);
|
t.deepEqual(rq, undefined);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//IDBObjectStore.put() - Attempt to call 'put' without an key parameter when the object store uses out-of-line keys
|
//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) => {
|
test("WPT idbobjectstore_put10.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { property: "data" };
|
record = { property: "data" };
|
||||||
|
|
||||||
@ -301,12 +322,14 @@ test.cb("WPT idbobjectstore_put10.htm", (t) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
t.deepEqual(rq, undefined);
|
t.deepEqual(rq, undefined);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - Attempt to put a record where the record's key does not meet the constraints of a valid key
|
// 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) => {
|
test("WPT idbobjectstore_put11.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { key: { value: 1 }, property: "data" };
|
record = { key: { value: 1 }, property: "data" };
|
||||||
|
|
||||||
@ -325,12 +348,14 @@ test.cb("WPT idbobjectstore_put11.htm", (t) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
t.deepEqual(rq, undefined);
|
t.deepEqual(rq, undefined);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - Attempt to put a record where the record's in-line key is not defined
|
// IDBObjectStore.put() - Attempt to put a record where the record's in-line key is not defined
|
||||||
test.cb("WPT idbobjectstore_put12.htm", (t) => {
|
test("WPT idbobjectstore_put12.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { property: "data" };
|
record = { property: "data" };
|
||||||
|
|
||||||
@ -349,12 +374,14 @@ test.cb("WPT idbobjectstore_put12.htm", (t) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
t.deepEqual(rq, undefined);
|
t.deepEqual(rq, undefined);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - Attempt to put a record where the out of line key provided does not meet the constraints of a valid key
|
// 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) => {
|
test("WPT idbobjectstore_put13.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { property: "data" };
|
record = { property: "data" };
|
||||||
|
|
||||||
@ -375,12 +402,14 @@ test.cb("WPT idbobjectstore_put13.htm", (t) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
t.deepEqual(rq, undefined);
|
t.deepEqual(rq, undefined);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - Put a record where a value being indexed does not meet the constraints of a valid key
|
// 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) => {
|
test("WPT idbobjectstore_put14.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any,
|
var db: any,
|
||||||
record = { key: 1, indexedProperty: { property: "data" } };
|
record = { key: 1, indexedProperty: { property: "data" } };
|
||||||
|
|
||||||
@ -397,13 +426,15 @@ test.cb("WPT idbobjectstore_put14.htm", (t) => {
|
|||||||
|
|
||||||
t.true(rq instanceof BridgeIDBRequest);
|
t.true(rq instanceof BridgeIDBRequest);
|
||||||
rq.onsuccess = function () {
|
rq.onsuccess = function () {
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - If the transaction this IDBObjectStore belongs to has its mode set to readonly, throw ReadOnlyError
|
// IDBObjectStore.put() - If the transaction this IDBObjectStore belongs to has its mode set to readonly, throw ReadOnlyError
|
||||||
test.cb("WPT idbobjectstore_put15.htm", (t) => {
|
test("WPT idbobjectstore_put15.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any;
|
var db: any;
|
||||||
|
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
@ -423,12 +454,14 @@ test.cb("WPT idbobjectstore_put15.htm", (t) => {
|
|||||||
name: "ReadOnlyError",
|
name: "ReadOnlyError",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// IDBObjectStore.put() - If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError
|
// 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) => {
|
test("WPT idbobjectstore_put16.htm", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
var db: any, ostore: any;
|
var db: any, ostore: any;
|
||||||
|
|
||||||
var open_rq = createdb(t);
|
var open_rq = createdb(t);
|
||||||
@ -444,6 +477,7 @@ test.cb("WPT idbobjectstore_put16.htm", (t) => {
|
|||||||
name: "InvalidStateError",
|
name: "InvalidStateError",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
createDatabase,
|
createDatabase,
|
||||||
createNotBooksStore,
|
createNotBooksStore,
|
||||||
migrateDatabase,
|
migrateDatabase,
|
||||||
} from "./wptsupport";
|
} from "./wptsupport.js";
|
||||||
|
|
||||||
// IndexedDB: object store renaming support
|
// IndexedDB: object store renaming support
|
||||||
// IndexedDB object store rename in new transaction
|
// IndexedDB object store rename in new transaction
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { createdb } from "./wptsupport";
|
import { createdb } from "./wptsupport.js";
|
||||||
|
|
||||||
// IDBTransaction - complete event
|
// IDBTransaction - complete event
|
||||||
test("WPT idbtransaction-oncomplete.htm", async (t) => {
|
test("WPT idbtransaction-oncomplete.htm", async (t) => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import test from "ava";
|
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) => {
|
test("WPT test keypath.htm", async (t) => {
|
||||||
function keypath(
|
function keypath(
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { BridgeIDBRequest } from "..";
|
import { EventTarget } from "../idbtypes.js";
|
||||||
import { EventTarget, IDBDatabase } from "../idbtypes";
|
import { createdb } from "./wptsupport.js";
|
||||||
import { createdb } from "./wptsupport";
|
|
||||||
|
|
||||||
// Bubbling and capturing of request events
|
// Bubbling and capturing of request events
|
||||||
test("WPT request_bubble-and-capture.htm", async (t) => {
|
test("WPT request_bubble-and-capture.htm", async (t) => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { createdb } from "./wptsupport";
|
import { createdb } from "./wptsupport.js";
|
||||||
|
|
||||||
// Transactions have a request queue
|
// Transactions have a request queue
|
||||||
test("transaction-requestqueue.htm", async (t) => {
|
test("transaction-requestqueue.htm", async (t) => {
|
||||||
@ -72,7 +72,7 @@ test("transaction-requestqueue.htm", async (t) => {
|
|||||||
"os2: 1",
|
"os2: 1",
|
||||||
"os2: 1",
|
"os2: 1",
|
||||||
"os1: 2",
|
"os1: 2",
|
||||||
],
|
] as any,
|
||||||
"transaction keys",
|
"transaction keys",
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ test("transaction-requestqueue.htm", async (t) => {
|
|||||||
"os3: 1",
|
"os3: 1",
|
||||||
"os1: 2",
|
"os1: 2",
|
||||||
"os4: 5",
|
"os4: 5",
|
||||||
],
|
] as any,
|
||||||
"transaction 2 keys",
|
"transaction 2 keys",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { IDBVersionChangeEvent } from "../idbtypes";
|
import { IDBVersionChangeEvent } from "../idbtypes.js";
|
||||||
import { createdb } from "./wptsupport";
|
import { createdb } from "./wptsupport.js";
|
||||||
|
|
||||||
test.cb("WPT test value.htm, array", (t) => {
|
test("WPT test value.htm, array", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
const value = new Array();
|
const value = new Array();
|
||||||
const _instanceof = Array;
|
const _instanceof = Array;
|
||||||
|
|
||||||
@ -17,13 +18,15 @@ test.cb("WPT test value.htm, array", (t) => {
|
|||||||
.objectStore("store")
|
.objectStore("store")
|
||||||
.get(1).onsuccess = (e: any) => {
|
.get(1).onsuccess = (e: any) => {
|
||||||
t.assert(e.target.result instanceof _instanceof, "instanceof");
|
t.assert(e.target.result instanceof _instanceof, "instanceof");
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.cb("WPT test value.htm, date", (t) => {
|
test("WPT test value.htm, date", (t) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
const value = new Date();
|
const value = new Date();
|
||||||
const _instanceof = Date;
|
const _instanceof = Date;
|
||||||
|
|
||||||
@ -40,8 +43,9 @@ test.cb("WPT test value.htm, date", (t) => {
|
|||||||
console.log("target", e.target);
|
console.log("target", e.target);
|
||||||
console.log("result", e.target.result);
|
console.log("result", e.target.result);
|
||||||
t.assert(e.target.result instanceof _instanceof, "instanceof");
|
t.assert(e.target.result instanceof _instanceof, "instanceof");
|
||||||
t.end();
|
resolve();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import test, { ExecutionContext } from "ava";
|
import { ExecutionContext } from "ava";
|
||||||
import { BridgeIDBFactory, BridgeIDBRequest } from "..";
|
import { BridgeIDBFactory, BridgeIDBRequest } from "../bridge-idb.js";
|
||||||
import {
|
import {
|
||||||
IDBDatabase,
|
IDBDatabase,
|
||||||
IDBIndex,
|
IDBIndex,
|
||||||
@ -7,10 +7,9 @@ import {
|
|||||||
IDBOpenDBRequest,
|
IDBOpenDBRequest,
|
||||||
IDBRequest,
|
IDBRequest,
|
||||||
IDBTransaction,
|
IDBTransaction,
|
||||||
IDBTransactionMode,
|
} from "../idbtypes.js";
|
||||||
} from "../idbtypes";
|
import { MemoryBackend } from "../MemoryBackend.js";
|
||||||
import { MemoryBackend } from "../MemoryBackend";
|
import { compareKeys } from "../util/cmp.js";
|
||||||
import { compareKeys } from "../util/cmp";
|
|
||||||
|
|
||||||
BridgeIDBFactory.enableTracing = true;
|
BridgeIDBFactory.enableTracing = true;
|
||||||
const backend = new MemoryBackend();
|
const backend = new MemoryBackend();
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
permissions and limitations under the License.
|
permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import FakeEventTarget from "./FakeEventTarget";
|
import FakeEventTarget from "./FakeEventTarget.js";
|
||||||
import { Event, EventTarget } from "../idbtypes";
|
import { Event, EventTarget } from "../idbtypes.js";
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export type EventType =
|
export type EventType =
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
permissions and limitations under the License.
|
permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { InvalidStateError } from "./errors";
|
import { InvalidStateError } from "./errors.js";
|
||||||
import FakeEvent, { EventType } from "./FakeEvent";
|
import FakeEvent, { EventType } from "./FakeEvent.js";
|
||||||
import {
|
import {
|
||||||
EventTarget,
|
EventTarget,
|
||||||
Event,
|
Event,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { canInjectKey } from "./canInjectKey";
|
import { canInjectKey } from "./canInjectKey.js";
|
||||||
|
|
||||||
test("canInjectKey", (t) => {
|
test("canInjectKey", (t) => {
|
||||||
t.false(canInjectKey("foo", null));
|
t.false(canInjectKey("foo", null));
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
permissions and limitations under the License.
|
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.
|
* Check that a key could be injected into a value.
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
permissions and limitations under the License.
|
permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DataError } from "./errors";
|
import { DataError } from "./errors.js";
|
||||||
import { valueToKey } from "./valueToKey";
|
import { valueToKey } from "./valueToKey.js";
|
||||||
|
|
||||||
const getType = (x: any) => {
|
const getType = (x: any) => {
|
||||||
if (typeof x === "number") {
|
if (typeof x === "number") {
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
permissions and limitations under the License.
|
permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IDBKeyPath, IDBValidKey } from "../idbtypes";
|
import { IDBKeyPath, IDBValidKey } from "../idbtypes.js";
|
||||||
import { valueToKey } from "./valueToKey";
|
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
|
// 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) => {
|
export const extractKey = (keyPath: IDBKeyPath | IDBKeyPath[], value: any) => {
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DOMStringList } from "../idbtypes";
|
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export interface FakeDOMStringList extends Array<string> {
|
export interface FakeDOMStringList extends Array<string> {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { getIndexKeys } from "./getIndexKeys";
|
import { getIndexKeys } from "./getIndexKeys.js";
|
||||||
|
|
||||||
test("basics", (t) => {
|
test("basics", (t) => {
|
||||||
t.deepEqual(getIndexKeys({ foo: 42 }, "foo", false), [42]);
|
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 }, "foo", true), [42]);
|
||||||
t.deepEqual(getIndexKeys({ foo: 42, bar: 10 }, ["foo", "bar"], true), [
|
t.deepEqual(
|
||||||
42,
|
getIndexKeys({ foo: 42, bar: 10 }, ["foo", "bar"], true),
|
||||||
10,
|
[42, 10],
|
||||||
]);
|
);
|
||||||
t.deepEqual(getIndexKeys({ foo: 42, bar: 10 }, ["foo", "bar"], false), [
|
t.deepEqual(getIndexKeys({ foo: 42, bar: 10 }, ["foo", "bar"], false), [
|
||||||
[42, 10],
|
[42, 10],
|
||||||
]);
|
]);
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
permissions and limitations under the License.
|
permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IDBKeyPath, IDBValidKey } from "../idbtypes";
|
import { IDBKeyPath, IDBValidKey } from "../idbtypes.js";
|
||||||
import { extractKey } from "./extractKey";
|
import { extractKey } from "./extractKey.js";
|
||||||
import { valueToKey } from "./valueToKey";
|
import { valueToKey } from "./valueToKey.js";
|
||||||
|
|
||||||
export function getIndexKeys(
|
export function getIndexKeys(
|
||||||
value: any,
|
value: any,
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { makeStoreKeyValue } from "./makeStoreKeyValue";
|
import { makeStoreKeyValue } from "./makeStoreKeyValue.js";
|
||||||
|
|
||||||
test("basics", (t) => {
|
test("basics", (t) => {
|
||||||
let result;
|
let result;
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
permissions and limitations under the License.
|
permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { extractKey } from "./extractKey";
|
import { extractKey } from "./extractKey.js";
|
||||||
import { DataCloneError, DataError } from "./errors";
|
import { DataCloneError, DataError } from "./errors.js";
|
||||||
import { valueToKey } from "./valueToKey";
|
import { valueToKey } from "./valueToKey.js";
|
||||||
import { structuredClone } from "./structuredClone";
|
import { structuredClone } from "./structuredClone.js";
|
||||||
import { IDBKeyPath, IDBValidKey } from "../idbtypes";
|
import { IDBKeyPath, IDBValidKey } from "../idbtypes.js";
|
||||||
|
|
||||||
export interface StoreKeyResult {
|
export interface StoreKeyResult {
|
||||||
updatedKeyGenerator: number;
|
updatedKeyGenerator: number;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import test, { ExecutionContext } from "ava";
|
import test, { ExecutionContext } from "ava";
|
||||||
import { structuredClone } from "./structuredClone";
|
import { structuredClone } from "./structuredClone.js";
|
||||||
|
|
||||||
function checkClone(t: ExecutionContext, x: any): void {
|
function checkClone(t: ExecutionContext, x: any): void {
|
||||||
t.deepEqual(structuredClone(x), x);
|
t.deepEqual(structuredClone(x), x);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
permissions and limitations under the License.
|
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
|
// http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#dfn-valid-key-path
|
||||||
export const validateKeyPath = (
|
export const validateKeyPath = (
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
permissions and limitations under the License.
|
permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IDBValidKey } from "..";
|
import { IDBValidKey } from "../idbtypes.js";
|
||||||
import { DataError } from "./errors";
|
import { DataError } from "./errors.js";
|
||||||
|
|
||||||
// https://www.w3.org/TR/IndexedDB-2/#convert-a-value-to-a-key
|
// https://www.w3.org/TR/IndexedDB-2/#convert-a-value-to-a-key
|
||||||
export function valueToKey(
|
export function valueToKey(
|
||||||
|
@ -125,27 +125,27 @@ importers:
|
|||||||
'@rollup/plugin-commonjs': ^21.0.1
|
'@rollup/plugin-commonjs': ^21.0.1
|
||||||
'@rollup/plugin-json': ^4.1.0
|
'@rollup/plugin-json': ^4.1.0
|
||||||
'@rollup/plugin-node-resolve': ^13.1.3
|
'@rollup/plugin-node-resolve': ^13.1.3
|
||||||
'@types/node': ^17.0.8
|
'@types/node': ^17.0.17
|
||||||
ava: ^3.15.0
|
ava: ^4.0.1
|
||||||
esm: ^3.2.25
|
esm: ^3.2.25
|
||||||
prettier: ^2.2.1
|
prettier: ^2.5.1
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
rollup: ^2.63.0
|
rollup: ^2.67.2
|
||||||
tslib: ^2.3.1
|
tslib: ^2.3.1
|
||||||
typescript: ^4.5.4
|
typescript: ^4.5.5
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib: 2.3.1
|
tslib: 2.3.1
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@rollup/plugin-commonjs': 21.0.1_rollup@2.63.0
|
'@rollup/plugin-commonjs': 21.0.1_rollup@2.67.2
|
||||||
'@rollup/plugin-json': 4.1.0_rollup@2.63.0
|
'@rollup/plugin-json': 4.1.0_rollup@2.67.2
|
||||||
'@rollup/plugin-node-resolve': 13.1.3_rollup@2.63.0
|
'@rollup/plugin-node-resolve': 13.1.3_rollup@2.67.2
|
||||||
'@types/node': 17.0.8
|
'@types/node': 17.0.17
|
||||||
ava: 3.15.0
|
ava: 4.0.1
|
||||||
esm: 3.2.25
|
esm: 3.2.25
|
||||||
prettier: 2.2.1
|
prettier: 2.5.1
|
||||||
rimraf: 3.0.2
|
rimraf: 3.0.2
|
||||||
rollup: 2.63.0
|
rollup: 2.67.2
|
||||||
typescript: 4.5.4
|
typescript: 4.5.5
|
||||||
|
|
||||||
packages/pogen:
|
packages/pogen:
|
||||||
specifiers:
|
specifiers:
|
||||||
@ -10125,7 +10125,6 @@ packages:
|
|||||||
|
|
||||||
/@types/node/17.0.17:
|
/@types/node/17.0.17:
|
||||||
resolution: {integrity: sha512-e8PUNQy1HgJGV3iU/Bp2+D/DXh3PYeyli8LgIwsQcs1Ar1LoaWHSIT6Rw+H2rNJmiq6SNWiDytfx8+gYj7wDHw==}
|
resolution: {integrity: sha512-e8PUNQy1HgJGV3iU/Bp2+D/DXh3PYeyli8LgIwsQcs1Ar1LoaWHSIT6Rw+H2rNJmiq6SNWiDytfx8+gYj7wDHw==}
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@types/node/17.0.8:
|
/@types/node/17.0.8:
|
||||||
resolution: {integrity: sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==}
|
resolution: {integrity: sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==}
|
||||||
@ -10189,7 +10188,7 @@ packages:
|
|||||||
/@types/resolve/1.17.1:
|
/@types/resolve/1.17.1:
|
||||||
resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==}
|
resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 17.0.8
|
'@types/node': 17.0.17
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/scheduler/0.16.2:
|
/@types/scheduler/0.16.2:
|
||||||
|
Loading…
Reference in New Issue
Block a user