blob: 981f48bcbfba0cdadd0c9bd702b4d5cdeea40c2a [file] [log] [blame]
if (this.importScripts) {
importScripts('../../../resources/js-test.js');
importScripts('shared.js');
}
description("Test that setVersion is not blocked if handle closed in versionchange handler.");
indexedDBTest(prepareDatabase, onOpen);
evalAndLog("blockedEventFired = false");
evalAndLog("versionchangeEventFired = false");
function prepareDatabase(evt)
{
preamble(evt);
evalAndLog("h1 = event.target.result");
evalAndLog("h1.onversionchange = h1OnVersionChange");
}
function h1OnVersionChange(evt)
{
preamble(evt);
evalAndLog("versionchangeEventFired = true");
shouldBe("event.oldVersion", "1");
shouldBe("event.newVersion", "2");
evalAndLog("h1.close()");
}
function onOpen(evt)
{
request = evalAndLog("indexedDB.open(dbname, 2)");
request.onerror = unexpectedErrorCallback;
request.onblocked = function h2OpenBlocked(evt) {
preamble(evt);
shouldBe("event.oldVersion", "1");
shouldBe("event.newVersion", "2");
evalAndLog("blockedEventFired = true");
};
request.onupgradeneeded = function h2UpgradeNeeded(evt) {
preamble(evt);
shouldBe("event.oldVersion", "1");
shouldBe("event.newVersion", "2");
};
request.onsuccess = function h2OpenSuccess(evt) {
preamble(evt);
shouldBeTrue("versionchangeEventFired");
shouldBeFalse("blockedEventFired");
finishJSTest();
};
}