Skip to content

Validate exception ordering against implementations #11

Closed

Description

@inexorabletash

The various "If .... throw ...." statements were left in order from previous iterations of the spec which asserted behavior but didn't define it as formal steps.

We need to verify that the steps match the implementations in the case of conflicts, and reorder if necessary. If implementations disagree, file implementation bugs as necessary.

NOTE: Checkboxes below indicate that at least 2 implementations and the spec are in alignment.

Activity

  1. inexorabletash commented on Jun 1, 2015

    @inexorabletash
    MemberAuthor

    IDBDatabase

    Normal Methods

    • transaction
      • WPT: upstream blink's idbdatabase-transaction-exception-order.html
      • FF: InvalidStateError (closed/version) > InvalidAccessError (empty) > NotFoundError > TypeError (mode)
      • Cr: InvalidStateError (closed/version) > InvalidAccessError (empty) > NotFoundError > TypeError (mode)

    Schema Mutations

    • createObjectStore:
      • WPT: upstream blink's idbdatabase-createObjectStore-exception-order.html
      • FF: InvalidStateError > TransactionInactiveError > SyntaxError > ConstraintError > InvalidAccessError
      • Cr: InvalidStateError > TransactionInactiveError > SyntaxError > ConstraintError > InvalidAccessError
    • deleteObjectStore
      • WPT: upstream blink's idbdatabase-deleteObjectStore-exception-order.html
      • FF: InvalidStateError > TransactionInactiveError > NotFoundError
      • Cr: InvalidStateError > TransactionInactiveError > NotFoundError
  2. inexorabletash commented on Jun 1, 2015

    @inexorabletash
    MemberAuthor

    IDBObjectStore

    Normal Methods

    • add/put/delete:
      • WPT: upstream blink's idbobjectstore-add-put-exception-order.html
      • WPT: upstream blink's idbobjectstore-delete-exception-order.html
      • FF: InvalidStateError (deleted) > TransactionInactiveError > ReadOnlyError > DataError
      • Cr: InvalidStateError (deleted) > TransactionInactiveError > ReadOnlyError > DataError
    • clear
      • WPT: upstream blink's idbobjectstore-clear-exception-order.html
      • FF: InvalidStateError (deleted) > TransactionInactiveError > ReadOnlyError
      • Cr: InvalidStateError (deleted) > TransactionInactiveError > ReadOnlyError
    • get/getAll/getAllKeys/count/openCursor/openKeyCursor
      • WPT: upstream blink's idbobjectstore-query-exception-order.html
      • FF: InvalidStateError (deleted) > TransactionInactiveError > DataError
      • Cr: InvalidStateError (deleted) > TransactionInactiveError > DataError

    Schema Mutations

    • createIndex
      • WPT: IndexedDB/idbobjectstore_createIndex14-exception_order.htm
      • FF: InvalidStateError (mode) > InvalidStateError (deleted) > TransactionInactiveError > ConstraintError > SyntaxError > InvalidAccessError
      • Cr: InvalidStateError (mode) > InvalidStateError (deleted) > TransactionInactiveError > ConstraintError > SyntaxError > InvalidAccessError
    • deleteIndex
      • WPT: upstream blink's idbobjectstore-deleteIndex-exception-order.html
      • FF: InvalidStateError (mode) > InvalidStateError (deleted) > TransactionInactiveError > NotFoundError
      • Cr: InvalidStateError (mode) > InvalidStateError (deleted) > TransactionInactiveError > NotFoundError
  3. inexorabletash commented on Jun 1, 2015

    @inexorabletash
    MemberAuthor

    IDBIndex

    • get/getKey/getAll/getAllKeys/count/openCursor/openKeyCursor
      • WPT: upstream blink's idbindex-query-exception-order.html
      • FF: InvalidStateError (deleted) > TransactionInactiveError > DataError
      • Cr: InvalidStateError (deleted) > TransactionInactiveError > DataError
  4. inexorabletash commented on Jun 1, 2015

    @inexorabletash
    MemberAuthor

    IDBCursor

    • advance
      • WPT: upstream Blink's idbcursor-advance-exception-order.html
      • FF: TypeError > TransactionInactiveError > InvalidStateError (deleted) > InvalidStateError (got)
      • Cr: TypeError > TransactionInactiveError > InvalidStateError (deleted) > InvalidStateError (got)
    • continue
      • WPT: upstream Blink's idbcursor-continue-exception-order.html
      • FF: TransactionInactiveError > InvalidStateError (deleted) > InvalidStateError (got) > DataError (key) > DataError (order)
      • Cr: TransactionInactiveError > InvalidStateError (deleted) > InvalidStateError (got) > DataError (key) > DataError (order)
    • continuePrimaryKey
      • WPT: IndexedDB/idbcursor-continuePrimaryKey-exception-order.htm
      • FF: TransactionInactiveError > InvalidStateError (deleted) > InvalidAccessError (source) > InvalidAccessError (direction) > InvalidStateError (got) > DataError (key) > DataError (order)
      • Cr: TransactionInactiveError > InvalidStateError (deleted) > InvalidAccessError (source) > InvalidAccessError (direction) > InvalidStateError (got) > DataError (key) > DataError (order)
    • delete
      • WPT: upstream blink's idbcursor-delete-exception-order.html
      • FF: TransactionInactiveError > ReadOnlyError > InvalidStateError (deleted) > InvalidStateError (got) > InvalidStateError (key cursor)
      • Cr: TransactionInactiveError > ReadOnlyError > InvalidStateError (deleted) > InvalidStateError (got) > InvalidStateError (key cursor)
    • update
      • WPT: upstream blink's idbcursor-update-exception-order.html
      • FF: TransactionInactiveError > ReadOnlyError > InvalidStateError (deleted) > InvalidStateError (got) > InvalidStateError (key cursor) > DataError (key)
      • Cr: TransactionInactiveError > ReadOnlyError > InvalidStateError (deleted) > InvalidStateError (got) > InvalidStateError (key cursor) > DataError (key)
  5. inexorabletash commented on Jun 1, 2015

    @inexorabletash
    MemberAuthor

    IDBTransaction

    • abort
      • FF: InvalidStateError (finished)
      • Cr: InvalidStateError (finished)
    • objectStore
      • WPT: upstream blink's idbtransaction-objectStore-exception-order.html
      • FF: InvalidStateError (finished) > NotFoundError
      • Cr: InvalidStateError (finished) > NotFoundError
  6. odinho commented on Jun 16, 2015

    @odinho
    Member

    Great. At one point we should also get some tests on these things to make it simpler to implement and follow. :)

  7. inexorabletash commented on Jun 16, 2015

    @inexorabletash
    MemberAuthor

    @velmont - Yes please! Writing tests for these is a bit intimidating, since some cases involve upgrades, many involve async behavior (e.g. trying to use a transaction in a non-IDB callback but before the transaction has committed), etc. And, of course, this is all about combinations of the above. Ugh!

    I documented the Blink and Gecko behavior via code inspection, since that was easy.

    If anyone wants to help with writing testharness.js-based tests for these please let me know and I'll assist as best I can. I'm also happy to tweak the Chrome ordering; the cursor APIs are particularly funky, but until we have tests I don't want to change anything.

  8. inexorabletash commented on Jun 25, 2015

    @inexorabletash
    MemberAuthor

    Updated notes above for FF based on code inspection, following comments by @benturner #23

  9. inexorabletash commented on Sep 23, 2016

    @inexorabletash
    MemberAuthor
  10. inexorabletash commented on Sep 23, 2016

    @inexorabletash
    MemberAuthor

    And tests there can be upstreamed to wpt

  11. added this to the V2 milestone on Sep 23, 2016
  12. inexorabletash commented on Oct 12, 2016

    @inexorabletash
    MemberAuthor

    Following a change yesterday in Chrome, FF and Cr match in all cases. \o/ But we still need tests - there are a bunch to upstream from blink (see WPT:... lines above) - mostly for "v2" stuff or where we have changed to align recently.

  13. beidson commented on Oct 21, 2016

    @beidson

    Order of exceptions thrown from renaming object stores and indexes differs

    For IDBIndex, the name attribute’s setter runs these steps:
    ...
    4. If transaction is not an upgrade transaction, throw an InvalidStateError.
    5. If transaction is not active, throw a TransactionInactiveError.
    6. If index or index’s object store has been deleted, throw an InvalidStateError.
    7. If index’s name is equal to name, terminate these steps.
    8. If an index named name already exists in index’s object store, throw a ConstraintError.
    ...

    For IDBObjectStore, the name attribute's setter runs these steps:
    ...
    4. If store has been deleted, throw an InvalidStateError.
    5. If transaction is not an upgrade transaction, throw an InvalidStateError.
    6. If transaction is not active, throw a TransactionInactiveError.
    7. If store’s name is equal to name, terminate these steps.
    8. If an object store named name already exists in store’s database, throw a ConstraintError.
    ...

    The "if the is deleted..." exception is in different places for each of these, but should be in the same place.

    I'm implementing these in WebKit now and really don't want to follow the spec on this. Could we pick one or the other?

  14. inexorabletash commented on Oct 21, 2016

    @inexorabletash
    MemberAuthor

    @bevis-tseng and @pwnall - what do you think about making the changes @beidson proposes? i.e. swap the order in one of the two methods?

  15. pwnall commented on Oct 23, 2016

    @pwnall

    I'm fine with either order.

    While building apps, I used to get thrown off by random errors while debugging my code, so I hope we can converge on some ordering. I can change Chrome to adopt any ordering Firefox and Safari would like to use.

  16. bevis-tseng commented on Oct 24, 2016

    @bevis-tseng

    FYI.
    These were done in identical order in FF for both IDBObjectStore/IDBIndex [1][2]:
    4. If transaction is not an upgrade transaction or if the (store|index) was deleted, throw an InvalidStateError.
    5. If transaction is not active, throw a TransactionInactiveError.
    6. If the name is identical, terminate these steps.
    ...

    [1] http://searchfox.org/mozilla-central/rev/84075be5067b68dc6cb3b89f999645650e68c05b/dom/indexedDB/IDBObjectStore.cpp#2205-2219
    [2] http://searchfox.org/mozilla-central/rev/84075be5067b68dc6cb3b89f999645650e68c05b/dom/indexedDB/IDBIndex.cpp#159-172

  17. beidson commented on Oct 24, 2016

    @beidson

    WebKit now matches Gecko's ordering.
    I suggest we codify that.

  18. inexorabletash commented on Jan 13, 2017

    @inexorabletash
    MemberAuthor

    WebKit now matches Gecko's ordering.
    I suggest we codify that.

    Somehow I missed that comment. Yay!

    So far as I know WebKit/Gecko/Blink all match and those match the spec. If that's not the case please submit a web-platform-test case!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions