Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / websql / multiple-databases-garbage-collection.js
blobba47b0b23ea603b50ab7e740e575ecfd74a5ea5a
1 function GC()
3 // Force GC.
4 if (window.GCController)
5 GCController.collectAll();
6 else {
7 for (var i = 0; i < 10000; ++i) {
8 ({ });
13 // Variable for the database that will never be forgotten
14 var persistentDB = 0;
15 // Variable for the forgotten database
16 var forgottenDB = 0;
18 var completed = 0;
19 function checkCompletion()
21 if (++completed == 2 && window.testRunner)
22 testRunner.notifyDone();
25 function runTest()
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);
30 forgottenDB.transaction(function(tx) {
31 tx.executeSql("CREATE TABLE IF NOT EXISTS EmptyTable (unimportantData)", []);
32 }, function(err) {
33 log("Forgotten Database Transaction Errored - " + err);
34 forgottenDB = 0;
35 GC();
36 checkCompletion();
37 }, function() {
38 log("Forgotten Database Transaction Complete");
39 forgottenDB = 0;
40 GC();
41 checkCompletion();
42 });
44 persistentDB.transaction(function(tx) {
45 tx.executeSql("CREATE TABLE IF NOT EXISTS DataTest (randomData)", [], function(tx, result) {
46 for (var i = 0; i < 25; ++i)
47 tx.executeSql("INSERT INTO DataTest (randomData) VALUES (1)", []);
48 });
49 }, function(err) {
50 log("Persistent Database Transaction Errored - " + err);
51 checkCompletion();
52 }, function() {
53 log("Persistent Database Transaction Complete");
54 checkCompletion();
55 });