<!DOCTYPE html>
<title>IndexedDB: UpgradeNeeded Tests</title>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script>
(function() {
setup({ allow_uncaught_exception: true });
var order = [];
var description = 'Throw an exception in version change oncomplete handler ';
async_test(function(t) {
var dbName = 'db' + self.location.pathname + '-' + description;
var delete_request = indexedDB.deleteDatabase(dbName);
delete_request.onerror = t.unreached_func('deleteDatabase should not fail');
delete_request.onsuccess = t.step_func(function() {
var open_request = indexedDB.open(dbName);
open_request.onupgradeneeded = t.step_func(function() {
order.push('Upgrade');
var tx = open_request.transaction;
tx.oncomplete = function() {
order.push('Exception');
throw new Error('FakeException');
};
tx.onerror = t.unreached_func('error on transaction');
tx.onabort = t.unreached_func('aborting transaction');
});
open_request.onsuccess = t.step_func(function() {
assert_array_equals(order, ['Upgrade', 'Exception']);
t.done();
});
open_request.onerror = t.unreached_func('open failed');
});
}, description);
}());
</script>