RESOLVED FIXED 97898
[Microdata] names.item() must return null for out of range indexes
https://bugs.webkit.org/show_bug.cgi?id=97898
Summary [Microdata] names.item() must return null for out of range indexes
Arko Saha
Reported 2012-09-28 05:20:40 PDT
DOMStringList.item() must return null for an invalid index. Sample Test: test(function () { var testEl = makeEl('div',{}); assert_equals( testEl.properties.names.item(0), null, 'item(0)' ); assert_equals( testEl.properties.names.item(-1), null, 'item(-1)' ); }, 'names.item() must return null for out of range indexes'); Expected: testEl.properties.names.item(-1) should return null Actual: INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value According to the spec http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMStringList item() must return DOMString, The DOMString at the indexth position in the DOMStringList, or null if that is not a valid index. Currently it throws "INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value", when index is negative.
Attachments
Patch (4.22 KB, patch)
2012-09-28 06:11 PDT, Arko Saha
haraken: review+
Arko Saha
Comment 1 2012-09-28 06:11:52 PDT
Kentaro Hara
Comment 2 2012-09-28 08:01:23 PDT
Comment on attachment 166236 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166236&action=review The implementation looks good. I am just concerned about cross-browser compatibility. > Source/WebCore/ChangeLog:8 > + DOMStringList.item() must return null for an invalid index. What is the behavior of other browsers (IE, Firefox, Opera)?
Arko Saha
Comment 3 2012-09-28 08:05:58 PDT
(In reply to comment #2) > (From update of attachment 166236 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=166236&action=review > > The implementation looks good. I am just concerned about cross-browser compatibility. > > > Source/WebCore/ChangeLog:8 > > + DOMStringList.item() must return null for an invalid index. > > What is the behavior of other browsers (IE, Firefox, Opera)? I tested in Opera and Firefox. Both return null in case of negative index. Unable to test it in as I don't have access to IE.
Kentaro Hara
Comment 4 2012-09-28 08:08:02 PDT
Comment on attachment 166236 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166236&action=review >>> Source/WebCore/ChangeLog:8 >>> + DOMStringList.item() must return null for an invalid index. >> >> What is the behavior of other browsers (IE, Firefox, Opera)? > > I tested in Opera and Firefox. Both return null in case of negative index. Unable to test it in as I don't have access to IE. Thanks for the clarification. Given that the spec also requires it, the change looks reasonable.
Kentaro Hara
Comment 5 2012-09-28 08:11:45 PDT
Comment on attachment 166236 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166236&action=review >>>> Source/WebCore/ChangeLog:8 >>>> + DOMStringList.item() must return null for an invalid index. >>> >>> What is the behavior of other browsers (IE, Firefox, Opera)? >> >> I tested in Opera and Firefox. Both return null in case of negative index. Unable to test it in as I don't have access to IE. > > Thanks for the clarification. Given that the spec also requires it, the change looks reasonable. It would be better to describe other browsers' behaviors in the ChangeLog.
Arko Saha
Comment 6 2012-09-28 08:26:41 PDT
(In reply to comment #5) > (From update of attachment 166236 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=166236&action=review > > >>>> Source/WebCore/ChangeLog:8 > >>>> + DOMStringList.item() must return null for an invalid index. > >>> > >>> What is the behavior of other browsers (IE, Firefox, Opera)? > >> > >> I tested in Opera and Firefox. Both return null in case of negative index. Unable to test it in as I don't have access to IE. > > > > Thanks for the clarification. Given that the spec also requires it, the change looks reasonable. > > It would be better to describe other browsers' behaviors in the ChangeLog. Sure I will update the Change log with other browsers behavior. Thanks for the review.
Arko Saha
Comment 7 2012-10-01 03:45:16 PDT
Note You need to log in before you can comment on or make changes to this bug.