Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / idbcursor_continueprimarykey.html
blobcde33506032da94c213fc11f3b88b0e7fb0efe29
1 <!DOCTYPE html>
2 <title>IndexedDB: IDBCursor continuePrimaryKey() method</title>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <script>
7 async_test(function(t) {
8 var dbname = document.location + '-' + t.name;
9 var del = indexedDB.deleteDatabase(dbname);
10 del.onerror = t.unreached_func('deleteDatabase should succeed');
11 var open = indexedDB.open(dbname);
12 open.onerror = t.unreached_func('open should succeed');
14 open.onupgradeneeded = t.step_func(function() {
15 var db = open.result;
16 var store = db.createObjectStore('store');
17 store.put('a', 1).onerror = t.unreached_func('put should not fail');
18 var request = store.openCursor();
19 request.onerror = t.unreached_func('openCursor should not fail');
20 request.onsuccess = t.step_func(function() {
21 var cursor = request.result;
22 assert_class_string(cursor, 'IDBCursorWithValue',
23 'result should be a cursor');
25 assert_throws('InvalidAccessError', function() {
26 cursor.continuePrimaryKey(2, 2);
27 }, 'continuePrimaryKey() should throw if source is not an index');
28 });
29 });
31 open.onsuccess = t.step_func(function() {
32 var db = open.result;
33 db.close();
34 t.done();
35 });
37 }, 'IDBCursor continuePrimaryKey() on object store cursor');
41 direction: 'nextunique',
42 expected_key: 1, expected_primaryKey: 'a',
43 continue_key: 2, continue_primaryKey: 'a'
46 direction: 'prevunique',
47 expected_key: 3, expected_primaryKey: 'a',
48 continue_key: 2, continue_primaryKey: 'a'
50 ].forEach(function(testcase) {
51 async_test(function(t) {
52 var dbname = document.location + '-' + t.name;
53 var del = indexedDB.deleteDatabase(dbname);
54 del.onerror = t.unreached_func('deleteDatabase should succeed');
55 var open = indexedDB.open(dbname);
56 open.onerror = t.unreached_func('open should succeed');
58 open.onupgradeneeded = t.step_func(function() {
59 var db = open.result;
60 var store = db.createObjectStore('store', {keyPath: 'pk'});
61 var index = store.createIndex('index', 'ik', {multiEntry: true});
62 store.put({pk: 'a', ik: [1,2,3]}).onerror =
63 t.unreached_func('put should not fail');
64 store.put({pk: 'b', ik: [1,2,3]}).onerror =
65 t.unreached_func('put should not fail');
66 var request = index.openKeyCursor(null, testcase.direction);
67 request.onerror = t.unreached_func('openCursor should not fail');
68 request.onsuccess = t.step_func(function() {
69 var cursor = request.result;
70 assert_class_string(cursor, 'IDBCursor',
71 'result should be a cursor');
72 assert_equals(cursor.direction, testcase.direction,
73 'direction should be as specified');
74 assert_equals(cursor.key, testcase.expected_key,
75 'key should match');
76 assert_equals(cursor.primaryKey, testcase.expected_primaryKey,
77 'primaryKey should match');
79 assert_throws('InvalidAccessError', function() {
80 cursor.continuePrimaryKey(
81 testcase.continue_key,
82 testcase.continue_primaryKey);
83 }, 'continuePrimaryKey() should throw if direction is unique');
84 });
85 });
87 open.onsuccess = t.step_func(function() {
88 var db = open.result;
89 db.close();
90 t.done();
91 });
93 }, 'IDBCursor continuePrimaryKey() on "' + testcase.direction + '" cursor');
94 });
96 </script>