Index: LayoutTests/storage/indexeddb/objectstore-getallkeys.html |
diff --git a/LayoutTests/storage/indexeddb/objectstore-getall.html b/LayoutTests/storage/indexeddb/objectstore-getallkeys.html |
similarity index 64% |
copy from LayoutTests/storage/indexeddb/objectstore-getall.html |
copy to LayoutTests/storage/indexeddb/objectstore-getallkeys.html |
index 05e2349a0f4da7254b87bd30f0afa932ff98b376..8ca26eac529be274ab0c62da1df9e305668a6f27 100644 |
--- a/LayoutTests/storage/indexeddb/objectstore-getall.html |
+++ b/LayoutTests/storage/indexeddb/objectstore-getallkeys.html |
@@ -1,9 +1,11 @@ |
<!DOCTYPE html> |
-<title>IndexedDB: Test IDBObjectStore.getAll.</title> |
+<title>IndexedDB: Test IDBObjectStore.getAllKeys.</title> |
<script src="../../resources/testharness.js"></script> |
<script src="../../resources/testharnessreport.js"></script> |
<script> |
+var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''); |
+ |
function doSetup(dbName, dbVersion, onsuccess) { |
var delete_request = indexedDB.deleteDatabase(dbName); |
delete_request.onerror = function() { |
@@ -17,7 +19,6 @@ function doSetup(dbName, dbVersion, onsuccess) { |
}; |
req.onupgradeneeded = function(evt) { |
var connection = evt.target.result; |
- var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''); |
var store = connection.createObjectStore('generated', |
{autoIncrement: true, keyPath: 'id'}); |
@@ -27,7 +28,7 @@ function doSetup(dbName, dbVersion, onsuccess) { |
store = connection.createObjectStore('out-of-line', null); |
alphabet.forEach(function(letter) { |
- store.put(letter, letter); |
+ store.put('value-' + letter, letter); |
}); |
store = connection.createObjectStore('empty', null); |
@@ -35,20 +36,21 @@ function doSetup(dbName, dbVersion, onsuccess) { |
}; |
} |
-function createGetAllRequest(t, storeName, connection, range, maxCount) { |
+function createGetAllKeysRequest(t, storeName, connection, range, maxCount) { |
var transaction = connection.transaction(storeName, 'readonly'); |
var store = transaction.objectStore(storeName); |
// TODO(cmumford): Simplify once crbug.com/335871 is closed. |
- var req = maxCount !== undefined ? store.getAll(range, maxCount) : |
- range !== undefined ? store.getAll(range) : store.getAll(); |
- req.onerror = t.unreached_func('getAll request should succeed'); |
+ var req = maxCount !== undefined ? store.getAllKeys(range, maxCount) : |
+ range !== undefined ? store.getAllKeys(range) : |
+ store.getAllKeys(); |
+ req.onerror = t.unreached_func('getAllKeys request should succeed'); |
return req; |
} |
-doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) { |
+doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) { |
var connection = evt.target.result; |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'out-of-line', connection, 'c'); |
+ var req = createGetAllKeysRequest(t, 'out-of-line', connection, 'c'); |
req.onsuccess = t.step_func(function(evt) { |
assert_array_equals(evt.target.result, ['c']); |
t.done(); |
@@ -56,36 +58,35 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) { |
}, 'Single item get'); |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'generated', connection, 3); |
+ var req = createGetAllKeysRequest(t, 'generated', connection, 3); |
req.onsuccess = t.step_func(function(evt) { |
var data = evt.target.result; |
assert_true(Array.isArray(data)); |
- assert_equals(data.length, 1); |
- assert_object_equals(data[0], {ch: 'c', id: 3}); |
+ assert_array_equals(data, [3]); |
t.done(); |
}); |
}, 'Single item get (generated key)'); |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'empty', connection); |
+ var req = createGetAllKeysRequest(t, 'empty', connection); |
req.onsuccess = t.step_func(function(evt) { |
assert_array_equals(evt.target.result, [], |
- 'getAll() on empty object store should return an empty array'); |
+ 'getAllKeys() on empty object store should return an empty ' + |
+ 'array'); |
t.done(); |
}); |
- }, 'getAll on empty object store'); |
+ }, 'getAllKeys on empty object store'); |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'out-of-line', connection); |
+ var req = createGetAllKeysRequest(t, 'out-of-line', connection); |
req.onsuccess = t.step_func(function(evt) { |
- assert_array_equals(evt.target.result, |
- 'abcdefghijklmnopqrstuvwxyz'.split('')); |
+ assert_array_equals(evt.target.result, alphabet); |
t.done(); |
}); |
}, 'Get all values'); |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'out-of-line', connection, undefined, |
+ var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined, |
10); |
req.onsuccess = t.step_func(function(evt) { |
assert_array_equals(evt.target.result, |
@@ -95,7 +96,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) { |
}, 'Test maxCount'); |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'out-of-line', connection, |
+ var req = createGetAllKeysRequest(t, 'out-of-line', connection, |
IDBKeyRange.bound('g', 'm')); |
req.onsuccess = t.step_func(function(evt) { |
assert_array_equals(evt.target.result, |
@@ -105,7 +106,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) { |
}, 'Get bound range'); |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'out-of-line', connection, |
+ var req = createGetAllKeysRequest(t, 'out-of-line', connection, |
IDBKeyRange.bound('g', 'm'), 3); |
req.onsuccess = t.step_func(function(evt) { |
assert_array_equals(evt.target.result, ['g', 'h', 'i']); |
@@ -114,7 +115,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) { |
}, 'Get bound range with maxCount'); |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'out-of-line', connection, |
+ var req = createGetAllKeysRequest(t, 'out-of-line', connection, |
IDBKeyRange.bound('g', 'k', false, true)); |
req.onsuccess = t.step_func(function(evt) { |
assert_array_equals(evt.target.result, ['g', 'h', 'i', 'j']); |
@@ -123,7 +124,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) { |
}, 'Get upper excluded'); |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'out-of-line', connection, |
+ var req = createGetAllKeysRequest(t, 'out-of-line', connection, |
IDBKeyRange.bound('g', 'k', true, false)); |
req.onsuccess = t.step_func(function(evt) { |
assert_array_equals(evt.target.result, ['h', 'i', 'j', 'k']); |
@@ -132,37 +133,35 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) { |
}, 'Get lower excluded'); |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'generated', connection, |
+ var req = createGetAllKeysRequest(t, 'generated', connection, |
IDBKeyRange.bound(4, 15), 3); |
req.onsuccess = t.step_func(function(evt) { |
var data = evt.target.result; |
assert_true(Array.isArray(data)); |
- assert_equals(data.length, 3); |
- assert_object_equals(data[0], {ch: 'd', id: 4}); |
- assert_object_equals(data[1], {ch: 'e', id: 5}); |
- assert_object_equals(data[2], {ch: 'f', id: 6}); |
+ assert_array_equals(data, [4, 5, 6]); |
t.done(); |
}); |
}, 'Get bound range (generated) with maxCount'); |
async_test(function(t) { |
- var req = createGetAllRequest(t, 'out-of-line', connection, |
+ var req = createGetAllKeysRequest(t, 'out-of-line', connection, |
"Doesn't exist"); |
req.onsuccess = t.step_func(function(evt) { |
assert_array_equals(evt.target.result, [], |
- 'getAll() using a nonexistent key should return an empty array'); |
+ 'getAllKeys() using a nonexistent key should return an ' + |
+ 'empty array'); |
t.done(); |
}); |
- req.onerror = t.unreached_func('getAll request should succeed'); |
+ req.onerror = t.unreached_func('getAllKeys request should succeed'); |
}, 'Non existent key'); |
async_test(function(t) { |
- var transaction = connection.transaction('out-of-line', 'readonly'); |
- var store = transaction.objectStore('out-of-line'); |
- assert_throws(new TypeError(), function () { |
- store.getAll(undefined, 0); |
- }, 'getAll() with maxCount=0 should throw TypeError'); |
- t.done(); |
+ var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined, |
+ 0); |
+ req.onsuccess = t.step_func(function(evt) { |
+ assert_array_equals(evt.target.result, alphabet); |
+ t.done(); |
+ }); |
}, 'zero maxCount'); |
}); |