Bug 97898 - [Microdata] names.item() must return null for out of range indexes
Summary: [Microdata] names.item() must return null for out of range indexes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Arko Saha
URL:
Keywords:
Depends on:
Blocks: 92986
  Show dependency treegraph
 
Reported: 2012-09-28 05:20 PDT by Arko Saha
Modified: 2012-10-01 03:45 PDT (History)
5 users (show)

See Also:


Attachments
Patch (4.22 KB, patch)
2012-09-28 06:11 PDT, Arko Saha
haraken: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arko Saha 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.
Comment 1 Arko Saha 2012-09-28 06:11:52 PDT
Created attachment 166236 [details]
Patch
Comment 2 Kentaro Hara 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)?
Comment 3 Arko Saha 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.
Comment 4 Kentaro Hara 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.
Comment 5 Kentaro Hara 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.
Comment 6 Arko Saha 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.
Comment 7 Arko Saha 2012-10-01 03:45:16 PDT
Committed r130026: <http://trac.webkit.org/changeset/130026>