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

Unified Diff: LayoutTests/storage/indexeddb/objectstore-getall.html

Issue 1303983002: IndexedDB: Treat count of 0 as unbounded for getAll() methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review feedback Created 5 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/storage/indexeddb/objectstore-getall.html
diff --git a/LayoutTests/storage/indexeddb/objectstore-getall.html b/LayoutTests/storage/indexeddb/objectstore-getall.html
index 05e2349a0f4da7254b87bd30f0afa932ff98b376..fc4f5d11a63acdcdf7f57650e608d465d10f7277 100644
--- a/LayoutTests/storage/indexeddb/objectstore-getall.html
+++ b/LayoutTests/storage/indexeddb/objectstore-getall.html
@@ -4,6 +4,8 @@
<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);
@@ -40,7 +41,7 @@ function createGetAllRequest(t, storeName, connection, range, maxCount) {
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();
+ range !== undefined ? store.getAll(range) : store.getAll();
req.onerror = t.unreached_func('getAll request should succeed');
return req;
}
@@ -50,7 +51,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
async_test(function(t) {
var req = createGetAllRequest(t, 'out-of-line', connection, 'c');
req.onsuccess = t.step_func(function(evt) {
- assert_array_equals(evt.target.result, ['c']);
+ assert_array_equals(evt.target.result, ['value-c']);
t.done();
});
}, 'Single item get');
@@ -61,7 +62,8 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, 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_equals(data[0].id, 3);
+ assert_equals(data[0].ch, 'c');
t.done();
});
}, 'Single item get (generated key)');
@@ -79,7 +81,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
var req = createGetAllRequest(t, 'out-of-line', connection);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result,
- 'abcdefghijklmnopqrstuvwxyz'.split(''));
+ alphabet.map(c => 'value-' + c));
t.done();
});
}, 'Get all values');
@@ -89,7 +91,8 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
10);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result,
- ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']);
+ ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
+ .map(c => 'value-' + c));
t.done();
});
}, 'Test maxCount');
@@ -99,7 +102,8 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
IDBKeyRange.bound('g', 'm'));
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result,
- ['g', 'h', 'i', 'j', 'k', 'l', 'm']);
+ ['g', 'h', 'i', 'j', 'k', 'l', 'm']
+ .map(c => 'value-' + c));
t.done();
});
}, 'Get bound range');
@@ -108,7 +112,8 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
var req = createGetAllRequest(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']);
+ assert_array_equals(evt.target.result, ['g', 'h', 'i']
+ .map(c => 'value-' + c));
t.done();
});
}, 'Get bound range with maxCount');
@@ -117,7 +122,8 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
var req = createGetAllRequest(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']);
+ assert_array_equals(evt.target.result, ['g', 'h', 'i', 'j']
+ .map(c => 'value-' + c));
t.done();
});
}, 'Get upper excluded');
@@ -126,7 +132,8 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
var req = createGetAllRequest(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']);
+ assert_array_equals(evt.target.result, ['h', 'i', 'j', 'k']
+ .map(c => 'value-' + c));
t.done();
});
}, 'Get lower excluded');
@@ -137,10 +144,8 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
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.map(e => e.ch), ['d', 'e', 'f']);
+ assert_array_equals(data.map(e => e.id), [4, 5, 6]);
t.done();
});
}, 'Get bound range (generated) with maxCount');
@@ -157,12 +162,12 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
}, '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 = createGetAllRequest(t, 'out-of-line', connection, undefined, 0);
+ req.onsuccess = t.step_func(function(evt) {
+ assert_array_equals(evt.target.result,
+ alphabet.map(c => 'value-' + c));
+ t.done();
+ });
}, 'zero maxCount');
});
« no previous file with comments | « LayoutTests/storage/indexeddb/index-getallkeys.html ('k') | LayoutTests/storage/indexeddb/objectstore-getallkeys.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698