iterate cursor number of times specified by count ‣
Error: Uncaught TypeError: Cannot read properties of undefined (reading 'equal') (https://indexeddbshim.github.io/IndexedDBShim/tests-polyfill/w3c/IDBCursor.advance.js:162)
var db,
count = 0,
records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" },
{ pKey: "primaryKey_2", iKey: "indexKey_2" },
{ pKey: "primaryKey_3", iKey: "indexKey_3" }];
var open_rq = createdb(done);
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
var store = db.createObjectStore("test", {keyPath:"pKey"});
store.createIndex("idx", "iKey");
for(var i = 0; i < records.length; i++) {
store.add(records[i]);
}
};
open_rq.onsuccess = function (e) {
var cursor_rq = db.transaction("test")
.objectStore("test")
.index("idx")
.openCursor();
cursor_rq.onsuccess = function(e) {
var cursor = e.target.result;
assert(cursor instanceof FDBCursor);
switch(count) {
case 0:
count += 3;
cursor.advance(3);
break;
case 3:
var record = cursor.value;
assert.equal(record.pKey, records[count].pKey, "record.pKey");
assert.equal(record.iKey, records[count].iKey, "record.iKey");
done();
break;
default:
throw new Error("unexpected count");
break;
}
};
}
iterate cursor number of times specified by count ‣
Error: Uncaught TypeError: Cannot read properties of undefined (reading 'equal') (https://indexeddbshim.github.io/IndexedDBShim/tests-polyfill/w3c/IDBCursor.advance.js:162)
var db,
count = 0,
records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" },
{ pKey: "primaryKey_2", iKey: "indexKey_2" },
{ pKey: "primaryKey_3", iKey: "indexKey_3" }];
var open_rq = createdb(done);
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
var store = db.createObjectStore("test", {keyPath:"pKey"});
store.createIndex("idx", "iKey");
for(var i = 0; i < records.length; i++) {
store.add(records[i]);
}
};
open_rq.onsuccess = function (e) {
var cursor_rq = db.transaction("test")
.objectStore("test")
.index("idx")
.openCursor();
cursor_rq.onsuccess = function(e) {
var cursor = e.target.result;
assert(cursor instanceof FDBCursor);
switch(count) {
case 0:
count += 3;
cursor.advance(3);
break;
case 3:
var record = cursor.value;
assert.equal(record.pKey, records[count].pKey, "record.pKey");
assert.equal(record.iKey, records[count].iKey, "record.iKey");
done();
break;
default:
throw new Error("unexpected count");
break;
}
};
}
attempt to pass a count parameter that is not a number ‣
Error: Uncaught AbortError: The transaction was aborted, so the request cannot be fulfilled. (https://indexeddbshim.github.io/IndexedDBShim/tests-polyfill/w3c/IDBCursor.advance.js:177)
var db,
records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" } ];
var open_rq = createdb(done);
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
var objStore = db.createObjectStore("test", {keyPath:"pKey"});
objStore.createIndex("index", "iKey");
for(var i = 0; i < records.length; i++)
objStore.add(records[i]);
};
open_rq.onsuccess = function(e) {
var cursor_rq = db.transaction("test")
.objectStore("test")
.index("index")
.openCursor();
cursor_rq.onsuccess = function(e) {
var cursor = e.target.result;
assert(cursor != null, "cursor exist");
assert.throws(
function() { cursor.advance(window.document); }, TypeError);
done();
};
};
attempt to advance backwards ‣
Error: Uncaught TypeError: assert is not a function (https://indexeddbshim.github.io/IndexedDBShim/tests-polyfill/w3c/IDBCursor.advance.js:600)
var db,
records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" } ];
var open_rq = createdb(done);
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
var objStore = db.createObjectStore("test", { keyPath:"pKey" });
objStore.createIndex("index", "iKey");
for (var i = 0; i < records.length; i++)
objStore.add(records[i]);
};
open_rq.onsuccess = function(e) {
var cursor_rq = db.transaction("test")
.objectStore("test")
.index("index")
.openCursor(undefined, "next");
cursor_rq.onsuccess = function(e) {
var cursor = e.target.result;
assert(cursor != null, "cursor exist");
assert.throws(
function() { cursor.advance(-1); }, TypeError);
done();
};
};
iterate to the next record ‣
Error: Uncaught TypeError: assert is not a function (https://indexeddbshim.github.io/IndexedDBShim/tests-polyfill/w3c/IDBCursor.advance.js:647)
var db,
count = 0,
records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" },
{ pKey: "primaryKey_1-2", iKey: "indexKey_1" } ],
expected = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1-2", iKey: "indexKey_1" } ];
var open_rq = createdb(done);
open_rq.onupgradeneeded = function(e) {
db = e.target.result
var objStore = db.createObjectStore("test", { keyPath:"pKey" })
objStore.createIndex("index", "iKey")
for (var i = 0; i < records.length; i++)
objStore.add(records[i])
};
open_rq.onsuccess = function(e) {
var cursor_rq = db.transaction("test")
.objectStore("test")
.index("index")
.openCursor();
cursor_rq.onsuccess = function(e) {
var cursor = e.target.result;
if (!cursor) {
assert.equal(count, expected.length, "cursor run count")
return done()
}
var record = cursor.value;
assert.equal(record.pKey, expected[count].pKey, "primary key");
assert.equal(record.iKey, expected[count].iKey, "index key");
cursor.advance(2);
count++;
};
};
throw TypeError ‣
Error: Uncaught TypeError: assert is not a function (https://indexeddbshim.github.io/IndexedDBShim/tests-polyfill/w3c/IDBCursor.advance.js:682)
var db,
records = [{ pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" }];
var open_rq = createdb(done);
open_rq.onupgradeneeded = function (event) {
db = event.target.result;
var objStore = db.createObjectStore("store", {keyPath : "pKey"});
objStore.createIndex("index", "iKey");
for (var i = 0; i < records.length; i++) {
objStore.add(records[i]);
}
var rq = objStore.index("index").openCursor();
rq.onsuccess = function(event) {
var cursor = event.target.result;
assert(cursor instanceof FDBCursor);
assert.throws(function() {
cursor.advance(0);
}, TypeError, null, "Calling advance() with count argument 0 should throw TypeError.");
done();
};
}
open_rq.onsuccess = function () {};
throw TransactionInactiveError ‣
Error: Uncaught TypeError: assert is not a function (https://indexeddbshim.github.io/IndexedDBShim/tests-polyfill/w3c/IDBCursor.advance.js:752)
var db,
records = [{ pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" }];
var open_rq = createdb(done);
open_rq.onupgradeneeded = function (event) {
db = event.target.result;
var objStore = db.createObjectStore("store", {keyPath : "pKey"});
objStore.createIndex("index", "iKey");
for (var i = 0; i < records.length; i++) {
objStore.add(records[i]);
}
var rq = objStore.index("index").openCursor();
rq.onsuccess = function(event) {
var cursor = event.target.result;
assert(cursor instanceof FDBCursor);
event.target.transaction.abort();
support.throws(function() {
cursor.advance(1);
}, 'TransactionInactiveError', "Calling advance() should throws an exception TransactionInactiveError when the transaction is not active.");
done();
};
}
open_rq.onerror = function () {};
throw InvalidStateError ‣
Error: Uncaught TypeError: assert is not a function (https://indexeddbshim.github.io/IndexedDBShim/tests-polyfill/w3c/IDBCursor.advance.js:781)
var db,
records = [{ pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" }];
var open_rq = createdb(done);
open_rq.onupgradeneeded = function (event) {
db = event.target.result;
var objStore = db.createObjectStore("store", {keyPath : "pKey"});
objStore.createIndex("index", "iKey");
for (var i = 0; i < records.length; i++) {
objStore.add(records[i]);
}
var rq = objStore.index("index").openCursor();
var reallyDone = false;
rq.onsuccess = function(event) {
var cursor = event.target.result;
if (cursor) {
assert(cursor instanceof FDBCursor);
cursor.advance(1);
support.throws(function() {
cursor.advance(1);
}, 'InvalidStateError', "Calling advance() should throw DOMException when the cursor is currently being iterated.");
if (!reallyDone) {
reallyDone = true;
done();
}
}
};
}
open_rq.onsuccess = function () {};
throw InvalidStateError ‣
Error: Uncaught TypeError: assert is not a function (https://indexeddbshim.github.io/IndexedDBShim/tests-polyfill/w3c/IDBCursor.advance.js:781)
var db,
records = [{ pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" }];
var open_rq = createdb(done);
open_rq.onupgradeneeded = function (event) {
db = event.target.result;
var objStore = db.createObjectStore("store", {keyPath : "pKey"});
objStore.createIndex("index", "iKey");
for (var i = 0; i < records.length; i++) {
objStore.add(records[i]);
}
var rq = objStore.index("index").openCursor();
var reallyDone = false;
rq.onsuccess = function(event) {
var cursor = event.target.result;
if (cursor) {
assert(cursor instanceof FDBCursor);
cursor.advance(1);
support.throws(function() {
cursor.advance(1);
}, 'InvalidStateError', "Calling advance() should throw DOMException when the cursor is currently being iterated.");
if (!reallyDone) {
reallyDone = true;
done();
}
}
};
}
open_rq.onsuccess = function () {};