summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/storage')
-rw-r--r--LayoutTests/storage/database-lock-after-reload.html2
-rw-r--r--LayoutTests/storage/null-callbacks-expected.txt2
-rw-r--r--LayoutTests/storage/null-callbacks.html46
-rw-r--r--LayoutTests/storage/private-browsing-readonly.html1
-rw-r--r--LayoutTests/storage/quota-tracking.html22
-rw-r--r--LayoutTests/storage/statement-error-callback-expected.txt9
-rw-r--r--LayoutTests/storage/statement-error-callback.html56
7 files changed, 106 insertions, 32 deletions
diff --git a/LayoutTests/storage/database-lock-after-reload.html b/LayoutTests/storage/database-lock-after-reload.html
index ad34d5b..8bdaddc 100644
--- a/LayoutTests/storage/database-lock-after-reload.html
+++ b/LayoutTests/storage/database-lock-after-reload.html
@@ -28,7 +28,7 @@ function addData(db)
// Insert a large amount of data that will take a little while to run. Schedule a timout to run that will load a new page
// whilst the transaction is still in progress, interrupting the transaction. This should not leave the database locked and on
// the next page we should be able to insert some more data.
- tx.executeSql("INSERT INTO DataTest (testData) VALUES (randomBlob(524200 ))", [], function(tx, result) { }, errorFunction);
+ tx.executeSql("INSERT INTO DataTest (testData) VALUES (ZEROBLOB(524200))", [], function(tx, result) { }, errorFunction);
location.href = "./resources/database-lock-after-reload-2.html";
}, errorFunction, function() {
finishTest();
diff --git a/LayoutTests/storage/null-callbacks-expected.txt b/LayoutTests/storage/null-callbacks-expected.txt
new file mode 100644
index 0000000..8311675
--- /dev/null
+++ b/LayoutTests/storage/null-callbacks-expected.txt
@@ -0,0 +1,2 @@
+This test checks that 'null' can be used wherever we expect an optional callback.
+PASS
diff --git a/LayoutTests/storage/null-callbacks.html b/LayoutTests/storage/null-callbacks.html
new file mode 100644
index 0000000..4ca0e1c
--- /dev/null
+++ b/LayoutTests/storage/null-callbacks.html
@@ -0,0 +1,46 @@
+<html>
+<head>
+<script>
+function finishTest()
+{
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function runTest()
+{
+ if (window.layoutTestController) {
+ layoutTestController.clearAllDatabases();
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ try {
+ var db = openDatabase("NullCallbacks", "1.0", "Test for null callbacks.", 1);
+ db.transaction(function(tx) {
+ tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo INT)", null);
+ tx.executeSql("INSERT INTO Test VALUES (?)", [1], null, null);
+ tx.executeSql("INSERT INTO Test VALUES (?)", [2], null);
+ tx.executeSql("INSERT INTO Test VALUES (3)", null, null, null);
+ tx.executeSql("INSERT INTO Test VALUES (?)", [4], null,
+ function(tx, error) {});
+ }, null, null);
+
+ db.transaction(function(tx) {
+ tx.executeSql("INSERT INTO Test VALUES (?)", [5]);
+ }, null, function() { finishTest(); });
+ } catch(err) {
+ document.getElementById("console").innerHTML = "FAIL";
+ finishTest();
+ }
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+This test checks that 'null' can be used wherever we expect an optional callback.
+<pre id="console">PASS</pre>
+</body>
+
+</html>
diff --git a/LayoutTests/storage/private-browsing-readonly.html b/LayoutTests/storage/private-browsing-readonly.html
index 70a209a..972b123 100644
--- a/LayoutTests/storage/private-browsing-readonly.html
+++ b/LayoutTests/storage/private-browsing-readonly.html
@@ -46,6 +46,7 @@ function privateBrowsingErrorFunction(tx, error)
{
++completed;
writeMessageToLog("Private browsing statement " + completed + " completed with an error\n" + error.message);
+ return false;
}
function runSetup(transaction)
diff --git a/LayoutTests/storage/quota-tracking.html b/LayoutTests/storage/quota-tracking.html
index fb2cc9e..2b5b49d 100644
--- a/LayoutTests/storage/quota-tracking.html
+++ b/LayoutTests/storage/quota-tracking.html
@@ -1,9 +1,9 @@
<html>
<head>
<script>
-var database1;
-var database2;
-var database3;
+var database1 = null;
+var database2 = null;
+var database3 = null;
function log(message)
{
@@ -39,13 +39,15 @@ function checkCompletion(db)
{
log("Done adding data");
- db.complete = true;
- if (database1.complete && database2.complete && database3.complete)
+ if (database3) {
finishTest();
- else if (database2.complete)
+ } else if (database2) {
+ database3 = openDatabase("QuotaManagementDatabase3", "1.0", "Test for quota management <rdar://5628468>", 1);
testDatabase(database3);
- else
+ } else {
+ database2 = openDatabase("QuotaManagementDatabase2", "1.0", "Test for quota management <rdar://5628468>", 1);
testDatabase(database2);
+ }
}
function addData(db)
@@ -95,12 +97,6 @@ function runTest()
}
database1 = openDatabase("QuotaManagementDatabase1", "1.0", "Test for quota management <rdar://5628468>", 1);
- database2 = openDatabase("QuotaManagementDatabase2", "1.0", "Test for quota management <rdar://5628468>", 1);
- database3 = openDatabase("QuotaManagementDatabase3", "1.0", "Test for quota management <rdar://5628468>", 1);
- database1.complete = false;
- database2.complete = false;
- database3.complete = false;
-
testDatabase(database1);
}
diff --git a/LayoutTests/storage/statement-error-callback-expected.txt b/LayoutTests/storage/statement-error-callback-expected.txt
index ca117a8..791dfb6 100644
--- a/LayoutTests/storage/statement-error-callback-expected.txt
+++ b/LayoutTests/storage/statement-error-callback-expected.txt
@@ -1,5 +1,10 @@
-CONSOLE MESSAGE: line 0: Exception in Statement error callback
-This test confirms that if the statement error callback returns true or throws an exception we do not execute any further statements in that transaction and instead execute the transaction error callback immediately.
+CONSOLE MESSAGE: line 0: Exception in statement error callback
+This test confirms that a transaction is immediately rolled back if and only if a statement's error callback throws an exception, returns true, or doesn't return any value.
+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 error callback was invoked.
PASS - the transaction error callback was invoked.
Test Complete
diff --git a/LayoutTests/storage/statement-error-callback.html b/LayoutTests/storage/statement-error-callback.html
index 3675548..060a881 100644
--- a/LayoutTests/storage/statement-error-callback.html
+++ b/LayoutTests/storage/statement-error-callback.html
@@ -15,7 +15,8 @@ function finishTest()
}
var txCallbackCount = 0;
-var NUMBER_OF_TRANSACTIONS = 2;
+var NUMBER_OF_TRANSACTIONS = 7;
+var database;
function transactionErrorFunction(error)
{
@@ -31,6 +32,22 @@ function transactionSuccessFunction(message)
finishTest();
}
+function runTransactionExpectedToFail(statementErrorCallback)
+{
+ 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();
+ }, 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);
+}
+
function runTest()
{
if (window.layoutTestController) {
@@ -38,29 +55,36 @@ function runTest()
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
-
- var 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(message) { log("FAIL - this statement should have failed"); finishTest(); }, function(error) { return true; });
- tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test1'], function(message) { log("FAIL - This statement should not have been executed"); }, function(message) { log("FAIL - This statement should not have been executed"); });
- }, transactionErrorFunction, transactionSuccessFunction);
- database.transaction(function(tx) {
+ 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(message) { log("FAIL - this statement should have failed"); finishTest(); }, function(error) { throw "Exception in Statement error callback"; return false; });
- tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test1'], function(message) { log("FAIL - This statement should not have been executed"); }, function(message) { log("FAIL - This statement should not have been executed"); });
- }, transactionErrorFunction, transactionSuccessFunction);
+ 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() { });
+
+ 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"}; });
}
</script>
</head>
<body onload="runTest()">
-This test confirms that if the statement error callback returns true or throws an exception we do not execute any further statements in that transaction and instead execute the transaction error callback immediately.
+This test confirms that a transaction is immediately rolled back if and only if a statement's error callback throws an exception, returns true, or doesn't return any value.
<pre id="console">
</pre>
</body>