1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<html>
<head>
<script>
function log(message)
{
document.body.innerHTML += message + "<br>";
}
function GC()
{
// Force GC.
if (window.GCController)
GCController.collect();
else {
for (var i = 0; i < 10000; ++i) {
({ });
}
}
}
// Variable for the database that will never be forgotten
var persistentDB = 0;
// Variable for the forgotten database
var forgottenDB = 0;
var completed = 0;
function checkCompletion()
{
if (++completed == 2 && window.layoutTestController)
layoutTestController.notifyDone();
}
function runTest()
{
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
persistentDB = openDatabase("MultipleDatabasesTest1", "1.0", "Test one out of a set of databases being destroyed (1)", 32768);
forgottenDB = openDatabase("MultipleDatabasesTest2", "1.0", "Test one out of a set of databases being destroyed (2)", 32768);
persistentDB.transaction(function(tx) {
tx.executeSql("CREATE TABLE IF NOT EXISTS DataTest (randomData)", [], function(tx, result) {
for (var i = 0; i < 25; ++i)
tx.executeSql("INSERT INTO DataTest (randomData) VALUES (1)", []);
});
}, function(err) {
log("Persistent Database Transaction Errored - " + err);
checkCompletion();
}, function() {
log("Persistent Database Transaction Complete");
checkCompletion();
});
forgottenDB.transaction(function(tx) {
tx.executeSql("CREATE TABLE IF NOT EXISTS EmptyTable (unimportantData)", []);
}, function(err) {
log("Forgotten Database Transaction Errored - " + err);
forgottenDB = 0;
GC();
checkCompletion();
}, function() {
log("Forgotten Database Transaction Complete");
forgottenDB = 0;
GC();
checkCompletion();
});
}
</script>
<body onload="runTest();">
This test opens two databases, queues up a series of operations on both, then "forgets" about one of them.
After forcing GC, resources associated with that database should be freed gracefully.<br>
</body>
</html>
|