OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>IndexedDB: Unprevented errors trigger window.onerror</title> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script> |
| 6 |
| 7 var t = async_test('Unprevented error on request causes window.onerror to fire')
; |
| 8 t.step(function() { |
| 9 var onerrorCalled = false; |
| 10 var dbName = location.pathname; |
| 11 var deleteRequest = indexedDB.deleteDatabase(dbName); |
| 12 deleteRequest.onsuccess = t.step_func(function() { |
| 13 var openRequest = indexedDB.open(dbName); |
| 14 openRequest.onupgradeneeded = t.step_func(function() { |
| 15 var db = openRequest.result; |
| 16 var store = db.createObjectStore('store'); |
| 17 }); |
| 18 openRequest.onsuccess = t.step_func(function() { |
| 19 var db = openRequest.result; |
| 20 var tx = db.transaction('store', 'readwrite'); |
| 21 var store = tx.objectStore('store'); |
| 22 store.add({}, 'k1'); |
| 23 store.add({}, 'k1'); |
| 24 tx.oncomplete = t.step_func(function() { |
| 25 assert_unreached('transaction should have aborted'); |
| 26 }); |
| 27 tx.onabort = t.step_func(function() { |
| 28 assert_true(onerrorCalled, 'onerror should have been called'); |
| 29 t.done(); |
| 30 }); |
| 31 }); |
| 32 }); |
| 33 |
| 34 window.onerror = t.step_func(function(message, url, line, column) { |
| 35 onerrorCalled = true; |
| 36 assert_equals(message, 'ConstraintError: Key already exists in the objec
t store.'); |
| 37 assert_equals(line, 23); |
| 38 assert_equals(column, 19); |
| 39 }); |
| 40 }); |
| 41 |
| 42 </script> |
OLD | NEW |