diff options
Diffstat (limited to 'packages/idb-bridge/src/idb-wpt-ported/abort-in-initial-upgradeneeded.test.ts')
-rw-r--r-- | packages/idb-bridge/src/idb-wpt-ported/abort-in-initial-upgradeneeded.test.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/packages/idb-bridge/src/idb-wpt-ported/abort-in-initial-upgradeneeded.test.ts b/packages/idb-bridge/src/idb-wpt-ported/abort-in-initial-upgradeneeded.test.ts new file mode 100644 index 000000000..da9ed2632 --- /dev/null +++ b/packages/idb-bridge/src/idb-wpt-ported/abort-in-initial-upgradeneeded.test.ts @@ -0,0 +1,34 @@ +import test from "ava"; +import { createdb } from "./wptsupport"; + +test("WPT test abort-in-initial-upgradeneeded.htm", async (t) => { + await new Promise<void>((resolve, reject) => { + var db: any; + var open_rq = createdb(t, undefined, 2); + + open_rq.onupgradeneeded = function (e) { + const tgt = e.target as any; + db = tgt.result; + t.assert(db.version === 2); + var transaction = tgt.transaction; + transaction.oncomplete = () => t.fail("unexpected transaction.complete"); + transaction.onabort = function (e: any) { + console.log(`version: ${e.target.db.version}`); + t.deepEqual(e.target.db.version, 0); + }; + db.onabort = function () {}; + transaction.abort(); + }; + + open_rq.onerror = function (e) { + const tgt = e.target as any; + t.deepEqual(open_rq, e.target); + t.deepEqual(tgt.result, undefined); + t.deepEqual(tgt.error.name, "AbortError"); + console.log(`version (onerror): ${db.version}`); + t.deepEqual(db.version, 0); + t.deepEqual(open_rq.transaction, null); + resolve(); + }; + }); +}); |