Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / cursor-overloads.html
blobe159247414514f14fac7bdaeec044f7ce03d07be
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script src="resources/shared.js"></script>
4 <script>
5 description("Validate the overloads of IDBObjectStore.openCursor(), IDBIndex.openCursor() and IDBIndex.openKeyCursor().");
7 indexedDBTest(prepareDatabase, verifyOverloads);
8 function prepareDatabase()
10 db = event.target.result;
11 event.target.transaction.onabort = unexpectedAbortCallback;
12 evalAndLog("store = db.createObjectStore('store')");
13 evalAndLog("index = store.createIndex('index', 'value')");
14 evalAndLog("store.put({value: 0}, 0)");
17 function verifyOverloads()
19 debug("");
20 debug("verifyOverloads():");
21 evalAndLog("trans = db.transaction('store')");
22 evalAndLog("store = trans.objectStore('store')");
23 evalAndLog("index = store.index('index')");
25 checkCursorDirection("store.openCursor()", "next");
26 checkCursorDirection("store.openCursor(0)", "next");
27 checkCursorDirection("store.openCursor(0, 'next')", "next");
28 checkCursorDirection("store.openCursor(0, 'nextunique')", "nextunique");
29 checkCursorDirection("store.openCursor(0, 'prev')", "prev");
30 checkCursorDirection("store.openCursor(0, 'prevunique')", "prevunique");
32 checkCursorDirection("store.openCursor(IDBKeyRange.only(0))", "next");
33 checkCursorDirection("store.openCursor(IDBKeyRange.only(0), 'next')", "next");
34 checkCursorDirection("store.openCursor(IDBKeyRange.only(0), 'nextunique')", "nextunique");
35 checkCursorDirection("store.openCursor(IDBKeyRange.only(0), 'prev')", "prev");
36 checkCursorDirection("store.openCursor(IDBKeyRange.only(0), 'prevunique')", "prevunique");
38 checkCursorDirection("store.openKeyCursor()", "next");
39 checkCursorDirection("store.openKeyCursor(0)", "next");
40 checkCursorDirection("store.openKeyCursor(0, 'next')", "next");
41 checkCursorDirection("store.openKeyCursor(0, 'nextunique')", "nextunique");
42 checkCursorDirection("store.openKeyCursor(0, 'prev')", "prev");
43 checkCursorDirection("store.openKeyCursor(0, 'prevunique')", "prevunique");
45 checkCursorDirection("store.openKeyCursor(IDBKeyRange.only(0))", "next");
46 checkCursorDirection("store.openKeyCursor(IDBKeyRange.only(0), 'next')", "next");
47 checkCursorDirection("store.openKeyCursor(IDBKeyRange.only(0), 'nextunique')", "nextunique");
48 checkCursorDirection("store.openKeyCursor(IDBKeyRange.only(0), 'prev')", "prev");
49 checkCursorDirection("store.openKeyCursor(IDBKeyRange.only(0), 'prevunique')", "prevunique");
51 checkCursorDirection("index.openCursor()", "next");
52 checkCursorDirection("index.openCursor(0)", "next");
53 checkCursorDirection("index.openCursor(0, 'next')", "next");
54 checkCursorDirection("index.openCursor(0, 'nextunique')", "nextunique");
55 checkCursorDirection("index.openCursor(0, 'prev')", "prev");
56 checkCursorDirection("index.openCursor(0, 'prevunique')", "prevunique");
58 checkCursorDirection("index.openCursor(IDBKeyRange.only(0))", "next");
59 checkCursorDirection("index.openCursor(IDBKeyRange.only(0), 'next')", "next");
60 checkCursorDirection("index.openCursor(IDBKeyRange.only(0), 'nextunique')", "nextunique");
61 checkCursorDirection("index.openCursor(IDBKeyRange.only(0), 'prev')", "prev");
62 checkCursorDirection("index.openCursor(IDBKeyRange.only(0), 'prevunique')", "prevunique");
64 checkCursorDirection("index.openKeyCursor()", "next");
65 checkCursorDirection("index.openKeyCursor(0)", "next");
66 checkCursorDirection("index.openKeyCursor(0, 'next')", "next");
67 checkCursorDirection("index.openKeyCursor(0, 'nextunique')", "nextunique");
68 checkCursorDirection("index.openKeyCursor(0, 'prev')", "prev");
69 checkCursorDirection("index.openKeyCursor(0, 'prevunique')", "prevunique");
71 checkCursorDirection("index.openKeyCursor(IDBKeyRange.only(0))", "next");
72 checkCursorDirection("index.openKeyCursor(IDBKeyRange.only(0), 'next')", "next");
73 checkCursorDirection("index.openKeyCursor(IDBKeyRange.only(0), 'nextunique')", "nextunique");
74 checkCursorDirection("index.openKeyCursor(IDBKeyRange.only(0), 'prev')", "prev");
75 checkCursorDirection("index.openKeyCursor(IDBKeyRange.only(0), 'prevunique')", "prevunique");
77 trans.oncomplete = finishJSTest;
80 function checkCursorDirection(statement, direction)
82 request = eval(statement);
83 request.onerror = unexpectedErrorCallback;
84 request.onsuccess = function() {
85 debug(statement);
86 shouldBeNonNull("event.target.result")
87 shouldBeEqualToString("event.target.result.direction", direction);
91 </script>