Adding a test that makes sure openDatabaseSync() deals correctly with invalid inputs.
authordumi@chromium.org <dumi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 May 2010 05:37:42 +0000 (05:37 +0000)
committerdumi@chromium.org <dumi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 May 2010 05:37:42 +0000 (05:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=34994

Reviewed by Brady Eidson.

* fast/workers/storage: Added.
* fast/workers/storage/open-database-sync-inputs-expected.txt: Added.
* fast/workers/storage/open-database-sync-inputs.html: Added.
* fast/workers/storage/resources: Added.
* fast/workers/storage/resources/open-database-sync-inputs.js: Added.
(notAString.toString):
* fast/workers/storage/resources/test-inputs-common.js: Added.
(log):
(finishTest):
(runTest.worker.onmessage):
(runTest):

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

LayoutTests/ChangeLog
LayoutTests/fast/workers/storage/open-database-sync-inputs-expected.txt [new file with mode: 0644]
LayoutTests/fast/workers/storage/open-database-sync-inputs.html [new file with mode: 0644]
LayoutTests/fast/workers/storage/resources/open-database-sync-inputs.js [new file with mode: 0644]
LayoutTests/fast/workers/storage/resources/test-inputs-common.js [new file with mode: 0644]

index 3b6aa25..bc97842 100644 (file)
@@ -1,3 +1,22 @@
+2010-05-07  Dumitru Daniliuc  <dumi@chromium.org>
+
+        Reviewed by Brady Eidson.
+
+        Adding a test that makes sure openDatabaseSync() deals correctly with invalid inputs.
+        https://bugs.webkit.org/show_bug.cgi?id=34994
+
+        * fast/workers/storage: Added.
+        * fast/workers/storage/open-database-sync-inputs-expected.txt: Added.
+        * fast/workers/storage/open-database-sync-inputs.html: Added.
+        * fast/workers/storage/resources: Added.
+        * fast/workers/storage/resources/open-database-sync-inputs.js: Added.
+        (notAString.toString):
+        * fast/workers/storage/resources/test-inputs-common.js: Added.
+        (log):
+        (finishTest):
+        (runTest.worker.onmessage):
+        (runTest):
+
 2010-05-10  Simon Fraser  <simon.fraser@apple.com>
 
         Fix up test results from last commit, which were generated with a build from before r59129.
diff --git a/LayoutTests/fast/workers/storage/open-database-sync-inputs-expected.txt b/LayoutTests/fast/workers/storage/open-database-sync-inputs-expected.txt
new file mode 100644 (file)
index 0000000..55b332d
--- /dev/null
@@ -0,0 +1,8 @@
+This test makes sure that openDatabaseSync() accepts only valid parameters.
+PASS: SYNTAX_ERR: DOM Exception 12
+PASS: SYNTAX_ERR: DOM Exception 12
+PASS: undefined
+PASS: undefined
+PASS: undefined
+PASS: TYPE_MISMATCH_ERR: DOM Exception 17
+
diff --git a/LayoutTests/fast/workers/storage/open-database-sync-inputs.html b/LayoutTests/fast/workers/storage/open-database-sync-inputs.html
new file mode 100644 (file)
index 0000000..8af3f78
--- /dev/null
@@ -0,0 +1,12 @@
+<!doctype html>
+<html>
+<head>
+<script src="resources/test-inputs-common.js"></script>
+</head>
+
+<body onload="runTest('resources/open-database-sync-inputs.js')">
+This test makes sure that openDatabaseSync() accepts only valid parameters.
+<pre id="console">
+</pre>
+</body>
+</html>
diff --git a/LayoutTests/fast/workers/storage/resources/open-database-sync-inputs.js b/LayoutTests/fast/workers/storage/resources/open-database-sync-inputs.js
new file mode 100644 (file)
index 0000000..c92d068
--- /dev/null
@@ -0,0 +1,64 @@
+var db;
+
+var notAString = {
+    toString: function() { throw "foo"; }
+};
+
+try {
+    db = openDatabaseSync();
+    postMessage("FAIL: calling openDatabaseSync() without any argument should throw an exception.");
+} catch (err) {
+    postMessage("PASS: " + err.message);
+}
+
+try {
+    db = openDatabaseSync("DBName", "DBVersion");
+    postMessage("FAIL: calling openDatabaseSync() with fewer than four arguments should throw an exception.");
+} catch (err) {
+    postMessage("PASS: " + err.message);
+}
+
+try {
+    db = openDatabaseSync(notAString, "DBVersion", "DBDescription", 1024);
+    postMessage("FAIL: the first argument to openDatabaseSync() must be a string.");
+} catch (err) {
+    postMessage("PASS: " + err.message);
+}
+
+try {
+    db = openDatabaseSync("DBName", notAString, "DBDescription", 1024);
+    postMessage("FAIL: the second argument to openDatabaseSync() must be a string.");
+} catch (err) {
+    postMessage("PASS: " + err.message);
+}
+
+try {
+    db = openDatabaseSync("DBName", "DBVersion", notAString, 1024);
+    postMessage("FAIL: the fourth argument to openDatabaseSync() must be an integer.");
+} catch (err) {
+    postMessage("PASS: " + err.message);
+}
+
+try {
+    db = openDatabaseSync("DBName", "DBVersion", "DBDescription", 1024, 0);
+    postMessage("FAIL: the fifth argument to openDatabaseSync() must be an object, if present.");
+} catch (err) {
+    postMessage("PASS: " + err.message);
+}
+
+// FIXME: Uncomment these tests when the sync DB API is implemented.
+//try {
+//    db = openDatabaseSync("DBName", "DBVersion", "DBDescription", 1024);
+//    postMessage("PASS: openDatabaseSync() succeeded.");
+//} catch (err) {
+//    postMessage("FAIL: " + err.message);
+//}
+//
+//try {
+//    db = openDatabaseSync("DBName", "DBVersion", "DBDescription", 1024, function(db) { });
+//    postMessage("PASS: calling openDatabaseSync() with a creation callback succeeded.");
+//} catch (err) {
+//    postMessage("FAIL: " + err.message);
+//}
+
+postMessage("done");
diff --git a/LayoutTests/fast/workers/storage/resources/test-inputs-common.js b/LayoutTests/fast/workers/storage/resources/test-inputs-common.js
new file mode 100644 (file)
index 0000000..6bfa6e2
--- /dev/null
@@ -0,0 +1,30 @@
+function log(message)
+{
+    document.getElementById("console").innerHTML += message + "<br>";
+}
+
+function finishTest()
+{
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+function runTest(workerJSFile)
+{
+    if (!workerJSFile) {
+        log("FAIL: no JS file specified for the worker.");
+    }
+
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+
+    var worker = new Worker(workerJSFile);
+    worker.onmessage = function(event) {
+        if (event.data == "done")
+            finishTest();
+        else
+            log(event.data);
+    }
+}