1<!doctype html>
2<html>
3<head>
4<script>
5var db;
6
7try {
8    if (window.openDatabase) {
9        db = openDatabase("StressTest2", "1.0", "Database stress test", 200000);
10        if (!db)
11            alert("Failed to open the database on disk.  This is probably because the version was bad or there is not enough space left in this domain's quota");
12    } else
13        alert("Couldn't open the database.  Please try with a WebKit nightly with this feature enabled");
14} catch(err) { }
15
16function loaded()
17{
18    db.transaction(function(tx) {
19        tx.executeSql("SELECT COUNT(*) FROM WebkitStickyNotes", [], function(result) {
20            loadNotes();
21        }, function(tx, error) {
22            tx.executeSql("CREATE TABLE WebKitStickyNotes (id REAL UNIQUE, note TEXT)", [], function(result) { 
23                tx.executeSql("INSERT INTO WebKitStickyNotes (id, note) VALUES (?, ?)", [1, 'Text'], function(result) { 
24                    tx.executeSql("INSERT INTO WebKitStickyNotes (id, note) VALUES (?, ?)", [2, 'More Text'], function(result) { 
25                        loadNotes(); 
26                    });
27                });
28            });
29        });
30    });
31}
32
33function loadNotes()
34{
35    db.transaction(function(tx) {
36        tx.executeSql("SELECT id, note FROM WebKitStickyNotes", [], function(tx, result) {
37            loadNotes();
38        }, function(tx, error) {
39            alert('Failed to retrieve notes from database - ' + error.message);
40            return;
41        });
42    });
43}
44
45addEventListener('load', loaded, false);
46</script>
47</head>
48<body>
49<p>This test needs to run without crashes and assertion failures for a while.<p>
50</body>
51</html>
52