Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: LayoutTests/storage/indexeddb/resources/error-causes-abort-by-default.js

Issue 243523003: Fire window.onerror for uncaught IndexedDB errors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased and linkage fix Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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, testDefaultPreventedDoesNotAbort);
9 function prepareDatabase() 9 function prepareDatabase()
10 { 10 {
11 db = event.target.result; 11 db = event.target.result;
12 debug("setVersionSuccess():"); 12 debug("setVersionSuccess():");
13 self.trans = evalAndLog("trans = event.target.transaction"); 13 self.trans = evalAndLog("trans = event.target.transaction");
14 shouldBeNonNull("trans"); 14 shouldBeNonNull("trans");
15 trans.onabort = unexpectedAbortCallback; 15 trans.onabort = unexpectedAbortCallback;
16 evalAndLog("db.createObjectStore('storeName', null)"); 16 evalAndLog("db.createObjectStore('storeName', null)");
17 } 17 }
18 18
19 function addData() 19 function testDefaultPreventedDoesNotAbort()
20 { 20 {
21 debug("");
22 debug("Test: prevent the default event behavior prevents the transaction fro m aborting");
21 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')"); 23 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')");
22 evalAndLog("trans.onabort = unexpectedAbortCallback"); 24 evalAndLog("trans.onabort = unexpectedAbortCallback");
23 evalAndLog("trans.oncomplete = transactionCompleted"); 25 evalAndLog("trans.oncomplete = transactionCompleted");
24 store = evalAndLog("store = trans.objectStore('storeName')"); 26 store = evalAndLog("store = trans.objectStore('storeName')");
25 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); 27 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
26 request.onsuccess = addMore;
27 request.onerror = unexpectedErrorCallback; 28 request.onerror = unexpectedErrorCallback;
28 } 29 request.onsuccess = function() {
29 30 request = evalAndLog("event.target.source.add({x: 'value', y: 'zzz'}, 'k ey')");
30 function addMore() 31 request.onsuccess = unexpectedSuccessCallback;
31 { 32 request.addEventListener("error", preventTheDefault);
32 33 };
33 request = evalAndLog("event.target.source.add({x: 'value', y: 'zzz'}, 'key') ");
34 request.onsuccess = unexpectedSuccessCallback;
35 request.addEventListener("error", preventTheDefault);
36 } 34 }
37 35
38 function preventTheDefault() 36 function preventTheDefault()
39 { 37 {
40 evalAndLog("event.preventDefault()"); 38 evalAndLog("event.preventDefault()");
41 } 39 }
42 40
43 function transactionCompleted() 41 function transactionCompleted()
44 { 42 {
45 testPassed("Transaction completed"); 43 testPassed("Transaction completed");
44 testDefaultAllowedAborts();
45 }
46
47 function testDefaultAllowedAborts()
48 {
46 debug(""); 49 debug("");
47 debug(""); 50 debug("Test: allowing the default event behavior, which aborts the transacti on");
48 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')"); 51 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')");
49 evalAndLog("trans.onabort = transactionAborted1"); 52 evalAndLog("trans.onabort = transactionAborted1");
50 evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); 53 evalAndLog("trans.oncomplete = unexpectedCompleteCallback");
51 store = evalAndLog("store = trans.objectStore('storeName')"); 54 store = evalAndLog("store = trans.objectStore('storeName')");
52 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); 55 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
53 request.onsuccess = unexpectedSuccessCallback; 56 request.onsuccess = unexpectedSuccessCallback;
54 request.onerror = allowDefault; 57 request.onerror = allowDefault;
58 expectError();
55 } 59 }
56 60
57 function allowDefault() 61 function allowDefault()
58 { 62 {
59 debug("Doing nothing to prevent the default action..."); 63 debug("Doing nothing to prevent the default action...");
60 } 64 }
61 65
62 function transactionAborted1() 66 function transactionAborted1()
63 { 67 {
64 testPassed("Transaction aborted"); 68 testPassed("Transaction aborted");
69 testNoErrorHandlerAborts();
70 }
71
72 function testNoErrorHandlerAborts() {
65 debug(""); 73 debug("");
66 debug(""); 74 debug("Test: no error handler implicitly allows allowing the default event b ehavior, which aborts the transaction");
67 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')"); 75 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')");
68 evalAndLog("trans.onabort = transactionAborted2"); 76 evalAndLog("trans.onabort = transactionAborted2");
69 evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); 77 evalAndLog("trans.oncomplete = unexpectedCompleteCallback");
70 store = evalAndLog("store = trans.objectStore('storeName')"); 78 store = evalAndLog("store = trans.objectStore('storeName')");
71 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); 79 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
72 request.onsuccess = unexpectedSuccessCallback; 80 request.onsuccess = unexpectedSuccessCallback;
73 debug("Omitting an onerror handler"); 81 expectError();
82 debug("Omitting an onerror handler on request; transaction should abort");
74 } 83 }
75 84
76 function transactionAborted2() 85 function transactionAborted2()
77 { 86 {
78 testPassed("Transaction aborted"); 87 testPassed("Transaction aborted");
79 finishJSTest(); 88 finishJSTest();
80 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698