RESOLVED FIXED 93071
[Microdata] document.getItems() must treat no token as no parameter
https://bugs.webkit.org/show_bug.cgi?id=93071
Summary [Microdata] document.getItems() must treat no token as no parameter
Arko Saha
Reported 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
Attachments
Patch (4.59 KB, patch)
2012-08-03 00:05 PDT, Arko Saha
rniwa: review+
Arko Saha
Comment 1 2012-08-03 00:05:22 PDT
Ryosuke Niwa
Comment 2 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 ''?
Arko Saha
Comment 3 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.
Ryosuke Niwa
Comment 4 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.
Arko Saha
Comment 5 2012-08-06 03:33:31 PDT
Note You need to log in before you can comment on or make changes to this bug.