Index: third_party/WebKit/LayoutTests/storage/indexeddb/resources/error-causes-abort-by-default.js |
diff --git a/third_party/WebKit/LayoutTests/storage/indexeddb/resources/error-causes-abort-by-default.js b/third_party/WebKit/LayoutTests/storage/indexeddb/resources/error-causes-abort-by-default.js |
index e4126506ae31388a1dfe5fac1651d1c25fbcff99..c1edcb7b8ce96a487cb6644d9d5706e2967c1f84 100644 |
--- a/third_party/WebKit/LayoutTests/storage/indexeddb/resources/error-causes-abort-by-default.js |
+++ b/third_party/WebKit/LayoutTests/storage/indexeddb/resources/error-causes-abort-by-default.js |
@@ -5,7 +5,7 @@ if (this.importScripts) { |
description("Verify that a transaction with an error aborts unless preventDefault() is called."); |
-indexedDBTest(prepareDatabase, addData); |
+indexedDBTest(prepareDatabase, testDefaultPreventedDoesNotAbort); |
function prepareDatabase() |
{ |
db = event.target.result; |
@@ -16,23 +16,21 @@ function prepareDatabase() |
evalAndLog("db.createObjectStore('storeName', null)"); |
} |
-function addData() |
+function testDefaultPreventedDoesNotAbort() |
{ |
+ debug(""); |
+ debug("Test: prevent the default event behavior prevents the transaction from aborting"); |
trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')"); |
evalAndLog("trans.onabort = unexpectedAbortCallback"); |
evalAndLog("trans.oncomplete = transactionCompleted"); |
store = evalAndLog("store = trans.objectStore('storeName')"); |
request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); |
- request.onsuccess = addMore; |
request.onerror = unexpectedErrorCallback; |
-} |
- |
-function addMore() |
-{ |
- |
- request = evalAndLog("event.target.source.add({x: 'value', y: 'zzz'}, 'key')"); |
- request.onsuccess = unexpectedSuccessCallback; |
- request.addEventListener("error", preventTheDefault); |
+ request.onsuccess = function() { |
+ request = evalAndLog("event.target.source.add({x: 'value', y: 'zzz'}, 'key')"); |
+ request.onsuccess = unexpectedSuccessCallback; |
+ request.addEventListener("error", preventTheDefault); |
+ }; |
} |
function preventTheDefault() |
@@ -43,8 +41,13 @@ function preventTheDefault() |
function transactionCompleted() |
{ |
testPassed("Transaction completed"); |
+ testDefaultAllowedAborts(); |
+} |
+ |
+function testDefaultAllowedAborts() |
+{ |
debug(""); |
- debug(""); |
+ debug("Test: allowing the default event behavior, which aborts the transaction"); |
trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')"); |
evalAndLog("trans.onabort = transactionAborted1"); |
evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); |
@@ -52,6 +55,7 @@ function transactionCompleted() |
request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); |
request.onsuccess = unexpectedSuccessCallback; |
request.onerror = allowDefault; |
+ expectError(); |
} |
function allowDefault() |
@@ -62,15 +66,20 @@ function allowDefault() |
function transactionAborted1() |
{ |
testPassed("Transaction aborted"); |
+ testNoErrorHandlerAborts(); |
+} |
+ |
+function testNoErrorHandlerAborts() { |
debug(""); |
- debug(""); |
+ debug("Test: no error handler implicitly allows allowing the default event behavior, which aborts the transaction"); |
trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')"); |
evalAndLog("trans.onabort = transactionAborted2"); |
evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); |
store = evalAndLog("store = trans.objectStore('storeName')"); |
request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); |
request.onsuccess = unexpectedSuccessCallback; |
- debug("Omitting an onerror handler"); |
+ expectError(); |
+ debug("Omitting an onerror handler on request; transaction should abort"); |
} |
function transactionAborted2() |