1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB's createObjectStore's various options");
8 indexedDBTest(prepareDatabase, setVersionComplete);
9 function prepareDatabase()
11 db = event.target.result;
13 evalAndLog("db.createObjectStore('a', {keyPath: 'a'})");
14 evalAndLog("db.createObjectStore('b')");
16 debug("db.createObjectStore('c', {autoIncrement: true});");
17 db.createObjectStore('c', {autoIncrement: true});
20 function setVersionComplete()
22 trans = evalAndLog("trans = db.transaction(['a', 'b'], 'readwrite')");
23 shouldBeEqualToString("trans.mode", "readwrite");
25 req = evalAndLog("trans.objectStore('a').put({'a': 0})");
27 req.onerror = unexpectedErrorCallback;
29 evalAndExpectExceptionClass("db.createObjectStore('d', 'bar');", "TypeError");
30 evalAndExpectExceptionClass("db.createObjectStore('e', false);", "TypeError");
35 req = evalAndLog("trans.objectStore('b').put({'a': 0}, 0)"); // OOPS
37 req.onerror = unexpectedErrorCallback;
42 req = evalAndLog("trans.objectStore('a').get(0)");
44 req.onerror = unexpectedErrorCallback;
49 shouldBe("event.target.result.a", "{a: 0}");
51 req = evalAndLog("trans.objectStore('b').get(0)");
52 req.onsuccess = checkB;
53 req.onerror = unexpectedErrorCallback;
58 shouldBe("event.target.result.a", "{a: 0}");