Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / create-object-store-options.js
blob8797438e8365b4d32f8c851826afb904edd4a277
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})");
26     req.onsuccess = putB;
27     req.onerror = unexpectedErrorCallback;
29     evalAndExpectExceptionClass("db.createObjectStore('d', 'bar');", "TypeError");
30     evalAndExpectExceptionClass("db.createObjectStore('e', false);", "TypeError");
33 function putB()
35     req = evalAndLog("trans.objectStore('b').put({'a': 0}, 0)");  // OOPS
36     req.onsuccess = getA;
37     req.onerror = unexpectedErrorCallback;
40 function getA()
42     req = evalAndLog("trans.objectStore('a').get(0)");
43     req.onsuccess = getB;
44     req.onerror = unexpectedErrorCallback;
47 function getB()
49     shouldBe("event.target.result.a", "{a: 0}");
51     req = evalAndLog("trans.objectStore('b').get(0)");
52     req.onsuccess = checkB;
53     req.onerror = unexpectedErrorCallback;
56 function checkB()
58     shouldBe("event.target.result.a", "{a: 0}");
60     finishJSTest();