Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / setversion-not-blocked.js
blob44384dc7f2f427521a82207a314ba7e33f7c9abb
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("Test that setVersion is not blocked if handle closed in versionchange handler.");
8 indexedDBTest(prepareDatabase, onOpen);
9 evalAndLog("versionchangeEventFired = false");
10 function prepareDatabase(evt)
12     preamble(evt);
13     evalAndLog("h1 = event.target.result");
14     evalAndLog("h1.onversionchange = h1OnVersionChange");
17 function h1OnVersionChange(evt)
19     preamble(evt);
20     evalAndLog("versionchangeEventFired = true");
21     shouldBe("event.oldVersion", "1");
22     shouldBe("event.newVersion", "2");
23     evalAndLog("h1.close()");
26 function onOpen(evt)
28     request = evalAndLog("indexedDB.open(dbname, 2)");
29     request.onerror = unexpectedErrorCallback;
30     request.onblocked = unexpectedBlockedCallback;
31     request.onupgradeneeded = function h2UpgradeNeeded(evt) {
32         preamble(evt);
33         shouldBe("event.oldVersion", "1");
34         shouldBe("event.newVersion", "2");
35     };
36     request.onsuccess = function h2OpenSuccess(evt) {
37         preamble(evt);
38         shouldBeTrue("versionchangeEventFired");
39         finishJSTest();
40     };