Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(884)

Unified Diff: chrome/test/data/database/simple_database.html

Issue 10866013: Convert the browsing_data pyauto tests to chrome tests. Remove the ClearBrowsingData automation cod… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix flake in unittest harness Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698