aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.test.ts (renamed from packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.ts)0
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbfactory-cmp.test.ts63
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts76
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbindex-get.test.ts (renamed from packages/idb-bridge/src/idb-wpt-ported/idbindex_get.test.ts)0
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add.test.ts (renamed from packages/idb-bridge/src/idb-wpt-ported/idbobjectstore_add.test.ts)0
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.test.ts (renamed from packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.ts)0
-rw-r--r--packages/idb-bridge/src/idb-wpt-ported/wptsupport.ts2
7 files changed, 140 insertions, 1 deletions
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.ts b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.test.ts
index 44a647dc8..44a647dc8 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-reused.test.ts
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbfactory-cmp.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbfactory-cmp.test.ts
new file mode 100644
index 000000000..c7a25a46b
--- /dev/null
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbfactory-cmp.test.ts
@@ -0,0 +1,63 @@
+import test from "ava";
+import { createdb, idbFactory } from "./wptsupport";
+
+test("WPT idbfactory-cmp*.html", async (t) => {
+ const indexedDB = idbFactory;
+ var greater = indexedDB.cmp(2, 1);
+ var equal = indexedDB.cmp(2, 2);
+ var less = indexedDB.cmp(1, 2);
+
+ t.deepEqual(greater, 1, "greater");
+ t.deepEqual(equal, 0, "equal");
+ t.deepEqual(less, -1, "less");
+
+ t.throws(
+ () => {
+ // @ts-expect-error
+ indexedDB.cmp();
+ },
+ { instanceOf: TypeError },
+ );
+
+ t.throws(
+ () => {
+ indexedDB.cmp(null, null);
+ },
+ { name: "DataError" },
+ );
+
+ t.throws(
+ () => {
+ indexedDB.cmp(1, null);
+ },
+ { name: "DataError" },
+ );
+
+ t.throws(
+ () => {
+ indexedDB.cmp(null, 1);
+ },
+ { name: "DataError" },
+ );
+
+ t.throws(
+ () => {
+ indexedDB.cmp(NaN, NaN);
+ },
+ { name: "DataError" },
+ );
+
+ t.throws(
+ () => {
+ indexedDB.cmp(1, NaN);
+ },
+ { name: "DataError" },
+ );
+
+ t.throws(
+ () => {
+ indexedDB.cmp(NaN, 1);
+ },
+ { name: "DataError" },
+ );
+});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts
new file mode 100644
index 000000000..68d58a162
--- /dev/null
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts
@@ -0,0 +1,76 @@
+import test from "ava";
+import { createdb, idbFactory } from "./wptsupport";
+
+// IDBFactory.open() - request has no source
+test("WPT idbfactory-open.htm", async (t) => {
+ await new Promise<void>((resolve, reject) => {
+ var open_rq = createdb(t, undefined, 9);
+
+ open_rq.onupgradeneeded = function (e) {};
+ open_rq.onsuccess = function (e: any) {
+ t.deepEqual(e.target.source, null, "source");
+ resolve();
+ };
+ });
+ t.pass();
+});
+
+// IDBFactory.open() - database 'name' and 'version' are correctly set
+test("WPT idbfactory-open2.htm", async (t) => {
+ await new Promise<void>((resolve, reject) => {
+ var database_name = __filename + "-database_name";
+ var open_rq = createdb(t, database_name, 13);
+
+ open_rq.onupgradeneeded = function (e) {};
+ open_rq.onsuccess = function (e: any) {
+ var db = e.target.result;
+ t.deepEqual(db.name, database_name, "db.name");
+ t.deepEqual(db.version, 13, "db.version");
+ resolve;
+ };
+ });
+ t.pass();
+});
+
+// IDBFactory.open() - no version opens current database
+test("WPT idbfactory-open3.htm", async (t) => {
+ const indexedDB = idbFactory;
+ await new Promise<void>((resolve, reject) => {
+ var open_rq = createdb(t, undefined, 13);
+ var did_upgrade = false;
+
+ open_rq.onupgradeneeded = function () {};
+ open_rq.onsuccess = function (e: any) {
+ var db = e.target.result;
+ db.close();
+
+ var open_rq2 = indexedDB.open(db.name);
+ open_rq2.onsuccess = function (e: any) {
+ t.deepEqual(e.target.result.version, 13, "db.version");
+ e.target.result.close();
+ resolve();
+ };
+ open_rq2.onupgradeneeded = () => t.fail("Unexpected upgradeneeded");
+ open_rq2.onerror = () => t.fail("Unexpected error");
+ };
+ });
+ t.pass();
+});
+
+
+// IDBFactory.open() - new database has default version
+test("WPT idbfactory-open4.htm", async (t) => {
+ const indexedDB = idbFactory;
+ await new Promise<void>((resolve, reject) => {
+ var open_rq = createdb(t, __filename + '-database_name');
+
+ open_rq.onupgradeneeded = function(e: any) {
+ t.deepEqual(e.target.result.version, 1, "db.version");
+ };
+ open_rq.onsuccess = function(e: any) {
+ t.deepEqual(e.target.result.version, 1, "db.version");
+ resolve();
+ };
+ });
+ t.pass();
+});
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbindex_get.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbindex-get.test.ts
index 7601faada..7601faada 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbindex_get.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbindex-get.test.ts
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore_add.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add.test.ts
index b8fdb5ac3..b8fdb5ac3 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore_add.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbobjectstore-add.test.ts
diff --git a/packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.ts b/packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.test.ts
index edf98eb54..edf98eb54 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/transaction-requestqueue.test.ts
diff --git a/packages/idb-bridge/src/idb-wpt-ported/wptsupport.ts b/packages/idb-bridge/src/idb-wpt-ported/wptsupport.ts
index 1c25bb8e3..2d52ea074 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/wptsupport.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/wptsupport.ts
@@ -15,7 +15,7 @@ import { compareKeys } from "../util/cmp";
BridgeIDBFactory.enableTracing = true;
const backend = new MemoryBackend();
backend.enableTracing = true;
-const idbFactory = new BridgeIDBFactory(backend);
+export const idbFactory = new BridgeIDBFactory(backend);
const self = {
indexedDB: idbFactory,