Closed Bug 872873 Opened 11 years ago Closed 9 years ago

ConstraintError in IndexedDB should not throw error

Categories

(Core :: Storage: IndexedDB, defect)

24 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: kyawtun, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.13 (KHTML, like Gecko) Chrome/24.0.1284.0 (Dart) Safari/537.13

Steps to reproduce:

put a record that violate database contraint causing ConstraintError.

In that case, onerror event callback is invoked with ConstraintError http://www.w3.org/TR/IndexedDB/#dfn-steps-for-storing-a-record-into-an-object-store request and abort the algorithm. But browser must not throw Error. 


Actual results:

Firefox throw error

See unit test http://dev.yathit.com/test/test_crud.html 
also compare with Chrome, it pass the unit test.


Expected results:

Firefox should not throw error
Component: Untriaged → Web Apps
Component: Web Apps → DOM: IndexedDB
Product: Firefox → Core
Running into this issue building IndexedDB helpers. Firefox throws a constraintError in a way that doesn't seem to be able to be caught and suppressed. Nasty stuff.
Testcase?
Flags: needinfo?(mclaypotch)
To be clear, wrapping the offending code in a try...catch block does not catch the ConstraintError. There doesn't seem to be a way to continue gracefully after the error. It's a big problem.
Making a testcase.
Added testcase URL. The ConstraintError can't be caught (as it's the result of an async operation). Hard to build friendly abstractions on top of it. My intern's current project is trying to put promise wrappers around indexedDB, and this is an example of where the abstraction leaks.
Flags: needinfo?(mclaypotch)
You have to call |e.preventDefault()| in your onerror handler if you want to prevent the event from firing on the window and prevent your transaction from being aborted.
This is weird, so we need always preventDefault, or it will getting to the window.
Well, the big deal is that your transaction is normally aborted if you ever trigger an error event... This behavior is correct per spec, so closing.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.