Bug 58613

Summary: IndexedDB put() should fail if second (key) parameter is null
Product: WebKit Reporter: Mark Pilgrim (Google) <pilgrim>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, dgrogan, fishd, hans, pilgrim, tony
Priority: P3    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
test case
none
Patch
tony: review-, tony: commit-queue-
Patch with added changelog comments none

Mark Pilgrim (Google)
Reported 2011-04-14 17:32:17 PDT
http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-put states that the second (key) parameter to put() is optional, but if specified it must not be null. Mozilla correctly throws in this case (test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_key_requirements.html?force=1#204 ) but WebKit does not throw.
Attachments
test case (1.66 KB, text/html)
2011-04-14 17:32 PDT, Mark Pilgrim (Google)
no flags
Patch (7.69 KB, patch)
2011-04-28 04:06 PDT, Mark Pilgrim (Google)
tony: review-
tony: commit-queue-
Patch with added changelog comments (8.18 KB, patch)
2011-04-28 10:58 PDT, Mark Pilgrim (Google)
no flags
Mark Pilgrim (Google)
Comment 1 2011-04-14 17:32:34 PDT
Created attachment 89699 [details] test case
Mark Pilgrim (Google)
Comment 2 2011-04-28 04:06:57 PDT
Mark Pilgrim (Google)
Comment 3 2011-04-28 04:12:00 PDT
Straightforward fix -- if key is not specified, the prpKey ends up as a null pointer in ::put(). However, if the key is specified but is null, the prpKey ends up as a valid IDBKey which has a null key type. As it happens, we need to be able to detect the difference between these cases (the key arg is optional but if specified must not be null), and we can! Yay. There was one existing layouttest that needed tweaking, plus the new layouttest ported from Mozilla's test suite. All other existing layouttests pass, including 5 that use put() without the second (key) arg. (I know it's exactly 5 because my first attempt crashed these 5 tests.)
Hans Wennborg
Comment 4 2011-04-28 04:18:34 PDT
(In reply to comment #3) > Straightforward fix -- if key is not specified, the prpKey ends up as a null pointer in ::put(). However, if the key is specified but is null, the prpKey ends up as a valid IDBKey which has a null key type. As it happens, we need to be able to detect the difference between these cases (the key arg is optional but if specified must not be null), and we can! Yay. > > There was one existing layouttest that needed tweaking, plus the new layouttest ported from Mozilla's test suite. All other existing layouttests pass, including 5 that use put() without the second (key) arg. (I know it's exactly 5 because my first attempt crashed these 5 tests.) Thanks, Mark! Unofficial r+.
Tony Chang
Comment 5 2011-04-28 10:18:19 PDT
Comment on attachment 91466 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=91466&action=review r- so you can upload a new version that I can cq+ > Source/WebCore/ChangeLog:7 > + Can you put some of the first paragraph of comment #3 here? > LayoutTests/ChangeLog:11 > + * storage/indexeddb/objectstore-basics.html: You could add a one line description of why this needed tweaking here.
Mark Pilgrim (Google)
Comment 6 2011-04-28 10:58:48 PDT
Created attachment 91517 [details] Patch with added changelog comments
WebKit Commit Bot
Comment 7 2011-04-28 13:50:02 PDT
Comment on attachment 91517 [details] Patch with added changelog comments Clearing flags on attachment: 91517 Committed r85234: <http://trac.webkit.org/changeset/85234>
WebKit Commit Bot
Comment 8 2011-04-28 13:50:07 PDT
All reviewed patches have been landed. Closing bug.
Mark Pilgrim (Google)
Comment 9 2011-04-28 19:00:45 PDT
*** Bug 58611 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.