summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/fire-upgradeneeded-event-exception.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/IndexedDB/fire-upgradeneeded-event-exception.html
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testing/web-platform/tests/IndexedDB/fire-upgradeneeded-event-exception.html82
1 files changed, 82 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/fire-upgradeneeded-event-exception.html b/testing/web-platform/tests/IndexedDB/fire-upgradeneeded-event-exception.html
new file mode 100644
index 0000000000..7160dbdfc7
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/fire-upgradeneeded-event-exception.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Fire upgradeneeded event - Exception thrown</title>
+<link rel="help" href="https://w3c.github.io/IndexedDB/#fire-a-version-change-event">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=resources/support.js></script>
+<script>
+setup({allow_uncaught_exception:true});
+
+function fire_upgradeneeded_event_test(func, description) {
+ async_test(t => {
+ const dbname = document.location + '-' + t.name;
+ const del = indexedDB.deleteDatabase(dbname);
+ del.onerror = t.unreached_func('deleteDatabase should succeed');
+ const open = indexedDB.open(dbname, 1);
+ open.onsuccess = t.unreached_func('open should fail');
+ let tx;
+ open.addEventListener('upgradeneeded', () => {
+ tx = open.transaction;
+ });
+ func(t, open);
+ open.addEventListener('error', t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ }));
+ }, description);
+}
+
+fire_upgradeneeded_event_test((t, open) => {
+ open.onupgradeneeded = () => {
+ throw Error();
+ };
+}, 'Exception in upgradeneeded handler');
+
+fire_upgradeneeded_event_test((t, open) => {
+ open.addEventListener('upgradeneeded', () => {
+ throw Error();
+ });
+}, 'Exception in upgradeneeded listener');
+
+fire_upgradeneeded_event_test((t, open) => {
+ open.addEventListener('upgradeneeded', {
+ get handleEvent() {
+ throw new Error();
+ },
+ });
+}, 'Exception in upgradeneeded "handleEvent" lookup');
+
+fire_upgradeneeded_event_test((t, open) => {
+ open.addEventListener('upgradeneeded', {
+ get handleEvent() {
+ return 10;
+ },
+ });
+}, 'Exception in upgradeneeded due to non-callable "handleEvent"');
+
+fire_upgradeneeded_event_test((t, open) => {
+ open.addEventListener('upgradeneeded', () => {
+ // No-op.
+ });
+ open.addEventListener('upgradeneeded', () => {
+ throw Error();
+ });
+}, 'Exception in second upgradeneeded listener');
+
+fire_upgradeneeded_event_test((t, open) => {
+ let second_listener_called = false;
+ open.addEventListener('upgradeneeded', () => {
+ open.result.createObjectStore('s');
+ throw Error();
+ });
+ open.addEventListener('upgradeneeded', t.step_func(() => {
+ second_listener_called = true;
+ assert_true(is_transaction_active(open.transaction, 's'),
+ 'Transaction should be active until dispatch completes');
+ }));
+ open.addEventListener('error', t.step_func(() => {
+ assert_true(second_listener_called);
+ }));
+}, 'Exception in first upgradeneeded listener, tx active in second');
+
+</script>