Revision e57d2a1ed5681d3ea058ea3956583200d2efe9aa authored by Eric Willigers on 15 April 2018, 11:01:13 UTC, committed by Chromium WPT Sync on 15 April 2018, 11:01:13 UTC
Intent: https://groups.google.com/a/chromium.org/d/msg/blink-dev/oBKMVCOX1sY/BLsXXiukAgAJ BUG=804187 Change-Id: I94e79b2b426250c521d0ebae1492571fde078f31 Reviewed-on: https://chromium-review.googlesource.com/1013459 Reviewed-by: Emil A Eklund <eae@chromium.org> Commit-Queue: Eric Willigers <ericwilligers@chromium.org> Cr-Commit-Position: refs/heads/master@{#550915}
1 parent b3c7910
fire-upgradeneeded-event-exception.html
<!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=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');
func(t, open);
}, description);
}
fire_upgradeneeded_event_test((t, open) => {
let tx;
open.onupgradeneeded = () => {
tx = open.transaction;
throw Error();
};
open.onerror = t.step_func_done(() => {
assert_equals(tx.error.name, 'AbortError');
});
}, 'Exception in upgradeneeded handler');
fire_upgradeneeded_event_test((t, open) => {
let tx;
open.addEventListener('upgradeneeded', () => {
tx = open.transaction;
throw Error();
});
open.onerror = t.step_func_done(() => {
assert_equals(tx.error.name, 'AbortError');
});
}, 'Exception in upgradeneeded listener');
fire_upgradeneeded_event_test((t, open) => {
let tx;
open.addEventListener('upgradeneeded', () => {
// No-op.
});
open.addEventListener('upgradeneeded', () => {
tx = open.transaction;
throw Error();
});
open.onerror = t.step_func_done(() => {
assert_equals(tx.error.name, 'AbortError');
});
}, 'Exception in second upgradeneeded listener');
fire_upgradeneeded_event_test((t, open) => {
let tx;
let second_listener_called = false;
open.addEventListener('upgradeneeded', () => {
open.result.createObjectStore('s');
throw Error();
});
open.addEventListener('upgradeneeded', t.step_func(() => {
second_listener_called = true;
tx = open.transaction;
assert_true(is_transaction_active(tx, 's'),
'Transaction should be active until dispatch completes');
}));
open.onerror = t.step_func_done(() => {
assert_true(second_listener_called);
assert_equals(tx.error.name, 'AbortError');
});
}, 'Exception in first upgradeneeded listener, tx active in second');
</script>
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...