Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / create-and-remove-object-store.js
blob6e6fdb7e456a83b9417265cd4b8466234bbb90d5
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("Test IndexedDB's create and removeObjectStore");
8 indexedDBTest(prepareDatabase, setVersionComplete);
9 function prepareDatabase()
11     db = event.target.result;
12     event.target.transaction.onabort = unexpectedAbortCallback;
13     os = evalAndLog("db.createObjectStore('tmp')");
14     evalAndExpectException("db.createObjectStore('tmp')", "0", "'ConstraintError'");
17 function setVersionComplete()
19     trans = evalAndLog("trans = db.transaction(['tmp'])");
20     request = evalAndLog("trans.objectStore('tmp').get(0)");
21     request.onsuccess = tryToCreateAndDelete;
22     request.onerror = unexpectedErrorCallback;
25 function tryToCreateAndDelete()
27     shouldBeUndefined("event.target.result");
29     debug("Trying create");
30     evalAndExpectException('db.createObjectStore("some os")', "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
31     debug("Trying remove");
32     evalAndExpectException('db.deleteObjectStore("some os")', "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
34     debug("Trying create with store that already exists");
35     evalAndExpectException("db.createObjectStore('tmp')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
36     debug("Trying remove with store that already exists");
37     evalAndExpectException("db.deleteObjectStore('tmp')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
39     finishJSTest();