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