Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / setversion-blocked-by-versionchange-close.js
blob1f9f1bd0d0377b32d234e200dad4ef7a0f622e60
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("h2 shouldn't receive any blocked events, and h3 should open after h2 is open");
7 indexedDBTest(prepareDatabase, openAnother);
8 function prepareDatabase()
10     evalAndLog("versionChangeComplete = false");
11     evalAndLog("h2Opened = false");
14 function openAnother(evt)
16     preamble(evt);
17     evalAndLog("h1 = event.target.result");
18     h1.onversionchange = unexpectedVersionChangeCallback;
19     request = evalAndLog("indexedDB.open(dbname, 2)");
20     request.onblocked = unexpectedBlockedCallback;
21     request.onerror = unexpectedErrorCallback;
22     request.onupgradeneeded = h2UpgradeNeeded;
23     request.onsuccess = h2Success;
25     request = evalAndLog("indexedDB.open(dbname)");
26     request.onblocked = unexpectedBlockedCallback;
27     request.onerror = unexpectedErrorCallback;
28     request.onupgradeneeded = unexpectedUpgradeNeededCallback;
29     request.onsuccess = h3Success;
30     evalAndLog("h1.close()");
33 function h2UpgradeNeeded(evt)
35     preamble(evt);
36     evalAndLog("h2 = event.target.result");
37     h2.onversionchange = unexpectedVersionChangeCallback;
38     transaction = event.target.transaction;
39     transaction.onabort = unexpectedAbortCallback;
40     transaction.oncomplete = function transactionOnComplete(evt) {
41         preamble(evt);
42         evalAndLog("versionChangeComplete = true");
43     };
46 function h2Success(evt)
48     preamble(evt);
49     evalAndLog("h2Opened = true");
52 function h3Success(evt)
54     preamble(evt);
55     evalAndLog("h3 = event.target.result");
56     shouldBe("h3.version", "2");
57     shouldBeTrue("versionChangeComplete");
58     shouldBeTrue("h2Opened");
59     finishJSTest();