Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
idb-keyval reported IDBTransaction.error if a `set` operation failed. However, based on my reading of the IndexedDB spec, and based on testing, IDBTransaction.error may not be set at the time the `error` event fires. This can be seen under the following scenarios: - If IDBObjectStore.add fails because a key already exists - If a quota is exceeded in Safari - If the transaction is aborted immediately after an IndexedDB operation is requested The `error` event's EventTarget should give the specific IDBRequest that failed, and that IDBRequest's error property should always be populated, so accessing `event.target` should fix this issue. I tried using a similar approach for `abort` events, but it did not work; strangely, the abort event's target appears to be the IDBOpenRequest associated with the transaction, rather than the transaction itself, so it does not have a usable error property. This PR also adds limited unit tests to cover this scenario. Aborting a transaction immediately after issuing a database request appears to be a good way to force an error. Fixes jakearchibald#163
- Loading branch information