• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1function GC()
2{
3    // Force GC.
4    if (window.GCController)
5        GCController.collect();
6    else {
7        for (var i = 0; i < 10000; ++i) {
8            ({ });
9        }
10    }
11}
12
13// Variable for the database that will never be forgotten
14var persistentDB = 0;
15// Variable for the forgotten database
16var forgottenDB = 0;
17
18var completed = 0;
19function checkCompletion()
20{
21    if (++completed == 2 && window.layoutTestController)
22        layoutTestController.notifyDone();
23}
24
25function runTest()
26{
27    persistentDB = openDatabaseWithSuffix("MultipleDatabasesTest1", "1.0", "Test one out of a set of databases being destroyed (1)", 32768);
28    forgottenDB = openDatabaseWithSuffix("MultipleDatabasesTest2", "1.0", "Test one out of a set of databases being destroyed (2)", 32768);
29
30    persistentDB.transaction(function(tx) {
31        tx.executeSql("CREATE TABLE IF NOT EXISTS DataTest (randomData)", [], function(tx, result) {
32            for (var i = 0; i < 25; ++i)
33                tx.executeSql("INSERT INTO DataTest (randomData) VALUES (1)", []);
34        });
35    }, function(err) {
36        log("Persistent Database Transaction Errored - " + err);
37        checkCompletion();
38    }, function() {
39        log("Persistent Database Transaction Complete");
40        checkCompletion();
41    });
42
43    forgottenDB.transaction(function(tx) {
44        tx.executeSql("CREATE TABLE IF NOT EXISTS EmptyTable (unimportantData)", []);
45    }, function(err) {
46        log("Forgotten Database Transaction Errored - " + err);
47        forgottenDB = 0;
48        GC();
49        checkCompletion();
50    }, function() {
51        log("Forgotten Database Transaction Complete");
52        forgottenDB = 0;
53        GC();
54        checkCompletion();
55    });
56}
57