WebCore: Changing the V8 and JSC implementations of
authordumi@chromium.org <dumi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Mar 2010 22:29:39 +0000 (22:29 +0000)
committerdumi@chromium.org <dumi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Mar 2010 22:29:39 +0000 (22:29 +0000)
SQLStatementErrorCallback to interpret as false all results that
could be converted to a false boolean. Pretty much a revert of
r54981.

Reviewed by Dimitri Glazkov.

https://bugs.webkit.org/show_bug.cgi?id=36569

* bindings/js/JSCustomSQLStatementErrorCallback.cpp:
(WebCore::JSCustomSQLStatementErrorCallback::handleEvent):
* bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp:
(WebCore::V8CustomSQLStatementErrorCallback::handleEvent):
* bindings/v8/custom/V8CustomVoidCallback.cpp:
(WebCore::invokeCallback):
* bindings/v8/custom/V8CustomVoidCallback.h:

LayoutTests: Updating the test to conform to the latest spec changes.

Reviewed by Dimitri Glazkov.

* storage/statement-error-callback-expected.txt:
* storage/statement-error-callback.html:

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

LayoutTests/ChangeLog
LayoutTests/storage/statement-error-callback-expected.txt
LayoutTests/storage/statement-error-callback.html
WebCore/ChangeLog
WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp
WebCore/bindings/v8/custom/V8CustomVoidCallback.h

index 04858274e971f12f78ff500c4e859a2f6fc2cea4..9d132ba2ed019890752b548411e240e8d4b491f5 100644 (file)
@@ -1,3 +1,12 @@
+2010-03-24  Dumitru Daniliuc  <dumi@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Updating the test to conform to the latest spec changes.
+
+        * storage/statement-error-callback-expected.txt:
+        * storage/statement-error-callback.html:
+
 2010-03-25  Ojan Vafai  <ojan@chromium.org>
 
         Reviewed by David Levin.
index 791dfb667b8a6bdc707416fba9563bf77b2dad39..6b65683aafc0ee7a0d90b1ebefeeeb33d487e9ae 100644 (file)
@@ -6,6 +6,9 @@ PASS - the transaction error callback was invoked.
 PASS - the transaction error callback was invoked.
 PASS - the transaction error callback was invoked.
 PASS - the transaction error callback was invoked.
-PASS - the transaction error callback was invoked.
+PASS - the transaction success callback was invoked.
+PASS - the transaction success callback was invoked.
+PASS - the transaction success callback was invoked.
+PASS - the transaction success callback was invoked.
 Test Complete
 
index 060a881e81c91c174e28cd7e9eab7491a6fd9c38..6db836d1618b9932456851ac9f8e07a76cc15fad 100644 (file)
@@ -15,37 +15,42 @@ function finishTest()
 }
 
 var txCallbackCount = 0;
-var NUMBER_OF_TRANSACTIONS = 7;
+var NUMBER_OF_TRANSACTIONS = 10;
 var database;
 
-function transactionErrorFunction(error)
-{
-    log("PASS - the transaction error callback was invoked.");
-    if (++txCallbackCount == NUMBER_OF_TRANSACTIONS)
-        finishTest();
-}
-
-function transactionSuccessFunction(message)
-{
-    log("FAIL - the transaction success callback should not be invoked.");
-    if (++txCallbackCount == NUMBER_OF_TRANSACTIONS)
-        finishTest();
-}
-
-function runTransactionExpectedToFail(statementErrorCallback)
+function runTransaction(expectedToFail, statementErrorCallback)
 {
     database.transaction(function(tx) {
-        tx.executeSql("CREATE TABLE IF NOT EXISTS StatementErrorCallbackTest (randomData)");
-        tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test']);
+        tx.executeSql("CREATE TABLE IF NOT EXISTS TestTable (RandomData TEXT)");
+        tx.executeSql("INSERT INTO TestTable VALUES (?)", ['test']);
         tx.executeSql("THIS STATEMENT WILL FAIL", [],
             function(tx, data) {
                 log("FAIL - this statement should have failed");
                 finishTest();
             }, statementErrorCallback);
-        tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test1'],
-            function(error) { log("FAIL - This statement should not have been executed"); },
-            function() { log("FAIL - This statement should not have been executed"); });
-    }, transactionErrorFunction, transactionSuccessFunction);
+        tx.executeSql("INSERT INTO TestTable VALUES (?)", ['test1'],
+            function(error) {
+                if (expectedToFail)
+                    log("FAIL - This statement should not have been executed");
+            }, function() {
+                if (expectedToFail)
+                    log("FAIL - This statement should not have been executed");
+            });
+    }, function(error) {
+        if (expectedToFail)
+            log("PASS - the transaction error callback was invoked.");
+        else
+            log("FAIL - the transaction error callback should not have been invoked.");
+        if (++txCallbackCount == NUMBER_OF_TRANSACTIONS)
+            finishTest();
+    }, function() {
+        if (expectedToFail)
+            log("FAIL - the transaction success callback should not have been invoked.");
+        else
+            log("PASS - the transaction success callback was invoked.");
+        if (++txCallbackCount == NUMBER_OF_TRANSACTIONS)
+            finishTest();
+    });
 }
 
 function runTest()
@@ -56,28 +61,18 @@ function runTest()
         layoutTestController.waitUntilDone();
     }
 
-    database = openDatabase("bug-28872", "1.0", "statement error callback test", 1024);
-    database.transaction(function(tx) {
-        tx.executeSql("CREATE TABLE IF NOT EXISTS StatementErrorCallbackTest (randomData)");
-        tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test']);
-        tx.executeSql("THIS STATEMENT WILL FAIL", [],
-            function(tx, data) {
-                log("FAIL - this statement should have failed");
-                finishTest();
-            }, function(tx, error) { return false; });
-        tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test1'],
-            function(tx, data) { },
-            function(tx, error) { log("FAIL - This statement should not have caused an error"); });
-    }, function(error) { log("FAIL - The transaction error callback should not have been invoked"); },
-    function() { });
+    database = openDatabase("StatementErrorCallbackTest", "1.0", "statement error callback test", 1024);
 
-    runTransactionExpectedToFail(function(error) { return true; });
-    runTransactionExpectedToFail(function(error) { throw "Exception in statement error callback"; return false; });
-    runTransactionExpectedToFail(function(error) {});
-    runTransactionExpectedToFail(function(error) { return null; });
-    runTransactionExpectedToFail(function(error) { return "some string"; });
-    runTransactionExpectedToFail(function(error) { return 1234; });
-    runTransactionExpectedToFail(function(error) { return {a: 2, b: "abc"}; });
+    runTransaction(true, function(error) { return true; });
+    runTransaction(true, function(error) { throw "Exception in statement error callback"; return false; });
+    runTransaction(true, function(error) { return "some string"; });
+    runTransaction(true, function(error) { return 1234; });
+    runTransaction(true, function(error) { return {a: 2, b: "abc"}; });
+    runTransaction(true, function(error) { return "false"; });
+    runTransaction(false, function(error) {});
+    runTransaction(false, function(error) { return false; });
+    runTransaction(false, function(error) { return 0; });
+    runTransaction(false, function(error) { return null; });
 }
 
 </script>
index 1d852cb1cc1e61fe73429e0761666f40eec7358b..ea9aee39cd9b4d30f356fa64d2bbfaa1e44b06c5 100644 (file)
@@ -1,3 +1,22 @@
+2010-03-24  Dumitru Daniliuc  <dumi@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Changing the V8 and JSC implementations of
+        SQLStatementErrorCallback to interpret as false all results that
+        could be converted to a false boolean. Pretty much a revert of
+        r54981.
+
+        https://bugs.webkit.org/show_bug.cgi?id=36569
+
+        * bindings/js/JSCustomSQLStatementErrorCallback.cpp:
+        (WebCore::JSCustomSQLStatementErrorCallback::handleEvent):
+        * bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp:
+        (WebCore::V8CustomSQLStatementErrorCallback::handleEvent):
+        * bindings/v8/custom/V8CustomVoidCallback.cpp:
+        (WebCore::invokeCallback):
+        * bindings/v8/custom/V8CustomVoidCallback.h:
+
 2010-03-25  Dmitry Titov  <dimich@chromium.org>
 
         Unreviewed, fix Chromium tests.
index 4d5de796503a69ed1b786484ab2debd037dbb0c3..61785092bf571e9c30a53eb73d6d4fe340638e86 100644 (file)
@@ -77,7 +77,7 @@ bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction,
         // Therefore an exception and returning true are the same thing - so, return true on an exception
         return true;
     }
-    return !result.isFalse();
+    return result.toBoolean(exec);
 }
 
 }
index f733ede3d815be98489eceddc70ec7f91642e736..605f14cd47f7a2007231f0895b1754cf23afde6d 100644 (file)
@@ -75,7 +75,7 @@ bool V8CustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction,
     // statement, if any, or onto the next overall step otherwise. Otherwise,
     // the error callback did not return false, or there was no error callback.
     // Jump to the last step in the overall steps.
-    return invokeCallbackTreatOnlyExplicitFalseAsFalse(m_callback, 2, argv, callbackReturnValue) || callbackReturnValue;
+    return invokeCallback(m_callback, 2, argv, callbackReturnValue) || callbackReturnValue;
 }
 
 } // namespace WebCore
index 8c69e765e6d9e008ed4f443efe45312568b5adc0..6e258dfc83ae66368cd6119d7ee8292c6940cc70 100644 (file)
  */
 
 #include "config.h"
-#include "V8Binding.h"
 #include "V8CustomVoidCallback.h"
 
 #include "Frame.h"
+#include "V8Binding.h"
 
 namespace WebCore {
 
@@ -64,7 +64,7 @@ void V8CustomVoidCallback::handleEvent()
     invokeCallback(m_callback, 0, 0, callbackReturnValue);
 }
 
-static bool invokeCallbackHelper(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], v8::Handle<v8::Value>& returnValue)
+bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue)
 {
     v8::TryCatch exceptionCatcher;
 
@@ -73,9 +73,8 @@ static bool invokeCallbackHelper(v8::Persistent<v8::Object> callback, int argc,
         callbackFunction = v8::Local<v8::Function>::New(v8::Persistent<v8::Function>::Cast(callback));
     } else if (callback->IsObject()) {
         v8::Local<v8::Value> handleEventFunction = callback->Get(v8::String::NewSymbol("handleEvent"));
-        if (handleEventFunction->IsFunction()) {
+        if (handleEventFunction->IsFunction())
             callbackFunction = v8::Local<v8::Function>::Cast(handleEventFunction);
-        }
     } else
         return false;
 
@@ -87,7 +86,8 @@ static bool invokeCallbackHelper(v8::Persistent<v8::Object> callback, int argc,
     V8Proxy* proxy = V8Proxy::retrieve();
     ASSERT(proxy);
 
-    returnValue = proxy->callFunction(callbackFunction, thisObject, argc, argv);
+    v8::Handle<v8::Value> result = proxy->callFunction(callbackFunction, thisObject, argc, argv);
+    callbackReturnValue = !result.IsEmpty() && result->IsBoolean() && result->BooleanValue();
 
     if (exceptionCatcher.HasCaught()) {
         v8::Local<v8::Message> message = exceptionCatcher.Message();
@@ -98,20 +98,4 @@ static bool invokeCallbackHelper(v8::Persistent<v8::Object> callback, int argc,
     return false;
 }
 
-bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue)
-{
-    v8::Handle<v8::Value> returnValue;
-    bool result = invokeCallbackHelper(callback, argc, argv, returnValue);
-    callbackReturnValue = !returnValue.IsEmpty() && returnValue->IsBoolean() && returnValue->BooleanValue();
-    return result;
-}
-
-bool invokeCallbackTreatOnlyExplicitFalseAsFalse(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue)
-{
-    v8::Handle<v8::Value> returnValue;
-    bool result = invokeCallbackHelper(callback, argc, argv, returnValue);
-    callbackReturnValue = !returnValue.IsEmpty() && !returnValue->IsFalse();
-    return result;
-}
-
 } // namespace WebCore
index 6b7b3e85da8f03d27f65dad565109139067413a0..586296b7006d003d76f55a5b4dd54315b55673d3 100644 (file)
@@ -60,7 +60,6 @@ private:
 
 // Returns false if callback failed (null, wrong type, or threw exception).
 bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue);
-bool invokeCallbackTreatOnlyExplicitFalseAsFalse(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue);
 
 } // namespace WebCore