From: kmccullough@apple.com Date: Wed, 27 Feb 2008 18:06:09 +0000 (+0000) Subject: Landing test that was forgotten in the original patch (r30087). X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=fb55917d0524383c61353158ee3c844505367ccc Landing test that was forgotten in the original patch (r30087). Test for: http://bugs.webkit.org/show_bug.cgi?id=17191 HTML5: Client-side database queries should return values of type number * storage/sql-data-types-expected.txt: Added. * storage/sql-data-types.html: Added. * storage/sql-data-types.js: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30628 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 56abab723514..5cd8a488808f 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,14 @@ +2008-02-27 Kevin McCullough + + Landing test that was forgotten in the original patch (r30087). + + Test for: http://bugs.webkit.org/show_bug.cgi?id=17191 + HTML5: Client-side database queries should return values of type number + + * storage/sql-data-types-expected.txt: Added. + * storage/sql-data-types.html: Added. + * storage/sql-data-types.js: Added. + 2008-02-27 Julien Chaffraix Reviewed by Alexey. diff --git a/LayoutTests/storage/sql-data-types-expected.txt b/LayoutTests/storage/sql-data-types-expected.txt new file mode 100644 index 000000000000..f60caf523b87 --- /dev/null +++ b/LayoutTests/storage/sql-data-types-expected.txt @@ -0,0 +1,7 @@ +PASS: property 'timestamp' ok, type was number +PASS: property 'id' ok, type was number +PASS: property 'real' ok, type was number +PASS: property 'text' ok, type was string +PASS: property 'blob' ok, type was string +PASS: database clean up ok. + diff --git a/LayoutTests/storage/sql-data-types.html b/LayoutTests/storage/sql-data-types.html new file mode 100644 index 000000000000..cd1c98f844c0 --- /dev/null +++ b/LayoutTests/storage/sql-data-types.html @@ -0,0 +1,10 @@ + + + + + + +

+
+
+
diff --git a/LayoutTests/storage/sql-data-types.js b/LayoutTests/storage/sql-data-types.js
new file mode 100644
index 000000000000..36fcd013b667
--- /dev/null
+++ b/LayoutTests/storage/sql-data-types.js
@@ -0,0 +1,87 @@
+//description("This test verifies that the javascript values returned by database queries are of same type as the values put into the database.");
+
+function writeMessageToLog(message)
+{
+    document.getElementById("console").innerText += message + "\n";
+}
+
+function notifyDone(str) {
+    writeMessageToLog(str);
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+var testValues = {
+    timestamp: new Date("Wed Feb 06 2008 12:16:52 GMT+0200 (EET)").valueOf(),
+    id: 1001,
+    real: 101.444,
+    text: "WebKit db TEXT",
+    blob: "supercalifragilistic"
+};
+
+function shouldBeSameTypeAndValue(propName, testValue, result) {
+    if (testValue == result && typeof testValue == typeof result) {
+        writeMessageToLog("PASS: property '" + propName + "' ok, type was " + typeof result);
+        return true;
+    }
+    writeMessageToLog("FAIL: property '" + propName + "' failed."
+        + " expected: " + typeof testValue + ":'" + testValue + "' "
+        + " got: " + typeof result + ":'" + result +"'");
+    return false;
+}
+
+function testDBValues(tx, result) {
+    var rs = result.rows.item(0);
+    // Avoid for .. in because (theretically) the order can change
+    i = "timestamp"; shouldBeSameTypeAndValue(i, testValues[i], rs[i]);
+    i = "id"; shouldBeSameTypeAndValue(i, testValues[i], rs[i]);
+    i = "real"; shouldBeSameTypeAndValue(i, testValues[i], rs[i]);
+    i = "text"; shouldBeSameTypeAndValue(i, testValues[i], rs[i]);
+    i = "blob"; shouldBeSameTypeAndValue(i, testValues[i], rs[i]);
+    
+    tx.executeSql("DROP TABLE DataTypeTestTable", [],
+        function(tx, result) {
+            notifyDone("PASS: database clean up ok.");
+        },
+        function(tx, result) {
+            notifyDone("FAIL: Database clean up failed.");
+        });
+}
+
+function fetchDBValuesStmt(tx, result) {
+    tx.executeSql("SELECT * FROM DataTypeTestTable", [],
+        testDBValues,
+        function(tx,error) {
+            notifyDone("FAIL: Error fetching values from the db.")
+        });
+}
+
+function insertTestValuesStmt(tx, result) {
+    tx.executeSql("INSERT INTO DataTypeTestTable (id, real, timestamp, text, blob) VALUES (?,?,?,?,?)",
+        [testValues.id, testValues.real, testValues.timestamp, testValues.text, testValues.blob],
+        fetchDBValuesStmt,
+        function(tx, error) {
+            notifyDone("FAIL: Error inserting values to the db.");
+        });
+}
+
+function createTestDBStmt(tx)
+{
+    tx.executeSql("CREATE TABLE IF NOT EXISTS DataTypeTestTable (id INTEGER UNIQUE, real REAL, timestamp INTEGER, text TEXT, blob BLOB)", [],
+        insertTestValuesStmt,
+        function(tx, error) {
+            notifyDone("FAIL: Error creating the db.");
+        });
+}
+
+function runTest() {
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    var db = openDatabase("DataTypeTest", "1.0", "Database for sql data type test", 1);
+    if (db)
+        db.transaction(createTestDBStmt);
+    else
+        notifyDone("FAIL: Error opening the db");
+}