summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage
diff options
context:
space:
mode:
authorLeon Clarke <leonclarke@google.com>2010-06-03 14:33:32 +0100
committerLeon Clarke <leonclarke@google.com>2010-06-08 12:24:51 +0100
commit5af96e2c7b73ebc627c6894727826a7576d31758 (patch)
treef9d5e6f6175ccd7e3d14de9b290f08937a0d17ba /LayoutTests/storage
parent8cc4fcf4f6adcbc0e0aebfc24fbad9a4cddf2cfb (diff)
downloadexternal_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.zip
external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.tar.gz
external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.tar.bz2
Merge webkit.org at r60469 : Initial merge by git.
Change-Id: I66a0047aa2af802f66bb0c7f2a8b02247a596234
Diffstat (limited to 'LayoutTests/storage')
-rw-r--r--LayoutTests/storage/change-version-handle-reuse.html22
-rw-r--r--LayoutTests/storage/change-version-handle-reuse.js2
-rw-r--r--LayoutTests/storage/execute-sql-args.html25
-rw-r--r--LayoutTests/storage/execute-sql-args.js2
-rw-r--r--LayoutTests/storage/hash-change-with-xhr-expected.txt1
-rw-r--r--LayoutTests/storage/hash-change-with-xhr.html140
-rw-r--r--LayoutTests/storage/hash-change-with-xhr.js112
-rw-r--r--LayoutTests/storage/indexeddb/idb-database-request-expected.txt35
-rw-r--r--LayoutTests/storage/indexeddb/idb-database-request.html (renamed from LayoutTests/storage/indexeddb/basics.html)3
-rw-r--r--LayoutTests/storage/indexeddb/indexed-database-request-expected.txt (renamed from LayoutTests/storage/indexeddb/basics-expected.txt)20
-rw-r--r--LayoutTests/storage/indexeddb/indexed-database-request.html13
-rw-r--r--LayoutTests/storage/indexeddb/resources/shared.js56
-rw-r--r--LayoutTests/storage/indexeddb/script-tests/TEMPLATE.html1
-rw-r--r--LayoutTests/storage/indexeddb/script-tests/basics.js61
-rw-r--r--LayoutTests/storage/indexeddb/script-tests/idb-database-request.js31
-rw-r--r--LayoutTests/storage/indexeddb/script-tests/indexed-database-request.js24
-rw-r--r--LayoutTests/storage/multiple-databases-garbage-collection.html77
-rw-r--r--LayoutTests/storage/multiple-databases-garbage-collection.js56
-rw-r--r--LayoutTests/storage/multiple-transactions-on-different-handles.html96
-rw-r--r--LayoutTests/storage/multiple-transactions-on-different-handles.js78
-rw-r--r--LayoutTests/storage/multiple-transactions.html53
-rw-r--r--LayoutTests/storage/multiple-transactions.js32
-rw-r--r--LayoutTests/storage/open-database-while-transaction-in-progress.html71
-rw-r--r--LayoutTests/storage/open-database-while-transaction-in-progress.js41
-rw-r--r--LayoutTests/storage/read-and-write-transactions-dont-run-together.html103
-rw-r--r--LayoutTests/storage/read-and-write-transactions-dont-run-together.js81
-rw-r--r--LayoutTests/storage/resources/database-common.js29
-rw-r--r--LayoutTests/storage/test-authorizer.html175
-rw-r--r--LayoutTests/storage/test-authorizer.js153
-rw-r--r--LayoutTests/storage/transaction-success-callback-isolated-world-expected.txt4
-rw-r--r--LayoutTests/storage/transaction-success-callback-isolated-world.html48
31 files changed, 854 insertions, 791 deletions
diff --git a/LayoutTests/storage/change-version-handle-reuse.html b/LayoutTests/storage/change-version-handle-reuse.html
index dd32198..af3fbf4 100644
--- a/LayoutTests/storage/change-version-handle-reuse.html
+++ b/LayoutTests/storage/change-version-handle-reuse.html
@@ -1,27 +1,7 @@
<html>
<head>
+<script src="resources/database-common.js"></script>
<script src="change-version-handle-reuse.js"></script>
-<script>
-
-var DB_TEST_SUFFIX = "_dom";
-
-function log(message)
-{
- document.getElementById("console").innerText += message + "\n";
-}
-
-function setupAndRunTest()
-{
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- layoutTestController.dumpAsText();
- }
-
- document.getElementById("console").innerText = "";
-
- runTest();
-}
-</script>
</head>
<body onload="setupAndRunTest()">
<div>This tests that a database can be accessed after changing its version. You should see an error about FooBar table below, not about mismatching versions.
diff --git a/LayoutTests/storage/change-version-handle-reuse.js b/LayoutTests/storage/change-version-handle-reuse.js
index e948614..847a58c 100644
--- a/LayoutTests/storage/change-version-handle-reuse.js
+++ b/LayoutTests/storage/change-version-handle-reuse.js
@@ -9,7 +9,7 @@ function finishTest()
function runTest()
{
try {
- db = openDatabase("ChangeVersion" + DB_TEST_SUFFIX, "", "Test that changing a database version doesn't kill our handle to it", 1);
+ db = openDatabaseWithSuffix("ChangeVersion", "", "Test that changing a database version doesn't kill our handle to it", 1);
var version = db.version;
var newVersion = version ? (parseInt(version) + 1).toString() : "1";
db.changeVersion(version, newVersion, function(tx) {
diff --git a/LayoutTests/storage/execute-sql-args.html b/LayoutTests/storage/execute-sql-args.html
index 8a36a7a..b9f2a43 100644
--- a/LayoutTests/storage/execute-sql-args.html
+++ b/LayoutTests/storage/execute-sql-args.html
@@ -1,30 +1,13 @@
<html>
-
<head>
+<script src="resources/database-common.js"></script>
<script src="execute-sql-args.js"></script>
-<script>
-
-var DB_TEST_SUFFIX = "_dom";
-
-function log(message)
-{
- document.getElementById("console").innerText += message + "\n";
-}
-
-function setupAndRunTest()
-{
- if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
- }
- runTest();
-}
-
-</script>
</head>
<body onload="setupAndRunTest()">
-<pre id="console"></pre>
+<pre id="console">
+FAILURE: test didn't run.
+</pre>
</body>
</html>
diff --git a/LayoutTests/storage/execute-sql-args.js b/LayoutTests/storage/execute-sql-args.js
index babeb5d..3b9414d 100644
--- a/LayoutTests/storage/execute-sql-args.js
+++ b/LayoutTests/storage/execute-sql-args.js
@@ -81,6 +81,6 @@ function runTransactionTests(transaction)
function runTest()
{
- var db = openDatabase("ExecuteSQLArgsTest" + DB_TEST_SUFFIX, "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1);
+ var db = openDatabaseWithSuffix("ExecuteSQLArgsTest", "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1);
db.transaction(runTransactionTests);
}
diff --git a/LayoutTests/storage/hash-change-with-xhr-expected.txt b/LayoutTests/storage/hash-change-with-xhr-expected.txt
index a481746..8e964e6 100644
--- a/LayoutTests/storage/hash-change-with-xhr-expected.txt
+++ b/LayoutTests/storage/hash-change-with-xhr-expected.txt
@@ -1,3 +1,4 @@
Changing the hash to create history entries.
Db is warmed up
Test Complete, SUCCESS
+
diff --git a/LayoutTests/storage/hash-change-with-xhr.html b/LayoutTests/storage/hash-change-with-xhr.html
index 9cbf276..584320f 100644
--- a/LayoutTests/storage/hash-change-with-xhr.html
+++ b/LayoutTests/storage/hash-change-with-xhr.html
@@ -1,140 +1,12 @@
<html>
<head>
<title>Hash Change with an Open XHR should not stop database transactions</title>
-
-<script type="text/javascript">
-
-var DB_UPDATE_INTERVAL = 100;
-var SEND_XHR_INTERVAL = 100;
-var BACK_INTERVAL = 100;
-var CREATE_HEALTH_TABLE = 'CREATE TABLE IF NOT EXISTS health (key VARCHAR(16) PRIMARY KEY);';
-var UPDATE_DATA = 'REPLACE INTO health VALUES("health-check-key");';
-
-var db = window.openDatabase('bug25710', '1.0', 'LayoutTest for bug 25710', 102400);
-var backIterations;
-var msgDiv;
-var xhrFctIntervalId;
-var backFctIntervalId;
-var successCheckIntervalId;
-var dbFctIntervalId;
-var successes;
-var databaseUpdates;
-var stoppedIntervals;
-
-function log(msg)
-{
- var newMsg = document.createElement('div');
- newMsg.innerText = msg;
- msgDiv.appendChild(newMsg);
-}
-
-function stopIntervals()
-{
- stoppedIntervals = true;
- window.clearInterval(dbFctIntervalId);
- window.clearInterval(xhrFctIntervalId);
- window.clearInterval(backFctIntervalId);
-}
-
-function stopTest(message)
-{
- if (!stoppedIntervals)
- stopIntervals();
-
- log(message);
-
- if (window.layoutTestController)
- layoutTestController.notifyDone();
-}
-
-function updateDatabase()
-{
- databaseUpdates++;
- db.transaction(function(transaction) {
- transaction.executeSql(UPDATE_DATA, [], function() {}, errorHandler);
- }, errorHandler, function() {
- successes++;
- });
-}
-
-function checkForSuccess()
-{
- if (successes == databaseUpdates) {
- stopTest('Test Complete, SUCCESS');
- window.clearInterval(successCheckIntervalId);
- }
-}
-
-function errorHandler(tx, error)
-{
- log('DB error, code: ' + error.code + ', msg: ' + error.message);
- stopTest('Test Complete, FAILED');
-}
-
-function sendXhr()
-{
- xhr = new XMLHttpRequest();
- xhr.open('GET', location.href, true);
- xhr.send('');
-}
-
-function invokeBack()
-{
- backIterations--;
- if (backIterations) {
- history.back();
- } else {
- stopIntervals();
- // Allow a little time for all the database transactions to complete now we've stopped making them.
- successCheckIntervalId = window.setInterval(checkForSuccess, 250);
- // If we don't finish before this time, then we consider the test failed.
- window.setTimeout(function() { stopTest('Timed out waiting for transactions to complete. FAILED'); }, 20000);
-
- }
-}
-
-function runTest()
-{
- if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
- }
-
- msgDiv = document.getElementById('msgs');
-
- msgDiv.innerHTML = '';
- backIterations = 10;
- consecutiveFailures = 0;
- successes = 0;
- databaseUpdates = 0;
- stoppedIntervals = false;
-
- // Create some hashes so we can call history.back().
- log('Changing the hash to create history entries.');
- for (var i = 0; i < backIterations; i++) {
- location.hash = i;
- }
-
- // Init the database.
- db.transaction(function(transaction) {
- transaction.executeSql(CREATE_HEALTH_TABLE, [], function() {}, errorHandler);
- }, errorHandler, function() {
- // Give a little for the database to 'warm up' before making xhr requests
- // and calling history.back().
- window.setTimeout(function() {
- log('Db is warmed up');
-
- // NOTE: If we don't make any xhr requests, then the test
- // successfully passes (comment this line out).
- xhrFctIntervalId = window.setInterval(sendXhr, SEND_XHR_INTERVAL);
- backFctIntervalId = window.setInterval(invokeBack, BACK_INTERVAL);
- dbFctIntervalId = window.setInterval(updateDatabase, DB_UPDATE_INTERVAL);
- }, 500);
- });
-}
-</script>
+<script src="resources/database-common.js"></script>
+<script src="hash-change-with-xhr.js"></script>
</head>
-<body onload="runTest()">
-<div id="msgs"></div>
+<body onload="setupAndRunTest()">
+<pre id="console">
+FAILURE: test didn't run.
+</pre>
</body>
</html>
diff --git a/LayoutTests/storage/hash-change-with-xhr.js b/LayoutTests/storage/hash-change-with-xhr.js
new file mode 100644
index 0000000..4290681
--- /dev/null
+++ b/LayoutTests/storage/hash-change-with-xhr.js
@@ -0,0 +1,112 @@
+var DB_UPDATE_INTERVAL = 100;
+var SEND_XHR_INTERVAL = 100;
+var BACK_INTERVAL = 100;
+var CREATE_HEALTH_TABLE = 'CREATE TABLE IF NOT EXISTS health (key VARCHAR(16) PRIMARY KEY);';
+var UPDATE_DATA = 'REPLACE INTO health VALUES("health-check-key");';
+
+var db = openDatabaseWithSuffix('bug25710', '1.0', 'LayoutTest for bug 25710', 102400);
+var backIterations;
+var xhrFctIntervalId;
+var backFctIntervalId;
+var successCheckIntervalId;
+var dbFctIntervalId;
+var successes;
+var databaseUpdates;
+var stoppedIntervals;
+
+function stopIntervals()
+{
+ stoppedIntervals = true;
+ clearInterval(dbFctIntervalId);
+ clearInterval(xhrFctIntervalId);
+ clearInterval(backFctIntervalId);
+}
+
+function stopTest(message)
+{
+ if (!stoppedIntervals)
+ stopIntervals();
+
+ log(message);
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function updateDatabase()
+{
+ databaseUpdates++;
+ db.transaction(function(transaction) {
+ transaction.executeSql(UPDATE_DATA, [], function() {}, errorHandler);
+ }, errorHandler, function() {
+ successes++;
+ });
+}
+
+function checkForSuccess()
+{
+ if (successes == databaseUpdates) {
+ stopTest('Test Complete, SUCCESS');
+ clearInterval(successCheckIntervalId);
+ }
+}
+
+function errorHandler(tx, error)
+{
+ log('DB error, code: ' + error.code + ', msg: ' + error.message);
+ stopTest('Test Complete, FAILED');
+}
+
+function sendXhr()
+{
+ xhr = new XMLHttpRequest();
+ xhr.open('GET', location.href, true);
+ xhr.send('');
+}
+
+function invokeBack()
+{
+ backIterations--;
+ if (backIterations) {
+ history.back();
+ } else {
+ stopIntervals();
+ // Allow a little time for all the database transactions to complete now we've stopped making them.
+ successCheckIntervalId = setInterval(checkForSuccess, 250);
+ // If we don't finish before this time, then we consider the test failed.
+ setTimeout(function() { stopTest('Timed out waiting for transactions to complete. FAILED'); }, 20000);
+
+ }
+}
+
+function runTest()
+{
+ backIterations = 10;
+ consecutiveFailures = 0;
+ successes = 0;
+ databaseUpdates = 0;
+ stoppedIntervals = false;
+
+ // Create some hashes so we can call history.back().
+ log('Changing the hash to create history entries.');
+ for (var i = 0; i < backIterations; i++) {
+ setLocationHash(i);
+ }
+
+ // Init the database.
+ db.transaction(function(transaction) {
+ transaction.executeSql(CREATE_HEALTH_TABLE, [], function() {}, errorHandler);
+ }, errorHandler, function() {
+ // Give a little for the database to 'warm up' before making xhr requests
+ // and calling history.back().
+ setTimeout(function() {
+ log('Db is warmed up');
+
+ // NOTE: If we don't make any xhr requests, then the test
+ // successfully passes (comment this line out).
+ xhrFctIntervalId = setInterval(sendXhr, SEND_XHR_INTERVAL);
+ backFctIntervalId = setInterval(invokeBack, BACK_INTERVAL);
+ dbFctIntervalId = setInterval(updateDatabase, DB_UPDATE_INTERVAL);
+ }, 500);
+ });
+}
diff --git a/LayoutTests/storage/indexeddb/idb-database-request-expected.txt b/LayoutTests/storage/indexeddb/idb-database-request-expected.txt
new file mode 100644
index 0000000..70ec252
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/idb-database-request-expected.txt
@@ -0,0 +1,35 @@
+Test IndexedDB's IDBDatabaseRequest.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB.open('name', 'description')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'abort' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+Success event fired:
+PASS 'result' in event is true
+PASS 'code' in event is false
+PASS 'message' in event is false
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'abort' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+db = event.result
+PASS db.name is "name"
+FAIL db.description should be description (of type string). Was undefined (of type undefined).
+PASS db.version is ""
+PASS db.objectStores is []
+PASS db.objectStores.length is 0
+PASS db.objectStores.contains('') is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/basics.html b/LayoutTests/storage/indexeddb/idb-database-request.html
index cca9674..3ea2893 100644
--- a/LayoutTests/storage/indexeddb/basics.html
+++ b/LayoutTests/storage/indexeddb/idb-database-request.html
@@ -3,10 +3,11 @@
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script src="../../fast/js/resources/js-test-post-function.js"></script>
+<script src="resources/shared.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
-<script src="script-tests/basics.js"></script>
+<script src="script-tests/idb-database-request.js"></script>
</body>
</html>
diff --git a/LayoutTests/storage/indexeddb/basics-expected.txt b/LayoutTests/storage/indexeddb/indexed-database-request-expected.txt
index 8a11f6c..1734ff9 100644
--- a/LayoutTests/storage/indexeddb/basics-expected.txt
+++ b/LayoutTests/storage/indexeddb/indexed-database-request-expected.txt
@@ -1,27 +1,23 @@
-Test the basics of IndexedDB.
+Test IndexedDB's IndexedDatabaseRequest.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS 'indexedDB' in window is true
-PASS 'open' in indexedDB is true
-indexedDB.open('name', 'description', true /* allow modification */)
+PASS indexedDB == null is false
+indexedDB.open('name', 'description')
PASS 'onsuccess' in result is true
PASS 'onerror' in result is true
PASS 'abort' in result is true
PASS 'readyState' in result is true
-
An event should fire shortly...
-FAIL Error function called: (0) Not implemented
-
+Success event fired:
+PASS 'result' in event is true
+PASS 'code' in event is false
+PASS 'message' in event is false
PASS 'source' in event is true
-PASS 'open' in event.source is true
-
-FAIL 'result' in event should be true. Was false.
-FAIL 'code' in event should be false. Was true.
-FAIL 'message' in event should be false. Was true.
-
+PASS event.source != null is true
PASS 'onsuccess' in event.target is true
PASS 'onerror' in event.target is true
PASS 'abort' in event.target is true
diff --git a/LayoutTests/storage/indexeddb/indexed-database-request.html b/LayoutTests/storage/indexeddb/indexed-database-request.html
new file mode 100644
index 0000000..c22934b
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/indexed-database-request.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+<script src="resources/shared.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/indexed-database-request.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/storage/indexeddb/resources/shared.js b/LayoutTests/storage/indexeddb/resources/shared.js
new file mode 100644
index 0000000..809bdec
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/resources/shared.js
@@ -0,0 +1,56 @@
+function done()
+{
+ window.successfullyParsed = true;
+ isSuccessfullyParsed();
+ if (window.layoutTestController)
+ layoutTestController.notifyDone()
+}
+
+function verifyEventCommon(event)
+{
+ shouldBeTrue("'source' in event");
+ shouldBeTrue("event.source != null");
+ shouldBeTrue("'onsuccess' in event.target");
+ shouldBeTrue("'onerror' in event.target");
+ shouldBeTrue("'abort' in event.target");
+ shouldBeTrue("'readyState' in event.target");
+ shouldBe("event.target.readyState", "event.target.DONE");
+ debug("");
+}
+
+function verifyErrorEvent(event)
+{
+ debug("Error event fired:");
+ shouldBeFalse("'result' in event");
+ shouldBeTrue("'code' in event");
+ shouldBeTrue("'message' in event");
+ verifyEventCommon(event);
+}
+
+function verifySuccessEvent(event)
+{
+ debug("Success event fired:");
+ shouldBeTrue("'result' in event");
+ shouldBeFalse("'code' in event");
+ shouldBeFalse("'message' in event");
+ verifyEventCommon(event);
+}
+
+function verifyResult(result)
+{
+ shouldBeTrue("'onsuccess' in result");
+ shouldBeTrue("'onerror' in result");
+ shouldBeTrue("'abort' in result");
+ shouldBeTrue("'readyState' in result");
+ debug("An event should fire shortly...");
+ debug("");
+}
+
+function unexpectedErrorCallback()
+{
+ testFailed("Error function called unexpectedly: (" + event.code + ") " + event.message);
+ debug("");
+ verifyErrorEvent(event);
+ done();
+}
+
diff --git a/LayoutTests/storage/indexeddb/script-tests/TEMPLATE.html b/LayoutTests/storage/indexeddb/script-tests/TEMPLATE.html
index 239a794..865fadb 100644
--- a/LayoutTests/storage/indexeddb/script-tests/TEMPLATE.html
+++ b/LayoutTests/storage/indexeddb/script-tests/TEMPLATE.html
@@ -3,6 +3,7 @@
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script src="../../fast/js/resources/js-test-post-function.js"></script>
+<script src="resources/shared.js"></script>
</head>
<body>
<p id="description"></p>
diff --git a/LayoutTests/storage/indexeddb/script-tests/basics.js b/LayoutTests/storage/indexeddb/script-tests/basics.js
deleted file mode 100644
index 307196a..0000000
--- a/LayoutTests/storage/indexeddb/script-tests/basics.js
+++ /dev/null
@@ -1,61 +0,0 @@
-description("Test the basics of IndexedDB.");
-
-if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
-}
-
-
-function eventShared()
-{
- debug("");
- shouldBeTrue("'source' in event");
- shouldBeTrue("'open' in event.source");
- debug("");
- shouldBeTrue("'result' in event");
- shouldBeFalse("'code' in event");
- shouldBeFalse("'message' in event");
- debug("");
- shouldBeTrue("'onsuccess' in event.target");
- shouldBeTrue("'onerror' in event.target");
- shouldBeTrue("'abort' in event.target");
- shouldBeTrue("'readyState' in event.target");
- shouldBe("event.target.readyState", "event.target.DONE");
- debug("");
- window.successfullyParsed = true;
- isSuccessfullyParsed();
- if (window.layoutTestController)
- layoutTestController.notifyDone()
-}
-
-function successFunction()
-{
- debug("Success function called");
- eventShared();
-}
-
-function errorFunction()
-{
- testFailed("Error function called: (" + event.code + ") " + event.message);
- eventShared();
-}
-
-function test()
-{
- shouldBeTrue("'indexedDB' in window");
- shouldBeTrue("'open' in indexedDB");
-
- result = evalAndLog("indexedDB.open('name', 'description', true /* allow modification */)");
- shouldBeTrue("'onsuccess' in result");
- shouldBeTrue("'onerror' in result");
- shouldBeTrue("'abort' in result");
- shouldBeTrue("'readyState' in result");
- result.onsuccess = successFunction;
- result.onerror = errorFunction;
- debug("");
- debug("An event should fire shortly...");
- debug("");
-}
-
-test();
-
diff --git a/LayoutTests/storage/indexeddb/script-tests/idb-database-request.js b/LayoutTests/storage/indexeddb/script-tests/idb-database-request.js
new file mode 100644
index 0000000..ae6a563
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/script-tests/idb-database-request.js
@@ -0,0 +1,31 @@
+description("Test IndexedDB's IDBDatabaseRequest.");
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function openSuccess()
+{
+ verifySuccessEvent(event);
+
+ var db = evalAndLog("db = event.result");
+ shouldBeEqualToString("db.name", "name");
+ shouldBeEqualToString("db.description", "description");
+ shouldBeEqualToString("db.version", "");
+ shouldBe("db.objectStores", "[]");
+ shouldBe("db.objectStores.length", "0");
+ shouldBe("db.objectStores.contains('')", "false");
+ // FIXME: Test .item() once it's possible to get back a non-empty list.
+
+ // FIXME: Test the other properties of IDBDatabase as they're written.
+
+ done();
+}
+
+function test()
+{
+ result = evalAndLog("indexedDB.open('name', 'description')");
+ verifyResult(result);
+ result.onsuccess = openSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+test();
diff --git a/LayoutTests/storage/indexeddb/script-tests/indexed-database-request.js b/LayoutTests/storage/indexeddb/script-tests/indexed-database-request.js
new file mode 100644
index 0000000..6f77279
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/script-tests/indexed-database-request.js
@@ -0,0 +1,24 @@
+description("Test IndexedDB's IndexedDatabaseRequest.");
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function openCallback()
+{
+ verifySuccessEvent(event);
+ done();
+}
+
+function test()
+{
+ shouldBeTrue("'indexedDB' in window");
+ shouldBeFalse("indexedDB == null");
+
+ // FIXME: Verify other IndexedDatabaseRequest constructors, once they're implemented.
+
+ result = evalAndLog("indexedDB.open('name', 'description')");
+ verifyResult(result);
+ result.onsuccess = openCallback;
+ result.onerror = unexpectedErrorCallback;
+}
+
+test();
diff --git a/LayoutTests/storage/multiple-databases-garbage-collection.html b/LayoutTests/storage/multiple-databases-garbage-collection.html
index 45246a9..8451acf 100644
--- a/LayoutTests/storage/multiple-databases-garbage-collection.html
+++ b/LayoutTests/storage/multiple-databases-garbage-collection.html
@@ -1,77 +1,12 @@
<html>
<head>
-<script>
-
-function log(message)
-{
- document.body.innerHTML += message + "<br>";
-}
-
-function GC()
-{
- // Force GC.
- if (window.GCController)
- GCController.collect();
- else {
- for (var i = 0; i < 10000; ++i) {
- ({ });
- }
- }
-}
-
-// Variable for the database that will never be forgotten
-var persistentDB = 0;
-// Variable for the forgotten database
-var forgottenDB = 0;
-
-var completed = 0;
-function checkCompletion()
-{
- if (++completed == 2 && window.layoutTestController)
- layoutTestController.notifyDone();
-}
-
-function runTest()
-{
- if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
- }
-
- persistentDB = openDatabase("MultipleDatabasesTest1", "1.0", "Test one out of a set of databases being destroyed (1)", 32768);
- forgottenDB = openDatabase("MultipleDatabasesTest2", "1.0", "Test one out of a set of databases being destroyed (2)", 32768);
-
- persistentDB.transaction(function(tx) {
- tx.executeSql("CREATE TABLE IF NOT EXISTS DataTest (randomData)", [], function(tx, result) {
- for (var i = 0; i < 25; ++i)
- tx.executeSql("INSERT INTO DataTest (randomData) VALUES (1)", []);
- });
- }, function(err) {
- log("Persistent Database Transaction Errored - " + err);
- checkCompletion();
- }, function() {
- log("Persistent Database Transaction Complete");
- checkCompletion();
- });
-
- forgottenDB.transaction(function(tx) {
- tx.executeSql("CREATE TABLE IF NOT EXISTS EmptyTable (unimportantData)", []);
- }, function(err) {
- log("Forgotten Database Transaction Errored - " + err);
- forgottenDB = 0;
- GC();
- checkCompletion();
- }, function() {
- log("Forgotten Database Transaction Complete");
- forgottenDB = 0;
- GC();
- checkCompletion();
- });
-}
-
-</script>
-<body onload="runTest();">
+<script src="resources/database-common.js"></script>
+<script src="multiple-databases-garbage-collection.js"></script>
+<body onload="setupAndRunTest();">
This test opens two databases, queues up a series of operations on both, then "forgets" about one of them.
After forcing GC, resources associated with that database should be freed gracefully.<br>
+<pre id="console">
+FAILURE: test didn't run.
+</pre>
</body>
</html>
diff --git a/LayoutTests/storage/multiple-databases-garbage-collection.js b/LayoutTests/storage/multiple-databases-garbage-collection.js
new file mode 100644
index 0000000..9a2b27f
--- /dev/null
+++ b/LayoutTests/storage/multiple-databases-garbage-collection.js
@@ -0,0 +1,56 @@
+function GC()
+{
+ // Force GC.
+ if (window.GCController)
+ GCController.collect();
+ else {
+ for (var i = 0; i < 10000; ++i) {
+ ({ });
+ }
+ }
+}
+
+// Variable for the database that will never be forgotten
+var persistentDB = 0;
+// Variable for the forgotten database
+var forgottenDB = 0;
+
+var completed = 0;
+function checkCompletion()
+{
+ if (++completed == 2 && window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function runTest()
+{
+ persistentDB = openDatabaseWithSuffix("MultipleDatabasesTest1", "1.0", "Test one out of a set of databases being destroyed (1)", 32768);
+ forgottenDB = openDatabaseWithSuffix("MultipleDatabasesTest2", "1.0", "Test one out of a set of databases being destroyed (2)", 32768);
+
+ persistentDB.transaction(function(tx) {
+ tx.executeSql("CREATE TABLE IF NOT EXISTS DataTest (randomData)", [], function(tx, result) {
+ for (var i = 0; i < 25; ++i)
+ tx.executeSql("INSERT INTO DataTest (randomData) VALUES (1)", []);
+ });
+ }, function(err) {
+ log("Persistent Database Transaction Errored - " + err);
+ checkCompletion();
+ }, function() {
+ log("Persistent Database Transaction Complete");
+ checkCompletion();
+ });
+
+ forgottenDB.transaction(function(tx) {
+ tx.executeSql("CREATE TABLE IF NOT EXISTS EmptyTable (unimportantData)", []);
+ }, function(err) {
+ log("Forgotten Database Transaction Errored - " + err);
+ forgottenDB = 0;
+ GC();
+ checkCompletion();
+ }, function() {
+ log("Forgotten Database Transaction Complete");
+ forgottenDB = 0;
+ GC();
+ checkCompletion();
+ });
+}
diff --git a/LayoutTests/storage/multiple-transactions-on-different-handles.html b/LayoutTests/storage/multiple-transactions-on-different-handles.html
index bcdab82..0a18c32 100644
--- a/LayoutTests/storage/multiple-transactions-on-different-handles.html
+++ b/LayoutTests/storage/multiple-transactions-on-different-handles.html
@@ -1,96 +1,12 @@
<html>
<head>
-<script>
-
-function log(message)
-{
- document.body.innerHTML += message + "<br>";
-}
-
-var complete = 0;
-
-function checkCompletion()
-{
- // The test should end after two transactions
- if (++complete == 2 && window.layoutTestController)
- layoutTestController.notifyDone();
-}
-
-// Opens the database used in this test case
-function openTestDatabase()
-{
- return openDatabase("MultipleTransactionsOnDifferentHandlesTest",
- "1.0",
- "Test to make sure that queueing multiple transactions on different DB handles does not result in a deadlock.",
- 32768);
-}
-
-function statementSuccessCallback(dbName, statementType)
-{
- log(dbName + " " + statementType + " statement succeeded");
-}
-
-function statementErrorCallback(dbName, statementType, error)
-{
- log(dbName + " " + statementType + " statement failed: " + error.message);
-}
-
-// Runs a transaction on the given database
-function runTransaction(db, dbName, val)
-{
- db.transaction(function(tx) {
- // Execute a read-only statement
- tx.executeSql("SELECT COUNT(*) FROM Test;", [],
- function(result) { statementSuccessCallback(dbName, "read"); },
- function(tx, error) { statementErrorCallback(dbName, "read", error); });
-
- // Execute a write statement to make sure SQLite tries to acquire an exclusive lock on the DB file
- tx.executeSql("INSERT INTO Test VALUES (?);", [val],
- function(result) { statementSuccessCallback(dbName, "write"); },
- function(tx, error) { statementErrorCallback(dbName, "write", error); });
- }, function(error) {
- // Transaction failure callback
- log(dbName + " transaction failed: " + error.message);
- checkCompletion();
- }, function() {
- // Transaction success callback
- log(dbName + " transaction succeeded");
- checkCompletion();
- });
-}
-
-// We need to guarantee that the Test table exists before we run our test.
-// Therefore, the test code is in the successCallback of the transaction that creates the table.
-function runTest() {
- if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
- }
-
- try {
- var db = openTestDatabase();
- db.transaction(function(tx) {
- // Create the Test table if it does not exist
- tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);", [],
- function(result) {}, function(tx, error) {});
- }, function(error) {
- log("Creating the Test table failed: " + error.message);
- }, function() {
- // The Test table was created successfully
- var db1 = openTestDatabase();
- var db2 = openTestDatabase();
- if (db1 == db2)
- log("failure: db1 == db2");
- else {
- runTransaction(db1, "db1", 1);
- runTransaction(db2, "db2", 2);
- }
- });
- } catch(err) {}
-}
-</script>
+<script src="resources/database-common.js"></script>
+<script src="multiple-transactions-on-different-handles.js"></script>
</head>
-<body onload="runTest();">
+<body onload="setupAndRunTest();">
This is a test to see if queueing up multiple transactions on different handles to the same database results in a deadlock.<br>
+<pre id="console">
+FAILURE: test didn't run.
+</pre>
</body>
</html>
diff --git a/LayoutTests/storage/multiple-transactions-on-different-handles.js b/LayoutTests/storage/multiple-transactions-on-different-handles.js
new file mode 100644
index 0000000..9ab4b93
--- /dev/null
+++ b/LayoutTests/storage/multiple-transactions-on-different-handles.js
@@ -0,0 +1,78 @@
+var complete = 0;
+
+function checkCompletion()
+{
+ // The test should end after two transactions
+ if (++complete == 2 && window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+// Opens the database used in this test case
+function openTestDatabase()
+{
+ return openDatabaseWithSuffix("MultipleTransactionsOnDifferentHandlesTest",
+ "1.0",
+ "Test to make sure that queueing multiple transactions on different DB handles does not result in a deadlock.",
+ 32768);
+}
+
+function statementSuccessCallback(dbName, statementType)
+{
+ log(dbName + " " + statementType + " statement succeeded");
+}
+
+function statementErrorCallback(dbName, statementType, error)
+{
+ log(dbName + " " + statementType + " statement failed: " + error.message);
+}
+
+// Runs a transaction on the given database
+function runTransaction(db, dbName, val)
+{
+ db.transaction(function(tx) {
+ // Execute a read-only statement
+ tx.executeSql("SELECT COUNT(*) FROM Test;", [],
+ function(result) { statementSuccessCallback(dbName, "read"); },
+ function(tx, error) { statementErrorCallback(dbName, "read", error); });
+
+ // Execute a write statement to make sure SQLite tries to acquire an exclusive lock on the DB file
+ tx.executeSql("INSERT INTO Test VALUES (?);", [val],
+ function(result) { statementSuccessCallback(dbName, "write"); },
+ function(tx, error) { statementErrorCallback(dbName, "write", error); });
+ }, function(error) {
+ // Transaction failure callback
+ log(dbName + " transaction failed: " + error.message);
+ checkCompletion();
+ }, function() {
+ // Transaction success callback
+ log(dbName + " transaction succeeded");
+ checkCompletion();
+ });
+}
+
+// We need to guarantee that the Test table exists before we run our test.
+// Therefore, the test code is in the successCallback of the transaction that creates the table.
+function runTest() {
+ try {
+ var db = openTestDatabase();
+ db.transaction(function(tx) {
+ // Create the Test table if it does not exist
+ tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);", [],
+ function(result) {}, function(tx, error) {});
+ }, function(error) {
+ log("Creating the Test table failed: " + error.message);
+ }, function() {
+ // The Test table was created successfully
+ var db1 = openTestDatabase();
+ var db2 = openTestDatabase();
+ if (db1 == db2)
+ log("failure: db1 == db2");
+ else {
+ runTransaction(db1, "db1", 1);
+ runTransaction(db2, "db2", 2);
+ }
+ });
+ } catch(err) {}
+}
+
+
diff --git a/LayoutTests/storage/multiple-transactions.html b/LayoutTests/storage/multiple-transactions.html
index 56656ca..3597440 100644
--- a/LayoutTests/storage/multiple-transactions.html
+++ b/LayoutTests/storage/multiple-transactions.html
@@ -1,53 +1,12 @@
<html>
<head>
-<script>
-
-function log(message)
-{
- document.body.innerHTML += message + "<br>";
-}
-
-var complete = 0;
-
-function checkCompletion()
-{
- if (++complete == 2 && window.layoutTestController)
- layoutTestController.notifyDone();
-}
-
-function runTest()
-{
- if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
- }
-
- var db = openDatabase("MultipleTransactionsTest", "1.0", "Test to make sure multiple transactions can be queued at once for an HTML5 database", 32768);
-
- db.transaction(function(tx) {
- log("Transaction 1 Started");
- }, function(err) {
- log("Transaction 1 Errored - " + err);
- checkCompletion();
- }, function() {
- log("Transaction 1 Succeeded");
- checkCompletion();
- });
-
- db.transaction(function(tx) {
- log("Transaction 2 Started");
- }, function(err) {
- log("Transaction 2 Errored - " + err);
- checkCompletion();
- }, function() {
- log("Transaction 2 Succeeded");
- checkCompletion();
- });
-}
-
-</script>
+<script src="resources/database-common.js"></script>
+<script src="multiple-transactions.js"></script>
<head>
-<body onload="runTest();">
+<body onload="setupAndRunTest();">
This is a test to see if the database API allows multiple transactions to be queued on the same database at once:<br>
+<pre id="console">
+FAILURE: test didn't run.
+</pre>
</body>
</html>
diff --git a/LayoutTests/storage/multiple-transactions.js b/LayoutTests/storage/multiple-transactions.js
new file mode 100644
index 0000000..85cdabc
--- /dev/null
+++ b/LayoutTests/storage/multiple-transactions.js
@@ -0,0 +1,32 @@
+var complete = 0;
+
+function checkCompletion()
+{
+ if (++complete == 2 && window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function runTest()
+{
+ var db = openDatabaseWithSuffix("MultipleTransactionsTest", "1.0", "Test to make sure multiple transactions can be queued at once for an HTML5 database", 32768);
+
+ db.transaction(function(tx) {
+ log("Transaction 1 Started");
+ }, function(err) {
+ log("Transaction 1 Errored - " + err);
+ checkCompletion();
+ }, function() {
+ log("Transaction 1 Succeeded");
+ checkCompletion();
+ });
+
+ db.transaction(function(tx) {
+ log("Transaction 2 Started");
+ }, function(err) {
+ log("Transaction 2 Errored - " + err);
+ checkCompletion();
+ }, function() {
+ log("Transaction 2 Succeeded");
+ checkCompletion();
+ });
+}
diff --git a/LayoutTests/storage/open-database-while-transaction-in-progress.html b/LayoutTests/storage/open-database-while-transaction-in-progress.html
index 691f6fe..707a1a4 100644
--- a/LayoutTests/storage/open-database-while-transaction-in-progress.html
+++ b/LayoutTests/storage/open-database-while-transaction-in-progress.html
@@ -1,71 +1,12 @@
<html>
<head>
-<script>
-
-function log(message)
-{
- document.body.innerHTML += message + "<br>";
-}
-
-var complete = 0;
-
-function checkCompletion()
-{
- // The test should end after two transactions
- if (++complete == 1 && window.layoutTestController)
- layoutTestController.notifyDone();
-}
-
-// Opens the database used in this test case
-function openTestDatabase()
-{
- return openDatabase("OpenDatabaseWhileTransactionInProgressTest",
- "1.0",
- "Test to make sure that calling openDatabase() while a transaction is in progress on a different handle to the same database does not result in a deadlock.",
- 2100000); // 2MB + epsilon
-}
-
-// See https://bugs.webkit.org/show_bug.cgi?id=28207
-// In order to trigger this bug, the transaction must acquire an exclusive
-// lock on the DB file before trying to obtain a second handle to the same DB.
-// The only way to force SQLite to obtain an exclusive lock is to change more
-// than cache_size * page_size bytes in the database. The default value for
-// cache_size is 2000 pages, and the default page_size is 1024 bytes. So the
-// size of the blob must be at least 2MB.
-function runTest()
-{
- if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
- }
-
- try {
- var db1 = openTestDatabase();
- db1.transaction(function(tx) {
- // Create the Test table if it does not exist
- tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo BLOB);");
- tx.executeSql("INSERT INTO Test VALUES (ZEROBLOB(2097152));", [],
- function(result) {
- var db2 = openTestDatabase();
- log("openDatabase() succeeded.");
- },
- function(tx, error) {
- log("Executing statement failed: " + error.message);
- });
-
- // Clean up the DB to allow for repeated runs of this test
- // without needing to increase the default allowed quota (5MB)
- tx.executeSql("DELETE FROM Test;");
- }, function(error) {
- log("Transaction failed: " + error.message);
- }, function() {
- checkCompletion();
- });
- } catch(err) {}
-}
-</script>
+<script src="resources/database-common.js"></script>
+<script src="open-database-while-transaction-in-progress.js"></script>
</head>
-<body onload="runTest();">
+<body onload="setupAndRunTest();">
This is a test to see if opening a database while a transaction is running on a different handle to the same database results in a deadlock.<br>
+<pre id="console">
+FAILURE: test didn't run.
+</pre>
</body>
</html>
diff --git a/LayoutTests/storage/open-database-while-transaction-in-progress.js b/LayoutTests/storage/open-database-while-transaction-in-progress.js
new file mode 100644
index 0000000..7a1a0c0
--- /dev/null
+++ b/LayoutTests/storage/open-database-while-transaction-in-progress.js
@@ -0,0 +1,41 @@
+// Opens the database used in this test case
+function openTestDatabase()
+{
+ return openDatabaseWithSuffix("OpenDatabaseWhileTransactionInProgressTest",
+ "1.0",
+ "Test to make sure that calling openDatabase() while a transaction is in progress on a different handle to the same database does not result in a deadlock.",
+ 2100000); // 2MB + epsilon
+}
+
+// See https://bugs.webkit.org/show_bug.cgi?id=28207
+// In order to trigger this bug, the transaction must acquire an exclusive
+// lock on the DB file before trying to obtain a second handle to the same DB.
+// The only way to force SQLite to obtain an exclusive lock is to change more
+// than cache_size * page_size bytes in the database. The default value for
+// cache_size is 2000 pages, and the default page_size is 1024 bytes. So the
+// size of the blob must be at least 2MB.
+function runTest()
+{
+ var db1 = openTestDatabase();
+ db1.transaction(function(tx) {
+ // Create the Test table if it does not exist
+ tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo BLOB);");
+ tx.executeSql("INSERT INTO Test VALUES (ZEROBLOB(2097152));", [],
+ function(result) {
+ var db2 = openTestDatabase();
+ log("openDatabase() succeeded.");
+ },
+ function(tx, error) {
+ log("Executing statement failed: " + error.message);
+ });
+
+ // Clean up the DB to allow for repeated runs of this test
+ // without needing to increase the default allowed quota (5MB)
+ tx.executeSql("DELETE FROM Test;");
+ }, function(error) {
+ log("Transaction failed: " + error.message);
+ }, function() {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ });
+}
diff --git a/LayoutTests/storage/read-and-write-transactions-dont-run-together.html b/LayoutTests/storage/read-and-write-transactions-dont-run-together.html
index a7565b5..11da356 100644
--- a/LayoutTests/storage/read-and-write-transactions-dont-run-together.html
+++ b/LayoutTests/storage/read-and-write-transactions-dont-run-together.html
@@ -1,103 +1,12 @@
<html>
<head>
-<script>
-
-function log(message)
-{
- document.body.innerHTML += message + "<br>";
-}
-
-function terminateTest()
-{
- if (window.layoutTestController)
- layoutTestController.notifyDone();
-}
-
-function openTestDatabase()
-{
- return openDatabase("ReadAndWriteTransactionsDontRunTogetherTest",
- "1.0",
- "Test to make sure that read and write transactions on different DB handles to the same DB don't run at the same time.",
- 32768);
-}
-
-var readTransactionsInProgress = 0;
-var writeTransactionsInProgress = 0;
-var totalTransactions = 0;
-var finishedTransactions = 0;
-
-function runTransaction(db, readOnly)
-{
- var transactionFunction = (readOnly ? db.readTransaction : db.transaction);
- transactionFunction.call(db, function(tx) {
- if (readOnly) {
- if (writeTransactionsInProgress != 0) {
- log("Read transaction starting while write transaction in progress.");
- terminateTest();
- }
- readTransactionsInProgress++;
- } else {
- if ((readTransactionsInProgress != 0) || (writeTransactionsInProgress != 0)) {
- log("Write transaction starting while another transaction in progress.");
- terminateTest();
- }
- writeTransactionsInProgress++;
- }
- tx.executeSql("SELECT * FROM Test;");
- }, function(error) {
- log((readOnly ? "Read" : "Write") + " transaction failed: " + error.message);
- terminateTest();
- }, function() {
- finishedTransactions++;
- if (readOnly)
- readTransactionsInProgress--;
- else
- writeTransactionsInProgress--;
- log("Transaction successful.");
- if ((finishedTransactions == totalTransactions) && (readTransactionsInProgress == 0) && (writeTransactionsInProgress == 0))
- terminateTest();
- });
-}
-
-function runReadAndWriteTransactions(db1, db2, db3)
-{
- totalTransactions = 10;
- finishedTransactions = 0;
- runTransaction(db1, true);
- runTransaction(db2, true);
- runTransaction(db1, false);
- runTransaction(db1, true);
- runTransaction(db2, true);
- runTransaction(db3, true);
- runTransaction(db1, false);
- runTransaction(db2, false);
- runTransaction(db1, true);
- runTransaction(db3, true);
-}
-
-function runTest() {
- if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
- }
-
- try {
- var db1 = openTestDatabase();
- var db2 = openTestDatabase();
- var db3 = openTestDatabase();
- db1.transaction(function(tx) {
- tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);");
- }, function(error) {
- log("Cannot create the Test table: " + error.message);
- terminateTest();
- }, function() {
- runReadAndWriteTransactions(db1, db2, db3);
- });
- } catch(err) {}
-}
-</script>
+<script src="resources/database-common.js"></script>
+<script src="read-and-write-transactions-dont-run-together.js"></script>
</head>
-<body onload="runTest();">
+<body onload="setupAndRunTest();">
This test tests that read and write transactions on different handles to the same database don't run together.<br>
+<pre id="console">
+FAILURE: test didn't run.
+</pre>
</body>
</html>
diff --git a/LayoutTests/storage/read-and-write-transactions-dont-run-together.js b/LayoutTests/storage/read-and-write-transactions-dont-run-together.js
new file mode 100644
index 0000000..5b817ba
--- /dev/null
+++ b/LayoutTests/storage/read-and-write-transactions-dont-run-together.js
@@ -0,0 +1,81 @@
+function terminateTest()
+{
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function openTestDatabase()
+{
+ return openDatabaseWithSuffix("ReadAndWriteTransactionsDontRunTogetherTest",
+ "1.0",
+ "Test to make sure that read and write transactions on different DB handles to the same DB don't run at the same time.",
+ 32768);
+}
+
+var readTransactionsInProgress = 0;
+var writeTransactionsInProgress = 0;
+var totalTransactions = 0;
+var finishedTransactions = 0;
+
+function runTransaction(db, readOnly)
+{
+ var transactionFunction = (readOnly ? db.readTransaction : db.transaction);
+ transactionFunction.call(db, function(tx) {
+ if (readOnly) {
+ if (writeTransactionsInProgress != 0) {
+ log("Read transaction starting while write transaction in progress.");
+ terminateTest();
+ }
+ readTransactionsInProgress++;
+ } else {
+ if ((readTransactionsInProgress != 0) || (writeTransactionsInProgress != 0)) {
+ log("Write transaction starting while another transaction in progress.");
+ terminateTest();
+ }
+ writeTransactionsInProgress++;
+ }
+ tx.executeSql("SELECT * FROM Test;");
+ }, function(error) {
+ log((readOnly ? "Read" : "Write") + " transaction failed: " + error.message);
+ terminateTest();
+ }, function() {
+ finishedTransactions++;
+ if (readOnly)
+ readTransactionsInProgress--;
+ else
+ writeTransactionsInProgress--;
+ log("Transaction successful.");
+ if ((finishedTransactions == totalTransactions) && (readTransactionsInProgress == 0) && (writeTransactionsInProgress == 0))
+ terminateTest();
+ });
+}
+
+function runReadAndWriteTransactions(db1, db2, db3)
+{
+ totalTransactions = 10;
+ finishedTransactions = 0;
+ runTransaction(db1, true);
+ runTransaction(db2, true);
+ runTransaction(db1, false);
+ runTransaction(db1, true);
+ runTransaction(db2, true);
+ runTransaction(db3, true);
+ runTransaction(db1, false);
+ runTransaction(db2, false);
+ runTransaction(db1, true);
+ runTransaction(db3, true);
+}
+
+function runTest() {
+ var db1 = openTestDatabase();
+ var db2 = openTestDatabase();
+ var db3 = openTestDatabase();
+ db1.transaction(function(tx) {
+ tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);");
+ }, function(error) {
+ log("Cannot create the Test table: " + error.message);
+ terminateTest();
+ }, function() {
+ runReadAndWriteTransactions(db1, db2, db3);
+ });
+}
diff --git a/LayoutTests/storage/resources/database-common.js b/LayoutTests/storage/resources/database-common.js
new file mode 100644
index 0000000..d1eb410
--- /dev/null
+++ b/LayoutTests/storage/resources/database-common.js
@@ -0,0 +1,29 @@
+var DB_TEST_SUFFIX = "_dom";
+
+function openDatabaseWithSuffix(name, version, description, size, callback)
+{
+ if (arguments.length > 4) {
+ return openDatabase(name + DB_TEST_SUFFIX, version, description, size, callback);
+ } else {
+ return openDatabase(name + DB_TEST_SUFFIX, version, description, size);
+ }
+}
+
+function log(message)
+{
+ document.getElementById("console").innerText += message + "\n";
+}
+
+function setLocationHash(hash) {
+ location.hash = hash;
+}
+
+function setupAndRunTest()
+{
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+ document.getElementById("console").innerText = "";
+ runTest();
+}
diff --git a/LayoutTests/storage/test-authorizer.html b/LayoutTests/storage/test-authorizer.html
index 57785a6..8baf10a 100644
--- a/LayoutTests/storage/test-authorizer.html
+++ b/LayoutTests/storage/test-authorizer.html
@@ -1,175 +1,12 @@
<html>
<head>
-<script>
-
-function log(message)
-{
- document.body.innerHTML += message + "<br>";
-}
-
-function terminateTest()
-{
- if (window.layoutTestController)
- layoutTestController.notifyDone();
-}
-
-function logAndTerminateTest(message, error)
-{
- log(message + ": " + error.message);
- terminateTest();
-}
-
-function cleanup(db)
-{
- db.transaction(function(tx) {
- tx.executeSql("DROP TABLE IF EXISTS Test;");
- tx.executeSql("DROP INDEX IF EXISTS TestIndex;");
- tx.executeSql("DROP VIEW IF EXISTS TestView;");
- tx.executeSql("DROP TRIGGER IF EXISTS TestTrigger;");
- }, function(error) { logAndTerminateTest("Cleanup failed", error); });
-}
-
-function statementSuccessCallback(statementType)
-{
- log(statementType + " statement succeeded.");
-}
-
-function statementErrorCallback(statementType, error)
-{
- log(statementType + " statement failed: " + error.message);
- return false;
-}
-
-function executeStatement(tx, statement, operation)
-{
- tx.executeSql(statement, [],
- function(result) { statementSuccessCallback(operation); },
- function(tx, error) { return statementErrorCallback(operation, error); });
-}
-
-function createTableCallback(tx)
-{
- executeStatement(tx, "CREATE TABLE Test (Foo int);", "SQLITE_CREATE_TABLE");
-}
-
-function createStatementsCallback(tx)
-{
- executeStatement(tx, "CREATE INDEX TestIndex ON Test (Foo);", "SQLITE_CREATE_INDEX");
-
- // Even though the following query should trigger a SQLITE_CREATE_TEMP_INDEX operation
- // (according to http://www.sqlite.org/tempfiles.html), it doesn't, and I'm not aware
- // of any other way to trigger this operation. So we'll skip it for now.
- //executeStatement(tx, "SELECT * FROM Test WHERE Foo IN (1, 2, 3);", "SQLITE_CREATE_TEMP_INDEX");
-
- executeStatement(tx, "CREATE TEMP TABLE TestTempTable (Foo int);", "SQLITE_CREATE_TEMP_TABLE");
- executeStatement(tx, "CREATE TEMP TRIGGER TestTempTrigger INSERT ON Test BEGIN SELECT COUNT(*) FROM Test; END;", "SQLITE_CREATE_TEMP_TRIGGER");
- executeStatement(tx, "CREATE TEMP VIEW TestTempView AS SELECT COUNT(*) FROM Test;", "SQLITE_CREATE_TEMP_VIEW");
- executeStatement(tx, "CREATE TRIGGER TestTrigger INSERT ON Test BEGIN SELECT COUNT(*) FROM Test; END;", "SQLITE_CREATE_TRIGGER");
- executeStatement(tx, "CREATE VIEW TestView AS SELECT COUNT(*) FROM Test;", "SQLITE_CREATE_VIEW");
- executeStatement(tx, "CREATE VIRTUAL TABLE TestVirtualTable USING MissingModule;", "SQLITE_CREATE_VTABLE");
-}
-
-function otherStatementsCallback(tx)
-{
- executeStatement(tx, "SELECT COUNT(*) FROM Test;", "SQLITE_READ");
- executeStatement(tx, "SELECT COUNT(*) FROM Test;", "SQLITE_SELECT");
- executeStatement(tx, "DELETE FROM Test;", "SQLITE_DELETE");
- executeStatement(tx, "INSERT INTO Test VALUES (1);", "SQLITE_INSERT");
- executeStatement(tx, "UPDATE Test SET Foo = 2 WHERE Foo = 1;", "SQLITE_UPDATE");
- executeStatement(tx, "PRAGMA cache_size;", "SQLITE_PRAGMA");
-
- executeStatement(tx, "ALTER TABLE Test RENAME TO TestTable;", "SQLITE_ALTER_TABLE");
- // Rename the table back to its original name
- executeStatement(tx, "ALTER TABLE TestTable RENAME To Test;", "SQLITE_ALTER_TABLE");
-
- executeStatement(tx, "BEGIN TRANSACTION;", "SQLITE_TRANSACTION");
- executeStatement(tx, "ATTACH main AS TestMain;", "SQLITE_ATTACH");
- executeStatement(tx, "DETACH TestMain;", "SQLITE_DETACH");
- executeStatement(tx, "REINDEX;", "SQLITE_REINDEX");
- executeStatement(tx, "ANALYZE;", "SQLITE_ANALYZE");
-
- // SQLITE_FUNCTION: allowed write mode
- // There is no SQL/Javascript API to add user-defined functions to SQLite,
- // so we cannot test this operation
-}
-
-function dropStatementsCallback(tx)
-{
- executeStatement(tx, "DROP INDEX TestIndex;", "SQLITE_DROP_INDEX");
-
- // SQLITE_DROP_TEMP_INDEX: allowed in write mode
- // Not sure how to test this: temp indexes are automatically dropped when
- // the database is closed, but HTML5 doesn't specify a closeDatabase() call.
-
- executeStatement(tx, "DROP TABLE TestTempTable;", "SQLITE_DROP_TEMP_TABLE");
- executeStatement(tx, "DROP TRIGGER TestTempTrigger;", "SQLITE_DROP_TEMP_TRIGGER");
- executeStatement(tx, "DROP VIEW TestTempView;", "SQLITE_DROP_TEMP_VIEW");
- executeStatement(tx, "DROP TRIGGER TestTrigger;", "SQLITE_DROP_TRIGGER");
- executeStatement(tx, "DROP VIEW TestView;", "SQLITE_DROP_VIEW");
-
- // SQLITE_DROP_VTABLE: allowed in write mode
- // Not sure how to test this: we cannot create a virtual table because we do not
- // have SQL/Javascript APIs to register a module that implements a virtual table.
- // Therefore, trying to drop a virtual table will always fail (no such table)
- // before even getting to the authorizer.
-
- executeStatement(tx, "DROP TABLE Test;", "SQLITE_DROP_TABLE");
-}
-
-function testReadWriteMode(db)
-{
- db.transaction(function(tx) {
- createTableCallback(tx);
- createStatementsCallback(tx);
- otherStatementsCallback(tx);
- dropStatementsCallback(tx);
- },
- function(error) { logAndTerminateTest("Write transaction failed", error); },
- function() { log("Write transaction succeeded."); });
-}
-
-function testReadOnlyMode(db)
-{
- // Test the 'CREATE TABLE' operation; it should be disallowed
- db.readTransaction(createTableCallback,
- function(error) { logAndTerminateTest("Read 'CREATE TABLE' transaction failed", error); });
-
- // In order to test all other 'CREATE' operations, we must create the table first
- db.transaction(createTableCallback,
- function(error) { logAndTerminateTest("Write 'CREATE TABLE' transaction failed", error); });
- db.readTransaction(createStatementsCallback,
- function(error) { logAndTerminateTest("Read 'CREATE' transaction failed", error); });
-
- // In order to test the 'DROP' and 'other' operations, we need to first create the respective entities
- db.transaction(createStatementsCallback,
- function(error) { logAndTerminateTest("Write 'CREATE' transaction failed", error); });
- db.readTransaction(otherStatementsCallback,
- function(error) { logAndTerminateTest("Read 'other' transaction failed", error); });
-
- // Hack: insert an empty write transaction to guaratee that these transactions are executed sequentially
- db.transaction(function(tx) { });
- db.readTransaction(dropStatementsCallback,
- function(error) { logAndTerminateTest("Read 'DROP' transaction failed", error); },
- function() { log("Read transactions succeeded."); terminateTest(); });
-}
-
-function runTest()
-{
- if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
- }
-
- try {
- var db = openDatabase("AuthorizerTest", "1.0", "Tests the database authorizer.", 32768);
- cleanup(db);
- testReadWriteMode(db);
- testReadOnlyMode(db);
- } catch(err) {}
-}
-</script>
+<script src="resources/database-common.js"></script>
+<script src="test-authorizer.js"></script>
</head>
-<body onload="runTest();">
+<body onload="setupAndRunTest();">
This test tests the database authorizer.<br>
+<pre id="console">
+FAILURE: test didn't run.
+</pre>
</body>
</html>
diff --git a/LayoutTests/storage/test-authorizer.js b/LayoutTests/storage/test-authorizer.js
new file mode 100644
index 0000000..4a08c89
--- /dev/null
+++ b/LayoutTests/storage/test-authorizer.js
@@ -0,0 +1,153 @@
+function terminateTest()
+{
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function logAndTerminateTest(message, error)
+{
+ log(message + ": " + error.message);
+ terminateTest();
+}
+
+function cleanup(db)
+{
+ db.transaction(function(tx) {
+ tx.executeSql("DROP TABLE IF EXISTS Test;");
+ tx.executeSql("DROP INDEX IF EXISTS TestIndex;");
+ tx.executeSql("DROP VIEW IF EXISTS TestView;");
+ tx.executeSql("DROP TRIGGER IF EXISTS TestTrigger;");
+ }, function(error) { logAndTerminateTest("Cleanup failed", error); });
+}
+
+function statementSuccessCallback(statementType)
+{
+ log(statementType + " statement succeeded.");
+}
+
+function statementErrorCallback(statementType, error)
+{
+ log(statementType + " statement failed: " + error.message);
+ return false;
+}
+
+function executeStatement(tx, statement, operation)
+{
+ tx.executeSql(statement, [],
+ function(result) { statementSuccessCallback(operation); },
+ function(tx, error) { return statementErrorCallback(operation, error); });
+}
+
+function createTableCallback(tx)
+{
+ executeStatement(tx, "CREATE TABLE Test (Foo int);", "SQLITE_CREATE_TABLE");
+}
+
+function createStatementsCallback(tx)
+{
+ executeStatement(tx, "CREATE INDEX TestIndex ON Test (Foo);", "SQLITE_CREATE_INDEX");
+
+ // Even though the following query should trigger a SQLITE_CREATE_TEMP_INDEX operation
+ // (according to http://www.sqlite.org/tempfiles.html), it doesn't, and I'm not aware
+ // of any other way to trigger this operation. So we'll skip it for now.
+ //executeStatement(tx, "SELECT * FROM Test WHERE Foo IN (1, 2, 3);", "SQLITE_CREATE_TEMP_INDEX");
+
+ executeStatement(tx, "CREATE TEMP TABLE TestTempTable (Foo int);", "SQLITE_CREATE_TEMP_TABLE");
+ executeStatement(tx, "CREATE TEMP TRIGGER TestTempTrigger INSERT ON Test BEGIN SELECT COUNT(*) FROM Test; END;", "SQLITE_CREATE_TEMP_TRIGGER");
+ executeStatement(tx, "CREATE TEMP VIEW TestTempView AS SELECT COUNT(*) FROM Test;", "SQLITE_CREATE_TEMP_VIEW");
+ executeStatement(tx, "CREATE TRIGGER TestTrigger INSERT ON Test BEGIN SELECT COUNT(*) FROM Test; END;", "SQLITE_CREATE_TRIGGER");
+ executeStatement(tx, "CREATE VIEW TestView AS SELECT COUNT(*) FROM Test;", "SQLITE_CREATE_VIEW");
+ executeStatement(tx, "CREATE VIRTUAL TABLE TestVirtualTable USING MissingModule;", "SQLITE_CREATE_VTABLE");
+}
+
+function otherStatementsCallback(tx)
+{
+ executeStatement(tx, "SELECT COUNT(*) FROM Test;", "SQLITE_READ");
+ executeStatement(tx, "SELECT COUNT(*) FROM Test;", "SQLITE_SELECT");
+ executeStatement(tx, "DELETE FROM Test;", "SQLITE_DELETE");
+ executeStatement(tx, "INSERT INTO Test VALUES (1);", "SQLITE_INSERT");
+ executeStatement(tx, "UPDATE Test SET Foo = 2 WHERE Foo = 1;", "SQLITE_UPDATE");
+ executeStatement(tx, "PRAGMA cache_size;", "SQLITE_PRAGMA");
+
+ executeStatement(tx, "ALTER TABLE Test RENAME TO TestTable;", "SQLITE_ALTER_TABLE");
+ // Rename the table back to its original name
+ executeStatement(tx, "ALTER TABLE TestTable RENAME To Test;", "SQLITE_ALTER_TABLE");
+
+ executeStatement(tx, "BEGIN TRANSACTION;", "SQLITE_TRANSACTION");
+ executeStatement(tx, "ATTACH main AS TestMain;", "SQLITE_ATTACH");
+ executeStatement(tx, "DETACH TestMain;", "SQLITE_DETACH");
+ executeStatement(tx, "REINDEX;", "SQLITE_REINDEX");
+ executeStatement(tx, "ANALYZE;", "SQLITE_ANALYZE");
+
+ // SQLITE_FUNCTION: allowed write mode
+ // There is no SQL/Javascript API to add user-defined functions to SQLite,
+ // so we cannot test this operation
+}
+
+function dropStatementsCallback(tx)
+{
+ executeStatement(tx, "DROP INDEX TestIndex;", "SQLITE_DROP_INDEX");
+
+ // SQLITE_DROP_TEMP_INDEX: allowed in write mode
+ // Not sure how to test this: temp indexes are automatically dropped when
+ // the database is closed, but HTML5 doesn't specify a closeDatabase() call.
+
+ executeStatement(tx, "DROP TABLE TestTempTable;", "SQLITE_DROP_TEMP_TABLE");
+ executeStatement(tx, "DROP TRIGGER TestTempTrigger;", "SQLITE_DROP_TEMP_TRIGGER");
+ executeStatement(tx, "DROP VIEW TestTempView;", "SQLITE_DROP_TEMP_VIEW");
+ executeStatement(tx, "DROP TRIGGER TestTrigger;", "SQLITE_DROP_TRIGGER");
+ executeStatement(tx, "DROP VIEW TestView;", "SQLITE_DROP_VIEW");
+
+ // SQLITE_DROP_VTABLE: allowed in write mode
+ // Not sure how to test this: we cannot create a virtual table because we do not
+ // have SQL/Javascript APIs to register a module that implements a virtual table.
+ // Therefore, trying to drop a virtual table will always fail (no such table)
+ // before even getting to the authorizer.
+
+ executeStatement(tx, "DROP TABLE Test;", "SQLITE_DROP_TABLE");
+}
+
+function testReadWriteMode(db)
+{
+ db.transaction(function(tx) {
+ createTableCallback(tx);
+ createStatementsCallback(tx);
+ otherStatementsCallback(tx);
+ dropStatementsCallback(tx);
+ },
+ function(error) { logAndTerminateTest("Write transaction failed", error); },
+ function() { log("Write transaction succeeded."); });
+}
+
+function testReadOnlyMode(db)
+{
+ // Test the 'CREATE TABLE' operation; it should be disallowed
+ db.readTransaction(createTableCallback,
+ function(error) { logAndTerminateTest("Read 'CREATE TABLE' transaction failed", error); });
+
+ // In order to test all other 'CREATE' operations, we must create the table first
+ db.transaction(createTableCallback,
+ function(error) { logAndTerminateTest("Write 'CREATE TABLE' transaction failed", error); });
+ db.readTransaction(createStatementsCallback,
+ function(error) { logAndTerminateTest("Read 'CREATE' transaction failed", error); });
+
+ // In order to test the 'DROP' and 'other' operations, we need to first create the respective entities
+ db.transaction(createStatementsCallback,
+ function(error) { logAndTerminateTest("Write 'CREATE' transaction failed", error); });
+ db.readTransaction(otherStatementsCallback,
+ function(error) { logAndTerminateTest("Read 'other' transaction failed", error); });
+
+ // Hack: insert an empty write transaction to guaratee that these transactions are executed sequentially
+ db.transaction(function(tx) { });
+ db.readTransaction(dropStatementsCallback,
+ function(error) { logAndTerminateTest("Read 'DROP' transaction failed", error); },
+ function() { log("Read transactions succeeded."); terminateTest(); });
+}
+
+function runTest()
+{
+ var db = openDatabaseWithSuffix("AuthorizerTest", "1.0", "Tests the database authorizer.", 32768);
+ cleanup(db);
+ testReadWriteMode(db);
+ testReadOnlyMode(db);
+}
diff --git a/LayoutTests/storage/transaction-success-callback-isolated-world-expected.txt b/LayoutTests/storage/transaction-success-callback-isolated-world-expected.txt
new file mode 100644
index 0000000..e427f4a
--- /dev/null
+++ b/LayoutTests/storage/transaction-success-callback-isolated-world-expected.txt
@@ -0,0 +1,4 @@
+ALERT: undefined
+ALERT: PASS: document.body.bar visible in a callback created in this world.
+This test tests that the transaction success callback is called in the right world.
+
diff --git a/LayoutTests/storage/transaction-success-callback-isolated-world.html b/LayoutTests/storage/transaction-success-callback-isolated-world.html
new file mode 100644
index 0000000..ca2df94
--- /dev/null
+++ b/LayoutTests/storage/transaction-success-callback-isolated-world.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<body>
+This test tests that the transaction success callback is called in the right world.
+<div id="console"></div>
+<script>
+var transactionSuccessCallbacksInvoked = 0;
+function done()
+{
+ if ((++transactionSuccessCallbacksInvoked == 2) && (window.layoutTestController))
+ layoutTestController.notifyDone();
+}
+
+function transactionSuccessCallback1(tx)
+{
+ alert("FAIL: Visible in isolated world.");
+ done();
+}
+
+function transactionSuccessCallback2(tx)
+{
+ alert(document.body.bar);
+ done();
+}
+
+document.body.foo = "FAIL: document.body.foo visible in isolated world.";
+document.body.bar = "PASS: document.body.bar visible in a callback created in this world.";
+
+if (window.layoutTestController) {
+ layoutTestController.clearAllDatabases();
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ layoutTestController.evaluateScriptInIsolatedWorld(
+ 0,
+ "function transactionSuccessCallback1(tx)\n" +
+ "{\n" +
+ " alert(document.body.foo);\n" +
+ " window.location='javascript:done()';\n" +
+ "}\n" +
+ "var db1 = openDatabase('TransactionSuccessCallbackIsolatedWorld1', '1.0', '', 1);\n" +
+ "db1.transaction(function(tx) { }, null, transactionSuccessCallback1);");
+
+ var db2 = openDatabase('TransactionSuccessCallbackIsolatedWorld2', '1.0', '', 1);
+ db2.transaction(function(tx) { }, null, transactionSuccessCallback2);
+}
+</script>
+</body>
+</html>