Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / intversion-revert-on-abort.js
blob812bbda0fab382e5ac2c97980a5402a7ff85d3a1
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("Test that integer versions are reverted when their version transactions abort.");
8 function test()
10     setDBNameFromPath();
12     request = evalAndLog("indexedDB.deleteDatabase(dbname)");
13     request.onsuccess = deleteSuccess;
14     request.onerror = unexpectedErrorCallback;
17 function deleteSuccess(evt) {
18     evalAndLog("request = indexedDB.open(dbname, 2)");
19     request.onsuccess = openSuccess;
20     request.onerror = unexpectedErrorCallback;
21     request.onblocked = unexpectedBlockedCallback;
22     request.onupgradeneeded = firstUpgradeNeededCallback;
25 function firstUpgradeNeededCallback(evt)
27     preamble(evt);
28     evalAndLog("db = event.target.result");
29     evalAndLog("db.createObjectStore('some os')");
32 function openSuccess(evt)
34     preamble(evt);
35     evalAndLog("db = event.target.result");
36     shouldBe("db.version", "2");
37     evalAndLog("db.close()");
38     evalAndLog("request = indexedDB.open(dbname, 3)");
39     evalAndLog("request.onupgradeneeded = secondUpgradeNeededCallback");
40     evalAndLog("request.onerror = errorAfterAbortCallback");
41     request.onsuccess = unexpectedSuccessCallback;
42     request.onblocked = unexpectedBlockedCallback;
45 function secondUpgradeNeededCallback(evt)
47     preamble(evt);
48     evalAndLog("db = event.target.result");
49     evalAndLog("db.createObjectStore('some os 2')");
50     evalAndLog("event.target.transaction.abort()");
53 function errorAfterAbortCallback(evt)
55     preamble(evt);
56     shouldBe("db.version", "2");
57     evalAndLog("request = indexedDB.open(dbname)");
58     evalAndLog("request.onsuccess = finalSuccessCallback");
59     request.onerror = unexpectedErrorCallback;
60     request.onblocked = unexpectedBlockedCallback;
61     request.onupgradeneeded = unexpectedUpgradeNeededCallback;
64 function finalSuccessCallback(evt)
66     preamble(evt);
67     evalAndLog("db = event.target.result");
68     shouldBe("db.version", "2");
69     shouldBe("db.objectStoreNames.length", "1");
70     shouldBeEqualToString("db.objectStoreNames[0]", "some os");
71     finishJSTest();
74 test();