Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / unblocked-version-changes.js
blob06e32cd1b334b4c72fe3bdc9166e90a0c9dc09be
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("Ensure that metadata remains correct when an aborted version change is followed by another. ");
8 function test() {
9     setDBNameFromPath();
10     request = evalAndLog("indexedDB.deleteDatabase(dbname)");
11     request.onblocked = unexpectedBlockedCallback;
12     request.onerror = unexpectedErrorCallback;
13     request.onsuccess = openConnection;
16 function openConnection()
18     preamble();
19     evalAndLog("request = indexedDB.open(dbname, 2)");
20     request.onblocked = unexpectedBlockedCallback;
21     request.onsuccess = unexpectedSuccessCallback;
22     request.onupgradeneeded = onUpgradeNeeded;
23     request.onerror = onError;
26 function onUpgradeNeeded(evt)
28     preamble(evt);
29     evalAndLog("db = request.result");
30     shouldBe("db.version", "2");
31     evalAndLog("transaction = request.transaction");
33     evalAndLog("request = indexedDB.open(dbname, 3)");
34     request.onerror = unexpectedErrorCallback;
35     request.onupgradeneeded = onUpgradeNeeded2;
36     request.onsuccess = onSuccess;
38     evalAndLog("transaction.abort()");
41 function onError(evt)
43     preamble(evt);
44     shouldBe("db.version", "0");
47 function onUpgradeNeeded2(evt)
49     preamble(evt);
50     evalAndLog("db = request.result");
51     shouldBe("db.version", "3");
54 function onSuccess(evt)
56     preamble(evt);
57     evalAndLog("db = request.result");
58     shouldBe("db.version", "3");
59     finishJSTest();
62 test();