// Check that cursor.update work as expected
request = store.openCursor();
request.onerror = errorHandler;
request.onsuccess = grabEventAndContinueHandler;
e = yield undefined;
let cursor = e.target.result;
request = cursor.update(info.value);
request.onerror = errorHandler;
request.onsuccess = grabEventAndContinueHandler;
yield undefined;
ok(true, "Successfully updated cursor" + test);
// Check that cursor.update throws as expected when key is changed
let newValue = cursor.value;
let destProp = Array.isArray(info.keyPath) ? info.keyPath[0] : info.keyPath; if (destProp) {
let splitDestProp = destProp.split("."); if (splitDestProp.length == 1) {
newValue[splitDestProp[0]] = "newKeyValue";
} elseif (splitDestProp.length == 2) {
newValue[splitDestProp[0]][splitDestProp[1]] = "newKeyValue";
} else {
newValue[splitDestProp[0]][splitDestProp[1]][splitDestProp[2]] = "newKeyValue";
}
} else {
newValue = "newKeyValue";
}
let didThrow; try {
cursor.update(newValue);
} catch (ex) {
didThrow = ex;
}
ok(didThrow instanceof DOMException, "Got a DOMException" + test);
is(didThrow.name, "DataError", "expect a DataError" + test);
is(didThrow.code, 0, "expect zero" + test);
// Clear object store to prepare for next test
store.clear().onsuccess = grabEventAndContinueHandler;
yield undefined;
}
// Attempt to create indexes and insert data
let store = db.createObjectStore("indexStore");
let indexes = {}; for (let i = 0; i < keyPaths.length; i++) {
let info = keyPaths[i];
let test = " for index test " + JSON.stringify(info);
let indexName = JSON.stringify(info.keyPath); if (!indexes[indexName]) { try {
let index = store.createIndex(indexName, info.keyPath);
ok(!("exception" in info), "shouldn't throw" + test);
is(
JSON.stringify(index.keyPath),
JSON.stringify(info.keyPath), "index has correct keyPath property" + test
);
ok( // eslint-disable-next-line no-self-compare
index.keyPath === index.keyPath, "object identity should be preserved"
);
indexes[indexName] = index;
} catch (e) {
ok("exception" in info, "should throw" + test);
is(e.name, "SyntaxError", "expect a SyntaxError" + test);
ok(e instanceof DOMException, "Got a DOM Exception" + test);
is(e.code, DOMException.SYNTAX_ERR, "expect a syntax error" + test); continue;
}
}
let index = indexes[indexName];
request = store.add(info.value, 1); if ("key" in info) {
index.getKey(info.key).onsuccess = grabEventAndContinueHandler;
let e = yield undefined;
is(e.target.result, 1, "found value when reading" + test);
} else {
index.count().onsuccess = grabEventAndContinueHandler;
let e = yield undefined;
is(e.target.result, 0, "should be empty" + test);
}
store = db.createObjectStore("gen", {
keyPath: "foo.id",
autoIncrement: true,
}); for (let i = 0; i < aitests.length; ++i) {
let info = aitests[i];
let test = " for autoIncrement test " + JSON.stringify(info);
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.