1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test that integer versions are retained when backing store is opened/closed/re-opened.");
12 // NOTE: deleteDatabase is not used, otherwise it would set the backing store schema version
13 // which would conceal the failure being tested for. Instead, a unique name is used each time.
14 evalAndLog("dbname = dbname + Date.now()");
19 function openFirstTime() {
21 request = evalAndLog("indexedDB.open(dbname, 1)");
22 request.onerror = unexpectedErrorCallback;
23 request.onblocked = unexpectedBlockedCallback;
24 upgradeNeededFired = false;
25 request.onupgradeneeded = function() {
26 evalAndLog("db = request.result");
27 evalAndLog("upgradeNeededFired = true");
28 shouldBe("db.version", "1");
29 shouldBe("db.objectStoreNames.length", "0");
30 evalAndLog("db.createObjectStore('store')");
32 request.onsuccess = function() {
33 shouldBeTrue("upgradeNeededFired");
34 evalAndLog("db = request.result");
35 shouldBe("db.version", "1");
36 shouldBe("db.objectStoreNames.length", "1");
37 evalAndLog("db.close()");
42 function openSecondTime() {
44 request = evalAndLog("indexedDB.open(dbname, 1)");
45 request.onerror = unexpectedErrorCallback;
46 request.onblocked = unexpectedBlockedCallback;
47 request.onupgradeneeded = unexpectedUpgradeNeededCallback;
48 request.onsuccess = function() {
49 evalAndLog("db = request.result");
50 shouldBe("db.version", "1");
51 shouldBe("db.objectStoreNames.length", "1");
52 evalAndLog("db.close()");