diff options
author | Steve Block <steveblock@google.com> | 2010-04-27 16:31:00 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-05-11 14:42:12 +0100 |
commit | dcc8cf2e65d1aa555cce12431a16547e66b469ee (patch) | |
tree | 92a8d65cd5383bca9749f5327fb5e440563926e6 /LayoutTests/storage | |
parent | ccac38a6b48843126402088a309597e682f40fe6 (diff) | |
download | external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2 |
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'LayoutTests/storage')
20 files changed, 534 insertions, 73 deletions
diff --git a/LayoutTests/storage/database-lock-after-reload.html b/LayoutTests/storage/database-lock-after-reload.html index 8bdaddc..5b5989f 100644 --- a/LayoutTests/storage/database-lock-after-reload.html +++ b/LayoutTests/storage/database-lock-after-reload.html @@ -1,8 +1,6 @@ <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> diff --git a/LayoutTests/storage/executesql-accepts-only-one-statement-expected.txt b/LayoutTests/storage/executesql-accepts-only-one-statement-expected.txt new file mode 100644 index 0000000..b95ceee --- /dev/null +++ b/LayoutTests/storage/executesql-accepts-only-one-statement-expected.txt @@ -0,0 +1,3 @@ +This test tests that executeSql() fails when called with a string that has more than one valid statement in it. +Test passed. + diff --git a/LayoutTests/storage/executesql-accepts-only-one-statement.html b/LayoutTests/storage/executesql-accepts-only-one-statement.html new file mode 100644 index 0000000..a3860c8 --- /dev/null +++ b/LayoutTests/storage/executesql-accepts-only-one-statement.html @@ -0,0 +1,78 @@ +<html> +<head> +<script> + +var TOTAL_STATEMENTS = 8; +var statements = 0; +var db = null; + +function log(message) +{ + document.body.innerText += message + "\n"; +} + +function terminateTest() +{ + if (window.layoutTestController) + layoutTestController.notifyDone(); +} + +function executeStatement(expectedToPass, statement) +{ + db.transaction(function(tx) { + tx.executeSql(statement, [], + function(tx, data) { + if (!expectedToPass) { + log("Statement " + statement + " was expected to fail, but passed."); + terminateTest(); + } + if (++statements == TOTAL_STATEMENTS) { + log("Test passed."); + terminateTest(); + } + }, function(tx, error) { + if (expectedToPass) { + log("Statement " + statement + " was expected to pass, but failed."); + terminateTest(); + } + if (++statements == TOTAL_STATEMENTS) { + log("Test passed."); + terminateTest(); + } + }); + }); +} + +function runTest() +{ + if (window.layoutTestController) { + layoutTestController.clearAllDatabases(); + layoutTestController.dumpAsText(); + layoutTestController.waitUntilDone(); + } + + db = openDatabase("ExecuteSQLAcceptsOnlyOneStatementTest", "1.0", "", 1); + db.transaction(function(tx) { + tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo INT)"); + }, function(error) { + log("Test failed: " + error.message); + terminateTest(); + }, function() { + executeStatement(true, "INSERT INTO Test VALUES (1)"); + executeStatement(true, "INSERT INTO Test VALUES (2);"); + executeStatement(true, " INSERT INTO Test VALUES (3) "); + executeStatement(true, " INSERT INTO Test VALUES (4); "); + executeStatement(true, "INSERT INTO Test VALUES (5) ;"); + executeStatement(false, "INSERT INTO Test VALUES (6); garbage"); + executeStatement(false, "INSERT INTO Test VALUES (7); INSERT INTO Test VALUES (8)"); + executeStatement(false, " INSERT INTO Test VALUES (9); INSERT INTO Test VALUES (10); "); + }); +} + +</script> +</head> +<body onload="runTest();"> +This test tests that executeSql() fails when called with a string that has more than one valid statement in it.<br> +</body> +</body> +</html> diff --git a/LayoutTests/storage/open-database-creation-callback-expected.txt b/LayoutTests/storage/open-database-creation-callback-expected.txt new file mode 100644 index 0000000..d86ab72 --- /dev/null +++ b/LayoutTests/storage/open-database-creation-callback-expected.txt @@ -0,0 +1,2 @@ +This test tests openDatabase()'s creation callback. + diff --git a/LayoutTests/storage/open-database-creation-callback-isolated-world-expected.txt b/LayoutTests/storage/open-database-creation-callback-isolated-world-expected.txt new file mode 100644 index 0000000..fa96a67 --- /dev/null +++ b/LayoutTests/storage/open-database-creation-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 openDatabase() creation callback is called in the right world. + diff --git a/LayoutTests/storage/open-database-creation-callback-isolated-world.html b/LayoutTests/storage/open-database-creation-callback-isolated-world.html new file mode 100644 index 0000000..98a4664 --- /dev/null +++ b/LayoutTests/storage/open-database-creation-callback-isolated-world.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<html> +<body> +This test tests that the openDatabase() creation callback is called in the right world. +<div id="console"></div> +<script> +var creationCallbacksExecuted = 0; +function done() +{ + if ((++creationCallbacksExecuted == 2) && (window.layoutTestController)) + layoutTestController.notifyDone(); +} + +function creationCallback1(db) +{ + alert("FAIL: Visible in isolated world."); + done(); +} + +function creationCallback2(db) +{ + 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 creationCallback1(db)\n" + + "{\n" + + " alert(document.body.foo);\n" + + " window.location='javascript:done()';\n" + + "}\n" + + "var db1 = openDatabase('OpenDatabaseCreationCallbackIsolatedWorld', '1.0', '', 1, creationCallback1);"); + + var db2 = openDatabase('OpenDatabaseCreationCallbackIsolatedWorld2', '1.0', '', 1, creationCallback2); +} +</script> +</body> +</html> diff --git a/LayoutTests/storage/open-database-creation-callback.html b/LayoutTests/storage/open-database-creation-callback.html new file mode 100644 index 0000000..ac24942 --- /dev/null +++ b/LayoutTests/storage/open-database-creation-callback.html @@ -0,0 +1,90 @@ +<html> +<head> +<script> +function log(message) +{ + document.getElementById("console").innerHTML += message + "<br>"; +} + +function finishTest() +{ + if (window.layoutTestController) + layoutTestController.notifyDone(); +} + +function runTest() +{ + if (window.layoutTestController) { + layoutTestController.clearAllDatabases(); + layoutTestController.setDatabaseQuota(32768); + layoutTestController.dumpDatabaseCallbacks(); + layoutTestController.dumpAsText(); + layoutTestController.waitUntilDone(); + } + + var transactionsRun = 0; + + // Open a new database with a creation callback, and make sure the creation callback is queued + var creationCallbackCalled1 = false; + var db1 = openDatabase("OpenDatabaseCreationCallback1", "1.0", "", 1, + function(db) { + creationCallbackCalled1 = true; + if (db.version != "") { + log("Creation callback was called with a database with version " + + db.version + "; empty string expected."); + finishTest(); + } + }); + + // Putting this code inside a transaction on 'db1' makes sure that it is executed after + // the creation callback is. + db1.transaction(function(tx) { + if (!creationCallbackCalled1) { + log("Creation callback for db1 was not called."); + finishTest(); + } + if (++transactionsRun == 2) + finishTest(); + }); + + // Try to open another handle to the same database. + // Since the version of this database is "" (empty string), openDatabase() should return + // a null handle and throw a INVALID_STATE_ERR exception. + var db1Fail = null; + try { + db1Fail = openDatabase("OpenDatabaseCreationCallback1", "1.0", "", 1); + log("This statement should not have been executed; an INVALID_STATE_ERR exception should've been thrown."); + finishTest(); + } catch(err) { + if (db1Fail) { + log("db1Fail should have been null."); + finishTest(); + } + } + + // Open a handle to another database, first without a creation callback, then with one. + // Make sure the creation callback is not called. + var creationCallbackCalled2 = false; + var db2 = openDatabase("OpenDatabaseCreationCallback2", "1.0", "", 1); + db2 = openDatabase("OpenDatabaseCreationCallback2", "1.0", "", 1, + function(db) { creationCallbackCalled2 = true; }); + db2.transaction(function(tx) { + if (creationCallbackCalled2) { + log("Creation callback for db2 should not have been called."); + finishTest(); + } + if (++transactionsRun == 2) + finishTest(); + }); +} + +</script> +</head> + +<body onload="runTest()"> +This test tests openDatabase()'s creation callback. +<pre id="console"> +</pre> +</body> + +</html> diff --git a/LayoutTests/storage/open-database-over-quota-expected.txt b/LayoutTests/storage/open-database-over-quota-expected.txt new file mode 100644 index 0000000..d0c15e4 --- /dev/null +++ b/LayoutTests/storage/open-database-over-quota-expected.txt @@ -0,0 +1,2 @@ +This tests that calling openDatabase with a size over 5MB doesn't assert on debug builds. +PASS diff --git a/LayoutTests/storage/open-database-over-quota.html b/LayoutTests/storage/open-database-over-quota.html new file mode 100644 index 0000000..2a9264d --- /dev/null +++ b/LayoutTests/storage/open-database-over-quota.html @@ -0,0 +1,24 @@ +<html> +<head> +<script> +function runTest() { + if (window.layoutTestController) { + layoutTestController.dumpAsText(); + layoutTestController.clearAllDatabases(); + } + + try { + var db = openDatabase('OverQuotaOpen', '', 'Test for bug 36473: missing lock in call to doneCreatingDatabase', 10000000); + } catch (err) { + document.getElementById('result').innerHTML = 'PASS' + } +} +</script> +</head> +<body onload="runTest()"> +<div>This tests that calling openDatabase with a size over 5MB doesn't assert on debug builds. +<div id="result"> +FAIL: We shouldn't have been able to open the database. +</div> +</body> +</html> diff --git a/LayoutTests/storage/resources/database-lock-after-reload-2.html b/LayoutTests/storage/resources/database-lock-after-reload-2.html index d73a0df..6e0f09c 100644 --- a/LayoutTests/storage/resources/database-lock-after-reload-2.html +++ b/LayoutTests/storage/resources/database-lock-after-reload-2.html @@ -1,8 +1,6 @@ <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"); diff --git a/LayoutTests/storage/statement-error-callback-expected.txt b/LayoutTests/storage/statement-error-callback-expected.txt index 791dfb6..6b65683 100644 --- a/LayoutTests/storage/statement-error-callback-expected.txt +++ b/LayoutTests/storage/statement-error-callback-expected.txt @@ -6,6 +6,9 @@ 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 success callback was invoked. +PASS - the transaction success callback was invoked. +PASS - the transaction success callback was invoked. +PASS - the transaction success callback was invoked. Test Complete diff --git a/LayoutTests/storage/statement-error-callback-isolated-world-expected.txt b/LayoutTests/storage/statement-error-callback-isolated-world-expected.txt new file mode 100644 index 0000000..b376896 --- /dev/null +++ b/LayoutTests/storage/statement-error-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 statement error callback is called in the right world. + diff --git a/LayoutTests/storage/statement-error-callback-isolated-world.html b/LayoutTests/storage/statement-error-callback-isolated-world.html new file mode 100644 index 0000000..196e42b --- /dev/null +++ b/LayoutTests/storage/statement-error-callback-isolated-world.html @@ -0,0 +1,52 @@ +<!DOCTYPE html> +<html> +<body> +This test tests that the statement error callback is called in the right world. +<div id="console"></div> +<script> +var statementErrorCallbacksInvoked = 0; +function done() +{ + if ((++statementErrorCallbacksInvoked == 2) && (window.layoutTestController)) + layoutTestController.notifyDone(); +} + +function statementErrorCallback1(tx, error) +{ + alert("FAIL: Visible in isolated world."); + done(); +} + +function statementErrorCallback2(tx, error) +{ + 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 statementErrorCallback1(tx, error)\n" + + "{\n" + + " alert(document.body.foo);\n" + + " window.location='javascript:done()';\n" + + "}\n" + + "var db1 = openDatabase('StatementErrorCallbackIsolatedWorld1', '1.0', '', 1);\n" + + "db1.transaction(function(tx) {\n" + + " tx.executeSql('BAD STATEMENT', [], function(tx, data) {}, statementErrorCallback1);\n" + + "});"); + + var db2 = openDatabase('StatementErrorCallbackIsolatedWorld2', '1.0', '', 1); + db2.transaction(function(tx) { + tx.executeSql('BAD STATEMENT', [], function(tx, data) {}, statementErrorCallback2); + }); +} +</script> +</body> +</html> diff --git a/LayoutTests/storage/statement-error-callback.html b/LayoutTests/storage/statement-error-callback.html index 060a881..6db836d 100644 --- a/LayoutTests/storage/statement-error-callback.html +++ b/LayoutTests/storage/statement-error-callback.html @@ -15,37 +15,42 @@ function finishTest() } var txCallbackCount = 0; -var NUMBER_OF_TRANSACTIONS = 7; +var NUMBER_OF_TRANSACTIONS = 10; var database; -function transactionErrorFunction(error) -{ - log("PASS - the transaction error callback was invoked."); - if (++txCallbackCount == NUMBER_OF_TRANSACTIONS) - finishTest(); -} - -function transactionSuccessFunction(message) -{ - log("FAIL - the transaction success callback should not be invoked."); - if (++txCallbackCount == NUMBER_OF_TRANSACTIONS) - finishTest(); -} - -function runTransactionExpectedToFail(statementErrorCallback) +function runTransaction(expectedToFail, statementErrorCallback) { database.transaction(function(tx) { - tx.executeSql("CREATE TABLE IF NOT EXISTS StatementErrorCallbackTest (randomData)"); - tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test']); + tx.executeSql("CREATE TABLE IF NOT EXISTS TestTable (RandomData TEXT)"); + tx.executeSql("INSERT INTO TestTable 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); + tx.executeSql("INSERT INTO TestTable VALUES (?)", ['test1'], + function(error) { + if (expectedToFail) + log("FAIL - This statement should not have been executed"); + }, function() { + if (expectedToFail) + log("FAIL - This statement should not have been executed"); + }); + }, function(error) { + if (expectedToFail) + log("PASS - the transaction error callback was invoked."); + else + log("FAIL - the transaction error callback should not have been invoked."); + if (++txCallbackCount == NUMBER_OF_TRANSACTIONS) + finishTest(); + }, function() { + if (expectedToFail) + log("FAIL - the transaction success callback should not have been invoked."); + else + log("PASS - the transaction success callback was invoked."); + if (++txCallbackCount == NUMBER_OF_TRANSACTIONS) + finishTest(); + }); } function runTest() @@ -56,28 +61,18 @@ function runTest() layoutTestController.waitUntilDone(); } - 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(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() { }); + database = openDatabase("StatementErrorCallbackTest", "1.0", "statement error callback test", 1024); - 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"}; }); + runTransaction(true, function(error) { return true; }); + runTransaction(true, function(error) { throw "Exception in statement error callback"; return false; }); + runTransaction(true, function(error) { return "some string"; }); + runTransaction(true, function(error) { return 1234; }); + runTransaction(true, function(error) { return {a: 2, b: "abc"}; }); + runTransaction(true, function(error) { return "false"; }); + runTransaction(false, function(error) {}); + runTransaction(false, function(error) { return false; }); + runTransaction(false, function(error) { return 0; }); + runTransaction(false, function(error) { return null; }); } </script> diff --git a/LayoutTests/storage/statement-success-callback-isolated-world-expected.txt b/LayoutTests/storage/statement-success-callback-isolated-world-expected.txt new file mode 100644 index 0000000..2ef027d --- /dev/null +++ b/LayoutTests/storage/statement-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 statement success callback is called in the right world. + diff --git a/LayoutTests/storage/statement-success-callback-isolated-world.html b/LayoutTests/storage/statement-success-callback-isolated-world.html new file mode 100644 index 0000000..4fac754 --- /dev/null +++ b/LayoutTests/storage/statement-success-callback-isolated-world.html @@ -0,0 +1,52 @@ +<!DOCTYPE html> +<html> +<body> +This test tests that the statement success callback is called in the right world. +<div id="console"></div> +<script> +var statementSuccessCallbacksInvoked = 0; +function done() +{ + if ((++statementSuccessCallbacksInvoked == 2) && (window.layoutTestController)) + layoutTestController.notifyDone(); +} + +function statementSuccessCallback1(tx, data) +{ + alert("FAIL: Visible in isolated world."); + done(); +} + +function statementSuccessCallback2(tx, data) +{ + 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 statementSuccessCallback1(tx, data)\n" + + "{\n" + + " alert(document.body.foo);\n" + + " window.location='javascript:done()';\n" + + "}\n" + + "var db1 = openDatabase('StatementSuccessCallbackIsolatedWorld1', '1.0', '', 1);\n" + + "db1.transaction(function(tx) {\n" + + " tx.executeSql('CREATE TABLE IF NOT EXISTS Test (Foo INT)', [], statementSuccessCallback1);\n" + + "});"); + + var db2 = openDatabase('StatementSuccessCallbackIsolatedWorld2', '1.0', '', 1); + db2.transaction(function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Test (Foo INT)', [], statementSuccessCallback2); + }); +} +</script> +</body> +</html> diff --git a/LayoutTests/storage/transaction-callback-isolated-world-expected.txt b/LayoutTests/storage/transaction-callback-isolated-world-expected.txt new file mode 100644 index 0000000..27f474f --- /dev/null +++ b/LayoutTests/storage/transaction-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 callback is called in the right world. + diff --git a/LayoutTests/storage/transaction-callback-isolated-world.html b/LayoutTests/storage/transaction-callback-isolated-world.html new file mode 100644 index 0000000..6825d70 --- /dev/null +++ b/LayoutTests/storage/transaction-callback-isolated-world.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<html> +<body> +This test tests that the transaction callback is called in the right world. +<div id="console"></div> +<script> +var transactionCallbacksInvoked = 0; +function done() +{ + if ((++transactionCallbacksInvoked == 2) && (window.layoutTestController)) + layoutTestController.notifyDone(); +} + +function transactionCallback1(tx) +{ + alert("FAIL: Visible in isolated world."); + done(); +} + +function transactionCallback2(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 transactionCallback1(tx)\n" + + "{\n" + + " alert(document.body.foo);\n" + + " window.location='javascript:done()';\n" + + "}\n" + + "var db1 = openDatabase('TransactionCallbackIsolatedWorld1', '1.0', '', 1);\n" + + "db1.transaction(transactionCallback1);"); + + var db2 = openDatabase('TransactionCallbackIsolatedWorld2', '1.0', '', 1); + db2.transaction(transactionCallback2); +} +</script> +</body> +</html> diff --git a/LayoutTests/storage/transaction-error-callback-isolated-world-expected.txt b/LayoutTests/storage/transaction-error-callback-isolated-world-expected.txt new file mode 100644 index 0000000..da15396 --- /dev/null +++ b/LayoutTests/storage/transaction-error-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 error callback is called in the right world. + diff --git a/LayoutTests/storage/transaction-error-callback-isolated-world.html b/LayoutTests/storage/transaction-error-callback-isolated-world.html new file mode 100644 index 0000000..521894d --- /dev/null +++ b/LayoutTests/storage/transaction-error-callback-isolated-world.html @@ -0,0 +1,52 @@ +<!DOCTYPE html> +<html> +<body> +This test tests that the transaction error callback is called in the right world. +<div id="console"></div> +<script> +var transactionErrorCallbacksInvoked = 0; +function done() +{ + if ((++transactionErrorCallbacksInvoked == 2) && (window.layoutTestController)) + layoutTestController.notifyDone(); +} + +function transactionErrorCallback1(tx) +{ + alert("FAIL: Visible in isolated world."); + done(); +} + +function transactionErrorCallback2(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 transactionErrorCallback1(tx)\n" + + "{\n" + + " alert(document.body.foo);\n" + + " window.location='javascript:done()';\n" + + "}\n" + + "var db1 = openDatabase('TransactionErrorCallbackIsolatedWorld1', '1.0', '', 1);\n" + + "db1.transaction(function(tx) {\n" + + " tx.executeSql('BAD STATEMENT', [], function(tx, data) {}, function(tx, error) { return true; });\n" + + "}, transactionErrorCallback1);"); + + var db2 = openDatabase('TransactionErrorCallbackIsolatedWorld2', '1.0', '', 1); + db2.transaction(function(tx) { + tx.executeSql('BAD STATEMENT', [], function(tx, data) {}, function(tx, error) { return true; }); + }, transactionErrorCallback2); +} +</script> +</body> +</html> |