for (let i = 0; i < objectStoreData.length - 1; i++) {
objectStore.add(objectStoreData[i]);
}
yield undefined;
let count = 0;
let sawAdded = false;
let sawRemoved = false;
db.transaction("foo").objectStore("foo").openCursor().onsuccess = function (
event
) {
event.target.transaction.oncomplete = continueToNextStep;
let cursor = event.target.result; if (cursor) { if (cursor.value.name == objectStoreData[0].name) {
sawRemoved = true;
} if (
cursor.value.name == objectStoreData[objectStoreData.length - 1].name
) {
sawAdded = true;
}
cursor.continue();
count++;
}
};
yield undefined;
is(count, objectStoreData.length - 1, "Good initial count");
is(sawAdded, false, "Didn't see item that is about to be added");
is(sawRemoved, true, "Saw item that is about to be removed");
count = 0;
sawAdded = false;
sawRemoved = false;
db
.transaction("foo", "readwrite")
.objectStore("foo")
.index("name")
.openCursor().onsuccess = function (event) {
event.target.transaction.oncomplete = continueToNextStep;
let cursor = event.target.result; if (cursor) { if (cursor.value.name == objectStoreData[0].name) {
sawRemoved = true;
} if (
cursor.value.name == objectStoreData[objectStoreData.length - 1].name
) {
sawAdded = true;
}
if (count == 1) {
let objectStore = event.target.transaction.objectStore("foo");
objectStore.delete(objectStoreData[0].ss).onsuccess = function () {
objectStore.add(
objectStoreData[objectStoreData.length - 1]
).onsuccess = function () {
cursor.continue();
};
};
} else {
cursor.continue();
}
}
};
yield undefined;
is(count, objectStoreData.length - 1, "Good final count");
is(sawAdded, true, "Saw item that was added");
is(sawRemoved, false, "Didn't see item that was removed");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.