Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / intversion-abort-in-initial-upgradeneeded.js
blob8d4b7d4702a54386e70c0a368e4c7ed856443c61
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("Test that an abort in the initial upgradeneeded sets version back to 0");
8 function test()
10     setDBNameFromPath();
12     request = evalAndLog("indexedDB.deleteDatabase(dbname)");
13     request.onsuccess = deleteSuccess;
14     request.onerror = unexpectedErrorCallback;
17 function deleteSuccess() {
18     request = evalAndLog("indexedDB.open(dbname, 2)");
19     request.onsuccess = unexpectedSuccessCallback;
20     evalAndLog("request.onupgradeneeded = upgradeNeeded");
21     evalAndLog("request.onerror = onError");
22     request.onblocked = unexpectedBlockedCallback;
25 function upgradeNeeded(evt)
27     preamble(evt);
28     db = event.target.result;
29     shouldBe("db.version", "2");
30     transaction = event.target.transaction;
31     transaction.oncomplete = unexpectedCompleteCallback;
32     transaction.onabort = onAbort;
33     evalAndLog("transaction.abort()");
36 function onAbort(evt)
38     preamble(evt);
39     shouldBe("event.target.db.version", "0");
40     shouldBeNonNull("request.transaction");
43 function onError(evt)
45     preamble(evt);
46     shouldBe("request", "event.target");
47     shouldBeUndefined("event.target.result");
48     shouldBeNonNull("event.target.error");
49     shouldBeEqualToString("event.target.error.name", "AbortError");
50     shouldBeNull("request.transaction");
51     finishJSTest();
54 test();