Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / aborted-versionchange-closes.js
blob592db3dff840a302508778233e02c925ec349e80
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("Test that an aborted 'versionchange' transaction closes the connection.");
8 indexedDBTest(prepareDatabase, onOpen, {version: 1});
9 function prepareDatabase(evt)
11     preamble(evt);
12     evalAndLog("db = event.target.result");
13     evalAndLog("db.createObjectStore('store')");
16 function onOpen(evt)
18     preamble(evt);
19     evalAndLog("db = event.target.result");
20     evalAndLog("db.close()");
21     openAgain();
24 function openAgain() {
25     preamble();
26     evalAndLog("request = indexedDB.open(dbname, 2)");
27     request.onsuccess = unexpectedSuccessCallback;
28     request.onblocked = unexpectedBlockedCallback;
29     request.onupgradeneeded = onUpgradeNeeded;
30     request.onerror = onOpenError;
33 function onUpgradeNeeded(evt)
35     preamble(evt);
36     evalAndLog("db = event.target.result");
37     evalAndLog("transaction = event.target.transaction");
38     evalAndLog("sawTransactionAbort = false");
39     transaction.oncomplete = unexpectedCompleteCallback;
40     transaction.onabort = onTransactionAbort;
41     transaction.abort();
44 function onTransactionAbort(evt)
46     preamble(evt);
47     evalAndLog("sawTransactionAbort = true");
48     debug("creating a transaction should fail because connection is closed:");
49     evalAndExpectException("db.transaction('store')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
52 function onOpenError(evt)
54     preamble(evt);
55     shouldBeTrue("sawTransactionAbort");
56     debug("creating a transaction should fail because connection is closed:");
57     evalAndExpectException("db.transaction('store')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
58     finishJSTest();