OLD | NEW |
1 if (this.importScripts) { | 1 if (this.importScripts) { |
2 importScripts('../../../resources/js-test.js'); | 2 importScripts('../../../resources/js-test.js'); |
3 importScripts('shared.js'); | 3 importScripts('shared.js'); |
4 } | 4 } |
5 | 5 |
6 description("Verify that a transaction with an error aborts unless preventDefaul
t() is called."); | 6 description("Verify that a transaction with an error aborts unless preventDefaul
t() is called."); |
7 | 7 |
8 indexedDBTest(prepareDatabase, addData); | 8 indexedDBTest(prepareDatabase, addData); |
9 function prepareDatabase() | 9 function prepareDatabase() |
10 { | 10 { |
(...skipping 11 matching lines...) Expand all Loading... |
22 evalAndLog("trans.onabort = unexpectedAbortCallback"); | 22 evalAndLog("trans.onabort = unexpectedAbortCallback"); |
23 evalAndLog("trans.oncomplete = transactionCompleted"); | 23 evalAndLog("trans.oncomplete = transactionCompleted"); |
24 store = evalAndLog("store = trans.objectStore('storeName')"); | 24 store = evalAndLog("store = trans.objectStore('storeName')"); |
25 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); | 25 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); |
26 request.onsuccess = addMore; | 26 request.onsuccess = addMore; |
27 request.onerror = unexpectedErrorCallback; | 27 request.onerror = unexpectedErrorCallback; |
28 } | 28 } |
29 | 29 |
30 function addMore() | 30 function addMore() |
31 { | 31 { |
32 | |
33 request = evalAndLog("event.target.source.add({x: 'value', y: 'zzz'}, 'key')
"); | 32 request = evalAndLog("event.target.source.add({x: 'value', y: 'zzz'}, 'key')
"); |
34 request.onsuccess = unexpectedSuccessCallback; | 33 request.onsuccess = unexpectedSuccessCallback; |
35 request.addEventListener("error", preventTheDefault); | 34 request.addEventListener("error", preventTheDefault); |
36 } | 35 } |
37 | 36 |
38 function preventTheDefault() | 37 function preventTheDefault() |
39 { | 38 { |
40 evalAndLog("event.preventDefault()"); | 39 evalAndLog("event.preventDefault()"); |
41 } | 40 } |
42 | 41 |
43 function transactionCompleted() | 42 function transactionCompleted() |
44 { | 43 { |
45 testPassed("Transaction completed"); | 44 testPassed("Transaction completed"); |
46 debug(""); | 45 debug(""); |
47 debug(""); | 46 debug(""); |
48 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')"); | 47 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')"); |
49 evalAndLog("trans.onabort = transactionAborted1"); | 48 evalAndLog("trans.onabort = transactionAborted1"); |
50 evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); | 49 evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); |
51 store = evalAndLog("store = trans.objectStore('storeName')"); | 50 store = evalAndLog("store = trans.objectStore('storeName')"); |
52 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); | 51 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); |
53 request.onsuccess = unexpectedSuccessCallback; | 52 request.onsuccess = unexpectedSuccessCallback; |
54 request.onerror = allowDefault; | 53 request.onerror = allowDefault; |
| 54 expectError(); |
55 } | 55 } |
56 | 56 |
57 function allowDefault() | 57 function allowDefault() |
58 { | 58 { |
59 debug("Doing nothing to prevent the default action..."); | 59 debug("Doing nothing to prevent the default action..."); |
60 } | 60 } |
61 | 61 |
62 function transactionAborted1() | 62 function transactionAborted1() |
63 { | 63 { |
64 testPassed("Transaction aborted"); | 64 testPassed("Transaction aborted"); |
65 debug(""); | 65 debug(""); |
66 debug(""); | 66 debug(""); |
67 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')"); | 67 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')"); |
68 evalAndLog("trans.onabort = transactionAborted2"); | 68 evalAndLog("trans.onabort = transactionAborted2"); |
69 evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); | 69 evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); |
70 store = evalAndLog("store = trans.objectStore('storeName')"); | 70 store = evalAndLog("store = trans.objectStore('storeName')"); |
71 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); | 71 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); |
72 request.onsuccess = unexpectedSuccessCallback; | 72 request.onsuccess = unexpectedSuccessCallback; |
| 73 expectError(); |
73 debug("Omitting an onerror handler"); | 74 debug("Omitting an onerror handler"); |
74 } | 75 } |
75 | 76 |
76 function transactionAborted2() | 77 function transactionAborted2() |
77 { | 78 { |
78 testPassed("Transaction aborted"); | 79 testPassed("Transaction aborted"); |
79 finishJSTest(); | 80 finishJSTest(); |
80 } | 81 } |
OLD | NEW |