Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / connection-leak.html
blob86db507e93daefdcc98677f59838abcd0f15bd93
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script src="resources/shared.js"></script>
4 <script>
6 description("Regression test to ensure that IndexedDB connections don't leak");
8 setDBNameFromPath();
9 waitForRequests([
10 indexedDB.deleteDatabase(dbname)
11 ], doFirstOpen);
13 function doFirstOpen()
15 preamble();
17 evalAndLog("request = indexedDB.open(dbname, 1)");
18 evalAndLog("sawUpgradeNeeded1 = false");
19 request.onerror = unexpectedErrorCallback;
20 request.onblocked = unexpectedBlockedCallback;
21 request.onupgradeneeded = function onUpgradeNeeded1() {
22 preamble();
23 evalAndLog("sawUpgradeNeeded1 = true");
25 request.onsuccess = function onOpenSuccess1() {
26 preamble();
27 shouldBeTrue("sawUpgradeNeeded1");
28 evalAndLog("db = request.result");
29 evalAndLog("db.close()");
31 doSecondOpen();
35 function doSecondOpen()
37 preamble();
39 evalAndLog("request = indexedDB.open(dbname, 1)");
40 request.onerror = unexpectedErrorCallback;
41 request.onblocked = unexpectedBlockedCallback;
42 request.onupgradeneeded = unexpectedUpgradeNeededCallback;
43 request.onsuccess = function onOpenSuccess2() {
44 preamble();
45 evalAndLog("db = request.result");
47 evalAndLog("db = null");
48 evalAndLog("request = null");
50 debug("Run GC outside of request's callback via setTimeout()");
51 setTimeout( function() {
52 evalAndLog("window.gc()");
53 doThirdOpen();
54 }, 0);
58 function doThirdOpen()
60 preamble();
62 evalAndLog("request = indexedDB.open(dbname, 2)");
63 evalAndLog("sawUpgradeNeeded3 = false");
64 request.onerror = unexpectedErrorCallback;
65 request.onblocked = unexpectedBlockedCallback;
66 request.onupgradeneeded = function onUpgradeNeeded2() {
67 preamble();
68 evalAndLog("sawUpgradeNeeded3 = true");
70 request.onsuccess = function onOpenSuccess3() {
71 preamble();
72 shouldBeTrue("sawUpgradeNeeded3");
73 evalAndLog("db = request.result");
74 evalAndLog("db.close()");
76 finishJSTest();
80 </script>