Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / intversion-two-opens-no-versions.js
bloba1dbfbd57f302aaf5cd1c2fddbb5e634ba5c912d
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("Test that only the first open call gets an upgradeneeded");
8 function test()
10     setDBNameFromPath();
12     request = evalAndLog("indexedDB.deleteDatabase(dbname)");
13     request.onsuccess = deleteSuccess;
14     request.onerror = unexpectedErrorCallback;
17 var gotFirstUpgradeNeededEvent = false;
18 var gotSecondUpgradeNeededEvent = false;
19 function deleteSuccess(evt) {
20     request = evalAndLog("indexedDB.open(dbname)");
21     evalAndLog("request.onsuccess = connection1OpenSuccess");
22     evalAndLog("request.onupgradeneeded = connection1UpgradeNeeded");
23     request.onerror = unexpectedErrorCallback;
24     request.onblocked = unexpectedBlockedCallback;
26     request = evalAndLog("indexedDB.open(dbname)");
27     evalAndLog("request.onsuccess = connection2OpenSuccess");
28     evalAndLog("request.onupgradeneeded = connection2UpgradeNeeded");
29     request.onerror = unexpectedErrorCallback;
30     request.onblocked = unexpectedBlockedCallback;
33 function connection1UpgradeNeeded(evt)
35     preamble(evt);
36     evalAndLog("gotFirstUpgradeNeededEvent = true");
37     shouldBe("event.oldVersion", "0");
38     shouldBe("event.newVersion", "1");
41 function connection1OpenSuccess(evt)
43     preamble(evt);
44     db = evalAndLog("db = event.target.result");
45     shouldBeTrue("gotFirstUpgradeNeededEvent");
46     shouldBe("db.version", "1");
49 function connection2UpgradeNeeded(evt)
51     preamble(evt);
52     evalAndLog("gotSecondUpgradeNeededEvent = true");
55 function connection2OpenSuccess(evt)
57     preamble(evt);
58     db = evalAndLog("db = event.target.result");
59     shouldBeFalse("gotSecondUpgradeNeededEvent");
60     shouldBe("db.version", "1");
61     finishJSTest();
64 test();