Skip to content

Validate exception ordering against implementations #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
inexorabletash opened this issue May 18, 2015 · 18 comments
Closed

Validate exception ordering against implementations #11

inexorabletash opened this issue May 18, 2015 · 18 comments

Comments

@inexorabletash
Copy link
Member

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.

@inexorabletash
Copy link
Member Author

inexorabletash commented Jun 1, 2015

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

@inexorabletash
Copy link
Member Author

inexorabletash commented Jun 1, 2015

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

@inexorabletash
Copy link
Member Author

inexorabletash commented Jun 1, 2015

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

@inexorabletash
Copy link
Member Author

inexorabletash commented Jun 1, 2015

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)

@inexorabletash
Copy link
Member Author

inexorabletash commented Jun 1, 2015

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

@odinho
Copy link
Member

odinho commented Jun 16, 2015

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

@inexorabletash
Copy link
Member Author

@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.

@inexorabletash
Copy link
Member Author

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

@inexorabletash
Copy link
Member Author

inexorabletash commented Sep 23, 2016

Need to update Chrome behavior descriptions following https://chromium.googlesource.com/chromium/src/+/dce205414aa1bde4125c3129fef24a8dc8ad32cc

@inexorabletash
Copy link
Member Author

And tests there can be upstreamed to wpt

@inexorabletash inexorabletash added this to the V2 milestone Sep 23, 2016
@inexorabletash
Copy link
Member Author

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.

@beidson
Copy link

beidson commented Oct 21, 2016

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?

@inexorabletash
Copy link
Member Author

@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?

@pwnall
Copy link

pwnall commented Oct 23, 2016

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.

@bevis-tseng
Copy link

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

@beidson
Copy link

beidson commented Oct 24, 2016

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

@inexorabletash
Copy link
Member Author

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
Projects
None yet
Development

No branches or pull requests

5 participants