summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/test/unit/test_setVersion_throw.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/indexedDB/test/unit/test_setVersion_throw.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/indexedDB/test/unit/test_setVersion_throw.js')
-rw-r--r--dom/indexedDB/test/unit/test_setVersion_throw.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/dom/indexedDB/test/unit/test_setVersion_throw.js b/dom/indexedDB/test/unit/test_setVersion_throw.js
new file mode 100644
index 0000000000..2706c2c2a4
--- /dev/null
+++ b/dom/indexedDB/test/unit/test_setVersion_throw.js
@@ -0,0 +1,54 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/* exported testGenerator */
+var testGenerator = testSteps();
+
+function* testSteps() {
+ const name = this.window ? window.location.pathname : "test_setVersion_throw";
+
+ // This test requires two databases. The first needs to be a low version
+ // number that gets closed when a second higher version number database is
+ // created. Then the upgradeneeded event for the second database throws an
+ // exception and triggers an abort/close.
+
+ let request = indexedDB.open(name, 1);
+ request.onerror = errorHandler;
+ request.onsuccess = grabEventAndContinueHandler;
+ request.onupgradeneeded = function (event) {
+ info("Got upgradeneeded event for db 1");
+ };
+ let event = yield undefined;
+
+ is(event.type, "success", "Got success event for db 1");
+
+ let db = event.target.result;
+ db.onversionchange = function (event) {
+ info("Got versionchange event for db 1");
+ event.target.close();
+ };
+
+ executeSoon(continueToNextStepSync);
+ yield undefined;
+
+ request = indexedDB.open(name, 2);
+ request.onerror = grabEventAndContinueHandler;
+ request.onsuccess = unexpectedSuccessHandler;
+ request.onupgradeneeded = function (event) {
+ info("Got upgradeneeded event for db 2");
+ expectUncaughtException(true);
+ // eslint-disable-next-line no-undef
+ trigger_js_exception_by_calling_a_nonexistent_function();
+ };
+ event = yield undefined;
+
+ event.preventDefault();
+
+ is(event.type, "error", "Got an error event for db 2");
+ ok(event.target.error instanceof DOMException, "Request has a DOMException");
+ is(event.target.error.name, "AbortError", "Request has AbortError");
+
+ finishTest();
+}