Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / versionchangerequest-activedomobject.js
blob9ac3806d725197e4d7d33b48bee88a6d17b8c274
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("Ensure that IDBVersionChangeRequest objects are not GC'd if they have pending events");
8 function test() {
9     debug("");
10     evalAndLog("self.dbname = 'versionchangerequest-activedomobject'");
12     testDeleteDatabase();
15 function testDeleteDatabase()
17     debug("");
18     debug("testDeleteDatabase():");
19     // NOTE: deleteRequest is local variable so it is not captured in global scope.
20     var deleteRequest = evalAndLog("indexedDB.deleteDatabase(self.dbname)");
21     deleteRequest.onerror = unexpectedErrorCallback;
22     deleteRequest.onblocked = unexpectedBlockedCallback;
23     deleteRequest.onsuccess = function() { deleteSuccess(); };
24     deleteRequest = null;
25     if (self.gc) {
26         evalAndLog("self.gc()");
27     }
30 function deleteSuccess()
32     testPassed("deleteDatabase's IDBVersionChangeRequest.onsuccess event fired");
33     testSetVersion();
36 function testSetVersion()
38     debug("");
39     debug("testSetVersion():");
41     // NOTE: openRequest is local variable so it is not captured in global
42     // scope.
43     var openRequest = evalAndLog("indexedDB.open(self.dbname)");
44     openRequest.onerror = unexpectedErrorCallback;
45     openRequest.onblocked = unexpectedBlockedCallback;
46     openRequest.onupgradeneeded = upgradeNeededCallback;
47     openRequest.onsuccess = successCallback;
48     openRequest = null;
49     if (self.gc) {
50         evalAndLog("self.gc()");
51     }
54 function upgradeNeededCallback()
56     testPassed("IDBOpenDBRequest received upgradeneeded event");
59 function successCallback()
61     testPassed("IDBOpenDBRequest received success event");
62     finishJSTest();
65 test();