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

Unified Diff: LayoutTests/storage/indexeddb/idbcursor_continueprimarykey.html

Issue 1188343002: IndexedDB: Disallow continuePrimaryKey on unique cursors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make assertion message more specific Created 5 years, 6 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
« no previous file with comments | « no previous file | Source/modules/indexeddb/IDBCursor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/storage/indexeddb/idbcursor_continueprimarykey.html
diff --git a/LayoutTests/storage/indexeddb/idbcursor_continueprimarykey.html b/LayoutTests/storage/indexeddb/idbcursor_continueprimarykey.html
index 186ac4d697c608254cd38ca90942fde363e15f49..cde33506032da94c213fc11f3b88b0e7fb0efe29 100644
--- a/LayoutTests/storage/indexeddb/idbcursor_continueprimarykey.html
+++ b/LayoutTests/storage/indexeddb/idbcursor_continueprimarykey.html
@@ -17,7 +17,7 @@ async_test(function(t) {
store.put('a', 1).onerror = t.unreached_func('put should not fail');
var request = store.openCursor();
request.onerror = t.unreached_func('openCursor should not fail');
- request.onsuccess = function() {
+ request.onsuccess = t.step_func(function() {
var cursor = request.result;
assert_class_string(cursor, 'IDBCursorWithValue',
'result should be a cursor');
@@ -25,7 +25,7 @@ async_test(function(t) {
assert_throws('InvalidAccessError', function() {
cursor.continuePrimaryKey(2, 2);
}, 'continuePrimaryKey() should throw if source is not an index');
- };
+ });
});
open.onsuccess = t.step_func(function() {
@@ -36,4 +36,61 @@ async_test(function(t) {
}, 'IDBCursor continuePrimaryKey() on object store cursor');
+[
+ {
+ direction: 'nextunique',
+ expected_key: 1, expected_primaryKey: 'a',
+ continue_key: 2, continue_primaryKey: 'a'
+ },
+ {
+ direction: 'prevunique',
+ expected_key: 3, expected_primaryKey: 'a',
+ continue_key: 2, continue_primaryKey: 'a'
+ }
+].forEach(function(testcase) {
+ async_test(function(t) {
+ var dbname = document.location + '-' + t.name;
+ var del = indexedDB.deleteDatabase(dbname);
+ del.onerror = t.unreached_func('deleteDatabase should succeed');
+ var open = indexedDB.open(dbname);
+ open.onerror = t.unreached_func('open should succeed');
+
+ open.onupgradeneeded = t.step_func(function() {
+ var db = open.result;
+ var store = db.createObjectStore('store', {keyPath: 'pk'});
+ var index = store.createIndex('index', 'ik', {multiEntry: true});
+ store.put({pk: 'a', ik: [1,2,3]}).onerror =
+ t.unreached_func('put should not fail');
+ store.put({pk: 'b', ik: [1,2,3]}).onerror =
+ t.unreached_func('put should not fail');
+ var request = index.openKeyCursor(null, testcase.direction);
+ request.onerror = t.unreached_func('openCursor should not fail');
+ request.onsuccess = t.step_func(function() {
+ var cursor = request.result;
+ assert_class_string(cursor, 'IDBCursor',
+ 'result should be a cursor');
+ assert_equals(cursor.direction, testcase.direction,
+ 'direction should be as specified');
+ assert_equals(cursor.key, testcase.expected_key,
+ 'key should match');
+ assert_equals(cursor.primaryKey, testcase.expected_primaryKey,
+ 'primaryKey should match');
+
+ assert_throws('InvalidAccessError', function() {
+ cursor.continuePrimaryKey(
+ testcase.continue_key,
+ testcase.continue_primaryKey);
+ }, 'continuePrimaryKey() should throw if direction is unique');
+ });
+ });
+
+ open.onsuccess = t.step_func(function() {
+ var db = open.result;
+ db.close();
+ t.done();
+ });
+
+ }, 'IDBCursor continuePrimaryKey() on "' + testcase.direction + '" cursor');
+});
+
</script>
« no previous file with comments | « no previous file | Source/modules/indexeddb/IDBCursor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698