| Index: chrome/test/data/database/simple_database.html
|
| ===================================================================
|
| --- chrome/test/data/database/simple_database.html (revision 0)
|
| +++ chrome/test/data/database/simple_database.html (revision 0)
|
| @@ -0,0 +1,77 @@
|
| +<html>
|
| +<script>
|
| +
|
| +// Open a Web SQL database.
|
| +var g_db = null;
|
| +if (typeof window.openDatabase == "undefined") {
|
| + document.write("Error: Web SQL databases are not supported.");
|
| +}
|
| +try {
|
| + g_db = openDatabase("test", "1.0", "test database", 1024 * 1024);
|
| +} catch(err) {
|
| + document.write("Error: cannot open database.");
|
| +}
|
| +
|
| +// Creates a table named "table1" with one text column named "data".
|
| +function createTable() {
|
| + if (!g_db)
|
| + return;
|
| + g_db.transaction(
|
| + function(tx) {
|
| + tx.executeSql("CREATE TABLE table1 (data TEXT)");
|
| + },
|
| + function(error) {
|
| + sendValueToTest(error);
|
| + },
|
| + function() {
|
| + sendValueToTest("done");
|
| + });
|
| +}
|
| +
|
| +// Inserts a record into the database.
|
| +function insertRecord(text) {
|
| + g_db.transaction(
|
| + function(tx) {
|
| + tx.executeSql("INSERT INTO table1 VALUES (?)", [text]);
|
| + },
|
| + function(error) {
|
| + sendValueToTest(error);
|
| + },
|
| + function() {
|
| + sendValueToTest("done");
|
| + });
|
| +}
|
| +
|
| +// Gets all the records in the database, ordered by their age.
|
| +function getRecords() {
|
| + g_db.readTransaction(function(tx) {
|
| + tx.executeSql(
|
| + "SELECT data FROM table1 ORDER BY ROWID",
|
| + [],
|
| + function(tx, result) {
|
| + items = "";
|
| + for (var i = 0; i < result.rows.length; i++) {
|
| + if (items != "")
|
| + items += ", ";
|
| + items += result.rows.item(i).data;
|
| + }
|
| + sendValueToTest(items);
|
| + },
|
| + function(tx, error) {
|
| + sendValueToTest(error);
|
| + });
|
| + });
|
| +}
|
| +
|
| +function sendValueToTest(value) {
|
| + //alert(value);
|
| + window.domAutomationController.setAutomationId(0);
|
| + window.domAutomationController.send(value);
|
| +}
|
| +
|
| +</script>
|
| +
|
| +<body>
|
| +This page is used for testing Web SQL databases.
|
| +</body>
|
| +</html>
|
|
|
| Property changes on: chrome\test\data\database\simple_database.html
|
| ___________________________________________________________________
|
| Added: svn:mime-type
|
| + text/html
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|