Bug 62286 - IndexedDB add() should fail if key is NaN
Summary: IndexedDB add() should fail if key is NaN
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joshua Bell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-08 08:55 PDT by Mark Pilgrim (Google)
Modified: 2011-10-04 12:34 PDT (History)
5 users (show)

See Also:


Attachments
test case (1.83 KB, text/html)
2011-06-08 08:55 PDT, Mark Pilgrim (Google)
no flags Details
Patch (7.54 KB, patch)
2011-10-03 14:51 PDT, Joshua Bell
no flags Details | Formatted Diff | Diff
Patch (7.62 KB, patch)
2011-10-03 15:39 PDT, Joshua Bell
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Pilgrim (Google) 2011-06-08 08:55:35 PDT
Created attachment 96428 [details]
test case

http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#key-construct states "Additionally, if the value is of type float, it is only a valid key if it is not NaN." This test attempts to add a record to an objectstore with NaN as the key.

Expected behavior: throw TYPE_MISMATCH_ERR
Actual behavior: no exception thrown, record added

Test case attached.
Comment 1 Joshua Bell 2011-10-03 14:51:31 PDT
Created attachment 109533 [details]
Patch
Comment 2 Joshua Bell 2011-10-03 14:54:03 PDT
NOTE: The layout tests for this and https://bugs.webkit.org/show_bug.cgi?id=62293 will conflict; that issue's expected.txt will need updating after this lands.
Comment 3 David Grogan 2011-10-03 15:27:28 PDT
LGTM

Being paranoid, could you (just locally) switch the stored value from [] to a string or int and ensure that the exception thrown is still type_mismatch?  Unless you've already done something like that to convince yourself that the type_mismatch_err isn't thrown b/c of the value.
Comment 4 Joshua Bell 2011-10-03 15:39:48 PDT
Created attachment 109541 [details]
Patch
Comment 5 Joshua Bell 2011-10-03 15:41:38 PDT
(In reply to comment #3)
> Being paranoid, could you (just locally) switch the stored value from [] to a string or int and ensure that the exception thrown is still type_mismatch?  Unless you've already done something like that to convince yourself that the type_mismatch_err isn't thrown b/c of the value.

Yeah... the use of [] for a dummy value came from another test file. I changed it in the latest patch to the string 'value' which is more obvious. Also, changed the test from add() (which would throw on collision) to put(). Shouldn't matter, but removes one more plausible bit of confusion.
Comment 6 Joshua Bell 2011-10-03 17:21:02 PDT
Comment on attachment 109541 [details]
Patch

Tony, can you review?
Comment 7 WebKit Review Bot 2011-10-04 12:34:30 PDT
Comment on attachment 109541 [details]
Patch

Clearing flags on attachment: 109541

Committed r96631: <http://trac.webkit.org/changeset/96631>
Comment 8 WebKit Review Bot 2011-10-04 12:34:34 PDT
All reviewed patches have been landed.  Closing bug.