Commit 49c07970 authored by dumi@chromium.org's avatar dumi@chromium.org
Browse files

Making database-lock-after-reload.html a bit more robust and

cleaning up some style issues.

Reviewed by Dimitri Glazkov.

* storage/database-lock-after-reload.html:
* storage/resources/database-lock-after-reload-2.html:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7c36f065
2010-03-03 Dumitru Daniliuc <dumi@chromium.org>
Reviewed by Dimitri Glazkov.
Making database-lock-after-reload.html a bit more robust and
cleaning up some style issues.
* storage/database-lock-after-reload.html:
* storage/resources/database-lock-after-reload-2.html:
2010-03-03 David Levin <levin@chromium.org>
No review, rolling out r55474.
......
<html>
<head>
<script>
var database;
function log(message)
{
document.getElementById("console").innerHTML += message + "<br>";
......@@ -15,7 +13,7 @@ function finishTest()
layoutTestController.notifyDone();
}
function errorFunction(tx, error)
function errorFunction(error)
{
log("Test failed - " + error.message);
finishTest();
......@@ -23,16 +21,16 @@ function errorFunction(tx, error)
function addData(db)
{
db.transaction(function(tx) {
db.transaction(function(tx) {
log("Inserting some data");
// 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 (ZEROBLOB(524200))", [], function(tx, result) { }, errorFunction);
location.href = "./resources/database-lock-after-reload-2.html";
}, errorFunction, function() {
finishTest();
});
// Load a new page while 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 (ZEROBLOB(524200))", [],
function(tx, result) { location.href = "./resources/database-lock-after-reload-2.html"; },
function(tx, error) { errorFunction(error); });
tx.executeSql("INSERT INTO DataTest (testData) VALUES (ZEROBLOB(524200))");
}, errorFunction, function() { finishTest(); });
}
function runTest()
......@@ -42,20 +40,20 @@ function runTest()
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
var database;
try {
database = openDatabase("DatabaseLockTest", "1.0", "Test for database locking", 5242880);
} catch (e) {
log("Error - could not open database");
finishTest();
}
database.transaction(function(tx) {
log("Adding a table");
tx.executeSql("CREATE TABLE DataTest (testData)", [], function(tx, result) { }, errorFunction);
}, errorFunction, function() {
addData(database);
});
tx.executeSql("CREATE TABLE DataTest (testData)", [], function(tx, result) { },
function(tx, error) { errorFunction(error); });
}, errorFunction, function() { addData(database); });
}
</script>
......
<html>
<head>
<script>
var database;
function log(message)
{
document.getElementById("console").innerHTML += message + "<br>";
......@@ -15,7 +13,7 @@ function finishTest()
layoutTestController.notifyDone();
}
function errorFunction(tx, error)
function errorFunction(error)
{
log("Test failed - " + error.message);
finishTest();
......@@ -23,13 +21,11 @@ function errorFunction(tx, error)
function addData(db)
{
db.transaction(function(tx) {
db.transaction(function(tx) {
log("Inserting some data");
tx.executeSql("INSERT INTO DataTest (testData) VALUES (?)", ["A"], function(tx, result) { }, errorFunction);
}, function(){}, function() {
finishTest();
});
tx.executeSql("INSERT INTO DataTest (testData) VALUES (?)", ["A"],
function(tx, result) { }, function(tx, error) { errorFunction(error); });
}, function() { }, function() { finishTest(); });
}
function runTest()
......@@ -38,9 +34,9 @@ function runTest()
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
try {
database = openDatabase("DatabaseLockTest", "1.0", "Test for database locking", 5242880);
var database = openDatabase("DatabaseLockTest", "1.0", "Test for database locking", 5242880);
addData(database);
} catch(e) {
log("Error - could not open database");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment