Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / database-deletepending-flag.js
blob28d0c591e61ca5d97e18f1dcc6a33395f134d385
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("Test IndexedDB IDBDatabase internal delete pending flag");
8 indexedDBTest(prepareDatabase, testDatabaseDelete, {"version": 5});
9 function prepareDatabase()
11     connection = event.target.result;
12     evalAndLog("connection.createObjectStore('store')");
13     shouldBe("connection.objectStoreNames.length", "1");
16 function testDatabaseDelete()
18     debug("");
19     debug("Issue a delete request against the database - should be blocked by the open connection:");
20     evalAndLog("deleteRequest = indexedDB.deleteDatabase(dbname)");
21     deleteRequest.onerror = unexpectedErrorCallback;
22     evalAndLog("state = 0");
24     debug("");
25     debug("Open a second connection - should be delayed:");
26     evalAndLog("openRequest = indexedDB.open(dbname)");
27     openRequest.onerror = unexpectedErrorCallback;
29     connection.onversionchange = function() {
30         debug("");
31         debug("connection received versionchange event - ignoring.");
32         shouldBe("++state", "1");
33     };
35     deleteRequest.onblocked = function() {
36         debug("");
37         debug("deleteRequest received blocked event.");
38         shouldBe("++state", "2");
39         evalAndLog("connection.close()");
40         debug("deleteRequest should now be unblocked.");
41     };
43     deleteRequest.onsuccess = function() {
44         debug("");
45         debug("deleteRequest received success event.");
46         shouldBe("++state", "3");
47         debug("openRequest should now be unblocked.");
48     };
50     openRequest.onsuccess = function() {
51         debug("");
52         testPassed("openRequest received success event.");
53         shouldBe("++state", "4");
54         evalAndLog("connection2 = openRequest.result");
56         debug("connection2 should reference a different database:");
57         shouldBeFalse("connection2.version == connection.version");
58         shouldBe("connection2.objectStoreNames.length", "0");
60         debug("");
61         finishJSTest();
62     };