This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
idbcursor_continue_index2.htm
62 lines (58 loc) · 2.42 KB
/
idbcursor_continue_index2.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<title>IDBCursor.continue() - index - attempt to pass a key parameter is not a valid key </title>
<script type="text/javascript" src="support.js"></script>
<script src="../testharness.js"></script>
<script src="../testharnessreport.js"></script>
<script src="/git/indexedDB.polyfill.debug.js"></script>
<script type="text/javascript">
var objectStoreName = "objectstore";
var indexName = "index";
var records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" }];
var db = null;
var t = async_test();
function RunTest() {
var rqOpen = window.indexedDB.open(databaseName, databaseVersion);
rqOpen.onupgradeneeded = t.step_func( function (event) {
db = event.target.result;
db.onerror = t.step_func( assert_database_error );
var objStore = db.createObjectStore(objectStoreName, {keyPath:"pKey"});
objStore.createIndex(indexName, "iKey");
for(var i = 0; i < records.length; i++) {
objStore.add(records[i]);
}
});
rqOpen.onsuccess = t.step_func( VerifyCursorThrowsException );
rqOpen.onerror = t.step_func( assert_open_request_error );
}
function VerifyCursorThrowsException(event) {
var txn = db.transaction(objectStoreName, "readonly");
var objStore = txn.objectStore(objectStoreName);
var index = objStore.index(indexName);
var rqCursor = index.openCursor();
rqCursor.onsuccess = t.step_func( function(event) {
var cursor = event.target.result;
assert_cursor_exists(cursor);
try {
cursor.continue(document);
} catch(ex) {
assert_equals(ex.name, "DataError", "ex.name");
t.done();
return;
}
assert_expected_exception();
});
}
add_completion_callback(function() { if(db) db.close(); });
setup(function() {
var rqDelete = window.indexedDB.deleteDatabase(databaseName);
rqDelete.onsuccess = t.step_func( RunTest );
});
</script>
</head>
<body>
<div id="log"></div>
</body>
</html>