Bug 93071 - [Microdata] document.getItems() must treat no token as no parameter
Summary: [Microdata] document.getItems() must treat no token as no parameter
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-08-02 23:46 PDT by Arko Saha
Modified: 2012-08-06 03:33 PDT (History)
1 user (show)

See Also:


Attachments
Patch (4.59 KB, patch)
2012-08-03 00:05 PDT, Arko Saha
rniwa: 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-08-02 23:46:33 PDT
document.getItems() must return all top-level microdata items in the document when no tokens specified in the argument.
spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#dom-document-getitems

sample test:
<div itemscope itemtype="http://example.com/bar"></div>
<div itemscope></div>
<script type ="text/javascript">
assert_equals( document.getItems('').length, 2, 'empty string' );
</script>

Expected: document.getItems('').length must return 2
Actual: Fail- empty string expected 2 but got 1
Comment 1 Arko Saha 2012-08-03 00:05:22 PDT
Created attachment 156272 [details]
Patch
Comment 2 Ryosuke Niwa 2012-08-03 00:54:58 PDT
Comment on attachment 156272 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=156272&action=review

> Source/WebCore/dom/MicroDataItemList.cpp:68
> +    if (m_originalTypeNames == undefinedItemType() || !m_typeNames.size())

Should we change undefinedItemType() to be ''?
Comment 3 Arko Saha 2012-08-03 02:18:36 PDT
(In reply to comment #2)
> (From update of attachment 156272 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=156272&action=review
> 
> > Source/WebCore/dom/MicroDataItemList.cpp:68
> > +    if (m_originalTypeNames == undefinedItemType() || !m_typeNames.size())
> 
> Should we change undefinedItemType() to be ''?

It is possible to call getItems() with empty string '' and string with spaces '    ' (no tokens). We can not handle these string with spaces case if we change undefinedItemType() to be ''.
I think checking size of the token i.e, !m_typeNames.size() is appropriate here as m_typeNames is a SpaceSplitString and its size will be zero in all cases like "", " ", "  ",etc.
Comment 4 Ryosuke Niwa 2012-08-03 11:53:39 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 156272 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=156272&action=review
> > 
> > > Source/WebCore/dom/MicroDataItemList.cpp:68
> > > +    if (m_originalTypeNames == undefinedItemType() || !m_typeNames.size())
> > 
> > Should we change undefinedItemType() to be ''?
> 
> It is possible to call getItems() with empty string '' and string with spaces '    ' (no tokens). We can not handle these string with spaces case if we change undefinedItemType() to be ''.
> I think checking size of the token i.e, !m_typeNames.size() is appropriate here as m_typeNames is a SpaceSplitString and its size will be zero in all cases like "", " ", "  ",etc.

What I meant is that use '' when we're creating MicroDataItemList. We can just pass in '' so that the SpaceSplitString has size 0.
Comment 5 Arko Saha 2012-08-06 03:33:31 PDT
Landed in: <http://trac.webkit.org/changeset/124750>