// In between callbacks
transaction = db.transaction("foo"); function makeNewRequest() {
let r = transaction.objectStore("foo").get(1);
r.onsuccess = makeNewRequest;
r.onerror = abortErrorHandler;
}
makeNewRequest();
transaction.objectStore("foo").get(1).onsuccess = function () {
executeSoon(function () {
transaction.abort();
expectedAbortEventCount++;
continueToNextStep();
});
};
yield undefined;
// During COMMITTING
transaction = db.transaction("foo", "readwrite");
transaction.objectStore("foo").put({ hello: "world" }, 1).onsuccess = function () {
continueToNextStep();
};
yield undefined; try {
transaction.abort();
ok(false, "second abort should throw an error");
} catch (ex) {
ok(true, "second abort should throw an error");
}
transaction.oncomplete = grabEventAndContinueHandler;
event = yield undefined;
// Since the previous transaction shouldn't have caused any error events, // we know that all events should have fired by now.
is(abortEventCount, expectedAbortEventCount, "All abort errors fired");
// Abort both failing and succeeding requests
transaction = db.transaction("foo", "readwrite");
transaction.onabort = transaction.oncomplete = grabEventAndContinueHandler;
transaction.objectStore("foo").add({ indexKey: "key" }).onsuccess = function () {
transaction.abort();
};
let request1 = transaction.objectStore("foo").add({ indexKey: "key" });
request1.onsuccess = grabEventAndContinueHandler;
request1.onerror = grabEventAndContinueHandler;
let request2 = transaction.objectStore("foo").get(1);
request2.onsuccess = grabEventAndContinueHandler;
request2.onerror = grabEventAndContinueHandler;
event = yield undefined;
is(event.type, "error", "abort() should make all requests fail");
is(event.target, request1, "abort() should make all requests fail");
is(
event.target.error.name, "AbortError", "abort() should make all requests fail"
);
event.preventDefault();
event = yield undefined;
is(event.type, "error", "abort() should make all requests fail");
is(event.target, request2, "abort() should make all requests fail");
is(
event.target.error.name, "AbortError", "abort() should make all requests fail"
);
event.preventDefault();
event = yield undefined;
is(event.type, "abort", "transaction should fail");
is(event.target, transaction, "transaction should fail");
ok(abortFired, "Abort should have fired!");
finishTest();
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet am 2026-08-25)
¤
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.