Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/IndexedDB/idbindex_getAllKeys.html

Issue 1419013007: update-w3c-deps import using blink 83a52878976eaffc8753993a7689c9c178664fba: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>IndexedDB: Test IDBIndex.getAllKeys.</title> 2 <title>IndexedDB: Test IDBIndex.getAllKeys.</title>
3 <script src="../../resources/testharness.js"></script> 3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script> 4 <script src="../../../resources/testharnessreport.js"></script>
5 <script> 5 <script>
6 setup({explicit_done: true});
6 7
7 var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''); 8 var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
8 9
9 function doSetup(dbName, dbVersion, onsuccess) { 10 function doSetup(dbName, dbVersion, onsuccess) {
10 var delete_request = indexedDB.deleteDatabase(dbName); 11 var delete_request = indexedDB.deleteDatabase(dbName);
11 delete_request.onerror = function() { 12 delete_request.onerror = function() {
12 assert_unreached('deleteDatabase should not fail'); 13 assert_unreached('deleteDatabase should not fail');
13 }; 14 };
14 delete_request.onsuccess = function(e) { 15 delete_request.onsuccess = function(e) {
15 var req = indexedDB.open(dbName, dbVersion); 16 var req = indexedDB.open(dbName, dbVersion);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 store = connection.createObjectStore('empty', null); 52 store = connection.createObjectStore('empty', null);
52 index = store.createIndex('test_idx', 'upper'); 53 index = store.createIndex('test_idx', 'upper');
53 }; 54 };
54 }; 55 };
55 } 56 }
56 57
57 function createGetAllKeysRequest(t, storeName, connection, range, maxCount) { 58 function createGetAllKeysRequest(t, storeName, connection, range, maxCount) {
58 var transaction = connection.transaction(storeName, 'readonly'); 59 var transaction = connection.transaction(storeName, 'readonly');
59 var store = transaction.objectStore(storeName); 60 var store = transaction.objectStore(storeName);
60 var index = store.index('test_idx'); 61 var index = store.index('test_idx');
61 // TODO(cmumford): Simplify once crbug.com/335871 is fixed. 62 var req = index.getAllKeys(range, maxCount);
62 var req = maxCount !== undefined ? index.getAllKeys(range, maxCount) :
63 range !== undefined ? index.getAllKeys(range) :
64 index.getAllKeys();
65 req.onerror = t.unreached_func('getAllKeys request should succeed'); 63 req.onerror = t.unreached_func('getAllKeys request should succeed');
66 return req; 64 return req;
67 } 65 }
68 66
69 doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) { 67 doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
70 var connection = evt.target.result; 68 var connection = evt.target.result;
71 async_test(function(t) { 69 async_test(function(t) {
72 var req = createGetAllKeysRequest(t, 'out-of-line', connection, 'C'); 70 var req = createGetAllKeysRequest(t, 'out-of-line', connection, 'C');
73 req.onsuccess = t.step_func(function(evt) { 71 req.onsuccess = t.step_func(function(evt) {
74 var data = evt.target.result; 72 var data = evt.target.result;
(...skipping 29 matching lines...) Expand all
104 'getAllKeys() should return 1..26'); 102 'getAllKeys() should return 1..26');
105 t.done(); 103 t.done();
106 }); 104 });
107 }, 'Get all generated keys'); 105 }, 'Get all generated keys');
108 106
109 async_test(function(t) { 107 async_test(function(t) {
110 var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined, 108 var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined,
111 10); 109 10);
112 req.onsuccess = t.step_func(function(evt) { 110 req.onsuccess = t.step_func(function(evt) {
113 assert_array_equals(evt.target.result, 111 assert_array_equals(evt.target.result,
114 ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], 112 'abcdefghij'.split(''),
115 'getAllKeys() should return a..j'); 113 'getAllKeys() should return a..j');
116 t.done(); 114 t.done();
117 }); 115 });
118 }, 'maxCount=10'); 116 }, 'maxCount=10');
119 117
120 async_test(function(t) { 118 async_test(function(t) {
121 var req = createGetAllKeysRequest(t, 'out-of-line', connection, 119 var req = createGetAllKeysRequest(t, 'out-of-line', connection,
122 IDBKeyRange.bound('G', 'M')); 120 IDBKeyRange.bound('G', 'M'));
123 req.onsuccess = t.step_func(function(evt) { 121 req.onsuccess = t.step_func(function(evt) {
124 assert_array_equals(evt.target.result, 122 assert_array_equals(evt.target.result,
125 ['g', 'h', 'i', 'j', 'k', 'l', 'm'], 123 'ghijklm'.split(''),
126 'getAllKeys() should return g..m'); 124 'getAllKeys() should return g..m');
127 t.done(); 125 t.done();
128 }); 126 });
129 }, 'Get bound range'); 127 }, 'Get bound range');
130 128
131 async_test(function(t) { 129 async_test(function(t) {
132 var req = createGetAllKeysRequest(t, 'out-of-line', connection, 130 var req = createGetAllKeysRequest(t, 'out-of-line', connection,
133 IDBKeyRange.bound('G', 'M'), 3); 131 IDBKeyRange.bound('G', 'M'), 3);
134 req.onsuccess = t.step_func(function(evt) { 132 req.onsuccess = t.step_func(function(evt) {
135 assert_array_equals(evt.target.result, 133 assert_array_equals(evt.target.result,
136 ['g', 'h', 'i'], 134 ['g', 'h', 'i'],
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 192
195 async_test(function(t) { 193 async_test(function(t) {
196 var req = createGetAllKeysRequest(t, 'out-of-line-multi', connection, 194 var req = createGetAllKeysRequest(t, 'out-of-line-multi', connection,
197 'vowel'); 195 'vowel');
198 req.onsuccess = t.step_func(function(evt) { 196 req.onsuccess = t.step_func(function(evt) {
199 assert_array_equals(evt.target.result, ['A','E','I','O','U']) 197 assert_array_equals(evt.target.result, ['A','E','I','O','U'])
200 t.done(); 198 t.done();
201 }); 199 });
202 req.onerror = t.unreached_func('getAllKeys request should succeed'); 200 req.onerror = t.unreached_func('getAllKeys request should succeed');
203 }, 'Retrieve multiEntry keys'); 201 }, 'Retrieve multiEntry keys');
202
203 // Explicit done needed in case async_test body fails synchronously.
204 done();
204 }); 205 });
205 206
206 </script> 207 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698