WebCore:
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2007 06:46:31 +0000 (06:46 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2007 06:46:31 +0000 (06:46 +0000)
        Reviewed by Adam

        http://bugs.webkit.org/show_bug.cgi?id=15976 - ASSERT/crash when SQLTransactionCallback throws an exception

        * storage/SQLTransaction.cpp:
        (WebCore::SQLTransaction::deliverTransactionCallback): Make a transaction error for the case where the
          SQLTransactionCallback fails
        (WebCore::SQLTransaction::deliverTransactionErrorCallback): Don't assert on the error callback, but null check it
          and make the commit/rollback decision accordingly

LayoutTests:

        Reviewed by Adam

        Fix for http://bugs.webkit.org/show_bug.cgi?id=15976

        * storage: Added - There will soon be an entire suite in here!
        * storage/transaction_callback_exception_crash-expected.txt: Added.
        * storage/transaction_callback_exception_crash.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27784 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/storage/transaction_callback_exception_crash-expected.txt [new file with mode: 0644]
LayoutTests/storage/transaction_callback_exception_crash.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/storage/SQLTransaction.cpp

index 6a3c97aa7deb31b1855dd314bbf41ada980c55e8..89e3cfee78678f162cc9cee8b9a89b9d9025ab51 100644 (file)
@@ -1,3 +1,13 @@
+2007-11-13  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Adam
+
+        Fix for http://bugs.webkit.org/show_bug.cgi?id=15976
+
+        * storage: Added - There will soon be an entire suite in here!
+        * storage/transaction_callback_exception_crash-expected.txt: Added.
+        * storage/transaction_callback_exception_crash.html: Added.
+
 2007-11-13  Adam Roben  <aroben@apple.com>
 
         Add the http/tests/media directory to the Windows Skipped file
diff --git a/LayoutTests/storage/transaction_callback_exception_crash-expected.txt b/LayoutTests/storage/transaction_callback_exception_crash-expected.txt
new file mode 100644 (file)
index 0000000..02b8a48
--- /dev/null
@@ -0,0 +1,2 @@
+CONSOLE MESSAGE: line 0: undefined
+If WebKit doesn't crash, this test has passed
diff --git a/LayoutTests/storage/transaction_callback_exception_crash.html b/LayoutTests/storage/transaction_callback_exception_crash.html
new file mode 100644 (file)
index 0000000..65b2efd
--- /dev/null
@@ -0,0 +1,22 @@
+<html>
+<head>
+<script>
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+var db = openDatabase("15976Test", "1.0", "Test for http://bugs.webkit.org/show_bug.cgi?id=15976", 1);
+db.transaction(function(tx) { 
+    if (window.layoutTestController)
+        setTimeout("layoutTestController.notifyDone()", 0);
+    throw "TransactionCallbackError";
+});
+
+</script>
+</head>
+<body>
+If WebKit doesn't crash, this test has passed
+</body>
+</html>
index 8a95492f2c87ae1a79c6da47435912510338a580..0d9f701342f13e6a0774540e5e63a91b71c87457 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-13  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Adam
+
+        http://bugs.webkit.org/show_bug.cgi?id=15976 - ASSERT/crash when SQLTransactionCallback throws an exception
+
+        * storage/SQLTransaction.cpp:
+        (WebCore::SQLTransaction::deliverTransactionCallback): Make a transaction error for the case where the 
+          SQLTransactionCallback fails
+        (WebCore::SQLTransaction::deliverTransactionErrorCallback): Don't assert on the error callback, but null check it
+          and make the commit/rollback decision accordingly
+
 2007-11-13  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Anders.
index f4de111688c8fe0e8a28121d0c3a4a0aef5d7d55..71c6ec96f221fb984f478378a0303be5f1c9ab73 100644 (file)
@@ -145,9 +145,10 @@ void SQLTransaction::deliverTransactionCallback()
         shouldDeliverErrorCallback = true;
 
     // Transaction Step 5 - If the transaction callback was null or raised an exception, jump to the error callback
-    if (shouldDeliverErrorCallback)
+    if (shouldDeliverErrorCallback) {
+        m_transactionError = new SQLError(0, "the SQLTransactionCallback was null or threw an exception");
         deliverTransactionErrorCallback();
-    else
+    else
         scheduleToRunStatements();
 }
 
@@ -289,11 +290,11 @@ void SQLTransaction::handleTransactionError(bool inCallback)
 
 void SQLTransaction::deliverTransactionErrorCallback()
 {
-    ASSERT(m_errorCallback);
     ASSERT(m_transactionError);
     
     // Transaction Step 11 - If the callback didn't return false, then rollback the transaction.
-    if (m_errorCallback->handleEvent(m_transactionError.get()))
+    // This includes the callback not existing, returning true, or throwing an exception
+    if (!m_errorCallback || m_errorCallback->handleEvent(m_transactionError.get()))
         m_shouldCommitAfterErrorCallback = false;
 
     m_nextStep = &SQLTransaction::cleanupAfterTransactionErrorCallback;