Source/WebCore/ChangeLog

 12011-11-17 Arko Saha <arko@motorola.com>
 2
 3 Microdata: Support for properties attribute.
 4 https://bugs.webkit.org/show_bug.cgi?id=71050
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 The properties attribute returns an HTMLPropertiesCollection object with all the element's
 9 properties. Otherwise, an empty HTMLPropertiesCollection object.
 10
 11 Tests: fast/dom/MicroData/names-property-must-be-correct.html
 12 fast/dom/MicroData/names-property-test.html
 13 fast/dom/MicroData/properties-collection-behavior-add-remove-itemscope-attr.html
 14 fast/dom/MicroData/properties-collection-must-be-correct.html
 15 fast/dom/MicroData/properties-collection-must-ignore-properties-of-nested-items.html
 16 fast/dom/MicroData/properties-collection-must-see-the-properties-added-in-itemref.html
 17 fast/dom/MicroData/properties-collection-test.html
 18
 19 * CMakeLists.txt:
 20 * DerivedSources.cpp:
 21 * DerivedSources.make:
 22 * DerivedSources.pri:
 23 * GNUmakefile.list.am:
 24 * Target.pri:
 25 * WebCore.gypi:
 26 * WebCore.vcproj/WebCore.vcproj:
 27 * bindings/gobject/GNUmakefile.am:
 28 * bindings/js/JSHTMLCollectionCustom.cpp:
 29 (WebCore::toJS):
 30 * dom/MicroDataItemList.cpp:
 31 * dom/Node.cpp:
 32 (WebCore::Node::itemProp):
 33 (WebCore::Node::setItemProp):
 34 (WebCore::Node::itemRef):
 35 (WebCore::Node::setItemRef):
 36 (WebCore::Node::itemType):
 37 (WebCore::Node::setItemType):
 38 (WebCore::Node::properties):
 39 * dom/Node.h:
 40 * dom/NodeRareData.h:
 41 (WebCore::NodeRareData::itemProp):
 42 (WebCore::NodeRareData::setItemProp):
 43 (WebCore::NodeRareData::itemRef):
 44 (WebCore::NodeRareData::setItemRef):
 45 (WebCore::NodeRareData::itemType):
 46 (WebCore::NodeRareData::setItemType):
 47 (WebCore::NodeRareData::properties):
 48 * html/CollectionType.h:
 49 * html/HTMLCollection.cpp:
 50 (WebCore::HTMLCollection::itemAfter):
 51 * html/HTMLElement.cpp:
 52 (WebCore::HTMLElement::setItemValueText):
 53 * html/HTMLElement.h:
 54 * html/HTMLElement.idl:
 55 * html/HTMLPropertiesCollection.cpp: Added.
 56 (WebCore::compareTreeOrder):
 57 (WebCore::HTMLPropertiesCollection::create):
 58 (WebCore::HTMLPropertiesCollection::HTMLPropertiesCollection):
 59 (WebCore::HTMLPropertiesCollection::~HTMLPropertiesCollection):
 60 (WebCore::HTMLPropertiesCollection::findPropetiesOfAnItem): Finds the properties of an item.
 61 (WebCore::HTMLPropertiesCollection::length): Returns the number of elements in the properties collection.
 62 (WebCore::HTMLPropertiesCollection::item): Returns the element with index 'index' from the collection. The items are sorted in tree order.
 63 (WebCore::HTMLPropertiesCollection::names): Returns a DOMStringList with the property names of the elements in the collection with the order preserved but with duplicates removed.
 64 * html/HTMLPropertiesCollection.h: Added.
 65 * html/HTMLPropertiesCollection.idl: Added.
 66 * page/DOMWindow.idl:
 67
1682011-11-17 Ben Murdoch <benm@google.com>
269
370 Unreviewed build fix.
100611

Source/WebCore/CMakeLists.txt

@@SET(WebCore_IDL_FILES
257257 html/HTMLParamElement.idl
258258 html/HTMLPreElement.idl
259259 html/HTMLProgressElement.idl
 260 html/HTMLPropertiesCollection.idl
260261 html/HTMLQuoteElement.idl
261262 html/HTMLScriptElement.idl
262263 html/HTMLSelectElement.idl

@@SET(WebCore_SOURCES
769770 html/HTMLPlugInImageElement.cpp
770771 html/HTMLPreElement.cpp
771772 html/HTMLProgressElement.cpp
 773 html/HTMLPropertiesCollection.cpp
772774 html/HTMLQuoteElement.cpp
773775 html/HTMLScriptElement.cpp
774776 html/HTMLSelectElement.cpp
100611

Source/WebCore/DerivedSources.cpp

135135#include "JSHashChangeEvent.cpp"
136136#include "JSHistory.cpp"
137137#include "JSHTMLAllCollection.cpp"
 138#include "JSHTMLPropertiesCollection.cpp"
138139#include "JSHTMLAnchorElement.cpp"
139140#include "JSHTMLAppletElement.cpp"
140141#include "JSHTMLAreaElement.cpp"
100611

Source/WebCore/DerivedSources.make

@@DOM_CLASSES = \
179179 Geolocation \
180180 Geoposition \
181181 HTMLAllCollection \
 182 HTMLPropertiesCollection \
182183 HTMLAnchorElement \
183184 HTMLAppletElement \
184185 HTMLAreaElement \
100611

Source/WebCore/DerivedSources.pri

@@IDL_BINDINGS += \
295295 html/HTMLParamElement.idl \
296296 html/HTMLPreElement.idl \
297297 html/HTMLProgressElement.idl \
 298 html/HTMLPropertiesCollection.idl \
298299 html/HTMLQuoteElement.idl \
299300 html/HTMLScriptElement.idl \
300301 html/HTMLSelectElement.idl \
100611

Source/WebCore/GNUmakefile.list.am

@@webcore_built_sources += \
303303 DerivedSources/WebCore/JSHTMLPreElement.h \
304304 DerivedSources/WebCore/JSHTMLProgressElement.cpp \
305305 DerivedSources/WebCore/JSHTMLProgressElement.h \
 306 DerivedSources/WebCore/JSHTMLPropertiesCollection.cpp \
 307 DerivedSources/WebCore/JSHTMLPropertiesCollection.h \
306308 DerivedSources/WebCore/JSHTMLQuoteElement.cpp \
307309 DerivedSources/WebCore/JSHTMLQuoteElement.h \
308310 DerivedSources/WebCore/JSHTMLScriptElement.cpp \

@@webcore_sources += \
18171819 Source/WebCore/html/HTMLPreElement.h \
18181820 Source/WebCore/html/HTMLProgressElement.cpp \
18191821 Source/WebCore/html/HTMLProgressElement.h \
 1822 Source/WebCore/html/HTMLPropertiesCollection.cpp \
 1823 Source/WebCore/html/HTMLPropertiesCollection.h \
18201824 Source/WebCore/html/HTMLQuoteElement.cpp \
18211825 Source/WebCore/html/HTMLQuoteElement.h \
18221826 Source/WebCore/html/HTMLScriptElement.cpp \
100611

Source/WebCore/Target.pri

@@SOURCES += \
760760 html/HTMLPlugInImageElement.cpp \
761761 html/HTMLPreElement.cpp \
762762 html/HTMLProgressElement.cpp \
 763 html/HTMLPropertiesCollection.cpp \
763764 html/HTMLQuoteElement.cpp \
764765 html/HTMLScriptElement.cpp \
765766 html/HTMLSelectElement.cpp \

@@HEADERS += \
18331834 html/HTMLPlugInImageElement.h \
18341835 html/HTMLPreElement.h \
18351836 html/HTMLProgressElement.h \
 1837 html/HTMLPropertiesCollection.h \
18361838 html/HTMLQuoteElement.h \
18371839 html/HTMLScriptElement.h \
18381840 html/HTMLSelectElement.h \
100611

Source/WebCore/WebCore.gypi

13111311 'html/HTMLParamElement.idl',
13121312 'html/HTMLPreElement.idl',
13131313 'html/HTMLProgressElement.idl',
 1314 'html/HTMLPropertiesCollection.idl',
13141315 'html/HTMLQuoteElement.idl',
13151316 'html/HTMLScriptElement.idl',
13161317 'html/HTMLSelectElement.idl',

55455546 'html/HTMLPreElement.h',
55465547 'html/HTMLProgressElement.cpp',
55475548 'html/HTMLProgressElement.h',
 5549 'html/HTMLPropertiesCollection.cpp',
 5550 'html/HTMLPropertiesCollection.h',
55485551 'html/HTMLQuoteElement.cpp',
55495552 'html/HTMLQuoteElement.h',
55505553 'html/HTMLScriptElement.cpp',

74747477 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSHTMLPreElement.h',
74757478 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSHTMLProgressElement.cpp',
74767479 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSHTMLProgressElement.h',
 7480 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSHTMLPropertiesCollection.cpp',
 7481 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSHTMLPropertiesCollection.h',
74777482 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSHTMLQuoteElement.cpp',
74787483 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSHTMLQuoteElement.h',
74797484 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSHTMLScriptElement.cpp',
100611

Source/WebCore/WebCore.vcproj/WebCore.vcproj

85988598 >
85998599 </File>
86008600 <File
 8601 RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSHTMLPropertiesCollection.cpp"
 8602 >
 8603 <FileConfiguration
 8604 Name="Debug|Win32"
 8605 ExcludedFromBuild="true"
 8606 >
 8607 <Tool
 8608 Name="VCCLCompilerTool"
 8609 />
 8610 </FileConfiguration>
 8611 <FileConfiguration
 8612 Name="Release|Win32"
 8613 ExcludedFromBuild="true"
 8614 >
 8615 <Tool
 8616 Name="VCCLCompilerTool"
 8617 />
 8618 </FileConfiguration>
 8619 <FileConfiguration
 8620 Name="Debug_Cairo_CFLite|Win32"
 8621 ExcludedFromBuild="true"
 8622 >
 8623 <Tool
 8624 Name="VCCLCompilerTool"
 8625 />
 8626 </FileConfiguration>
 8627 <FileConfiguration
 8628 Name="Release_Cairo_CFLite|Win32"
 8629 ExcludedFromBuild="true"
 8630 >
 8631 <Tool
 8632 Name="VCCLCompilerTool"
 8633 />
 8634 </FileConfiguration>
 8635 <FileConfiguration
 8636 Name="Debug_All|Win32"
 8637 ExcludedFromBuild="true"
 8638 >
 8639 <Tool
 8640 Name="VCCLCompilerTool"
 8641 />
 8642 </FileConfiguration>
 8643 <FileConfiguration
 8644 Name="Production|Win32"
 8645 ExcludedFromBuild="true"
 8646 >
 8647 <Tool
 8648 Name="VCCLCompilerTool"
 8649 />
 8650 </FileConfiguration>
 8651 </File>
 8652 <File
 8653 RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSHTMLPropertiesCollection.h"
 8654 >
 8655 </File>
 8656 <File
86018657 RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSHTMLQuoteElement.cpp"
86028658 >
86038659 <FileConfiguration

5655456610 >
5655556611 </File>
5655656612 <File
 56613 RelativePath="..\html\HTMLPropertiesCollection.cpp"
 56614 >
 56615 </File>
 56616 <File
 56617 RelativePath="..\html\HTMLPropertiesCollection.h"
 56618 >
 56619 </File>
 56620 <File
5655756621 RelativePath="..\html\HTMLQuoteElement.cpp"
5655856622 >
5655956623 <FileConfiguration
100611

Source/WebCore/bindings/gobject/GNUmakefile.am

@@webkitgtk_gdom_built_sources += \
166166 DerivedSources/webkit/WebKitDOMHTMLParamElementPrivate.h \
167167 DerivedSources/webkit/WebKitDOMHTMLPreElement.cpp \
168168 DerivedSources/webkit/WebKitDOMHTMLPreElementPrivate.h \
 169 DerivedSources/webkit/WebKitDOMHTMLPropertiesCollection.cpp \
 170 DerivedSources/webkit/WebKitDOMHTMLPropertiesCollectionPrivate.h \
169171 DerivedSources/webkit/WebKitDOMHTMLQuoteElement.cpp \
170172 DerivedSources/webkit/WebKitDOMHTMLQuoteElementPrivate.h \
171173 DerivedSources/webkit/WebKitDOMHTMLScriptElement.cpp \

@@webkitgtk_built_h_api += \
343345 DerivedSources/webkit/WebKitDOMHTMLParagraphElement.h \
344346 DerivedSources/webkit/WebKitDOMHTMLParamElement.h \
345347 DerivedSources/webkit/WebKitDOMHTMLPreElement.h \
 348 DerivedSources/webkit/WebKitDOMHTMLPropertiesCollection.h \
346349 DerivedSources/webkit/WebKitDOMHTMLQuoteElement.h \
347350 DerivedSources/webkit/WebKitDOMHTMLScriptElement.h \
348351 DerivedSources/webkit/WebKitDOMHTMLSelectElement.h \
100611

Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp

3333#include <wtf/Vector.h>
3434#include <wtf/text/AtomicString.h>
3535
 36#if ENABLE(MICRODATA)
 37#include "HTMLPropertiesCollection.h"
 38#include "JSHTMLPropertiesCollection.h"
 39#endif
 40
3641using namespace JSC;
3742
3843namespace WebCore {

@@JSValue toJS(ExecState* exec, JSDOMGloba
97102 case DocAll:
98103 wrapper = CREATE_DOM_WRAPPER(exec, globalObject, HTMLAllCollection, collection);
99104 break;
 105#if ENABLE(MICRODATA)
 106 case ItemProperties:
 107 wrapper = CREATE_DOM_WRAPPER(exec, globalObject, HTMLPropertiesCollection, collection);
 108 break;
 109#endif
100110 default:
101111 wrapper = CREATE_DOM_WRAPPER(exec, globalObject, HTMLCollection, collection);
102112 break;
100611

Source/WebCore/dom/MicroDataItemList.cpp

2828#if ENABLE(MICRODATA)
2929#include "MicroDataItemList.h"
3030
 31#include "DOMSettableTokenList.h"
3132#include "Document.h"
3233#include "HTMLElement.h"
3334#include "HTMLNames.h"
100611

Source/WebCore/dom/Node.cpp

114114#include <runtime/JSGlobalData.h>
115115#endif
116116
 117#if ENABLE(MICRODATA)
 118#include "DOMSettableTokenList.h"
 119#include "HTMLPropertiesCollection.h"
 120#endif
 121
117122#define DUMP_NODE_STATISTICS 0
118123
119124using namespace std;

@@void Node::defaultEventHandler(Event* ev
29973002 }
29983003}
29993004
 3005#if ENABLE(MICRODATA)
 3006DOMSettableTokenList* Node::itemProp()
 3007{
 3008 return ensureRareData()->itemProp();
 3009}
 3010
 3011void Node::setItemProp(const String& value)
 3012{
 3013 ensureRareData()->setItemProp(value);
 3014}
 3015
 3016DOMSettableTokenList* Node::itemRef()
 3017{
 3018 return ensureRareData()->itemRef();
 3019}
 3020
 3021void Node::setItemRef(const String& value)
 3022{
 3023 ensureRareData()->setItemRef(value);
 3024}
 3025
 3026DOMSettableTokenList* Node::itemType()
 3027{
 3028 return ensureRareData()->itemType();
 3029}
 3030
 3031void Node::setItemType(const String& value)
 3032{
 3033 ensureRareData()->setItemType(value);
 3034}
 3035
 3036HTMLPropertiesCollection* Node::properties()
 3037{
 3038 return ensureRareData()->properties(this);
 3039}
 3040#endif
 3041
30003042} // namespace WebCore
30013043
30023044#ifndef NDEBUG
100611

Source/WebCore/dom/Node.h

@@class SVGUseElement;
8282class TagNodeList;
8383class TreeScope;
8484
 85#if ENABLE(MICRODATA)
 86class DOMSettableTokenList;
 87class HTMLPropertiesCollection;
 88#endif
 89
8590typedef int ExceptionCode;
8691
8792const int nodeStyleChangeShift = 25;

@@public:
588593
589594#if ENABLE(MICRODATA)
590595 void itemTypeAttributeChanged();
 596
 597 DOMSettableTokenList* itemProp();
 598 DOMSettableTokenList* itemRef();
 599 DOMSettableTokenList* itemType();
 600 HTMLPropertiesCollection* properties();
591601#endif
592602
593603#if ENABLE(MUTATION_OBSERVERS)

@@protected:
758768 void setHasRareSVGData() { setFlag(HasSVGRareDataFlag); }
759769 void clearHasRareSVGData() { clearFlag(HasSVGRareDataFlag); }
760770#endif
 771
 772#if ENABLE(MICRODATA)
 773 void setItemProp(const String&);
 774 void setItemRef(const String&);
 775 void setItemType(const String&);
 776#endif
761777};
762778
763779// Used in Node::addSubresourceAttributeURLs() and in addSubresourceStyleURLs()
100611

Source/WebCore/dom/NodeRareData.h

2626#include "DynamicNodeList.h"
2727
2828#if ENABLE(MICRODATA)
 29#include "DOMSettableTokenList.h"
 30#include "HTMLPropertiesCollection.h"
2931#include "MicroDataItemList.h"
3032#endif
3133

@@public:
157159 }
158160#endif
159161
 162#if ENABLE(MICRODATA)
 163 DOMSettableTokenList* itemProp() const
 164 {
 165 if (!m_itemProp)
 166 m_itemProp = DOMSettableTokenList::create();
 167
 168 return m_itemProp.get();
 169 }
 170
 171 void setItemProp(const String& value)
 172 {
 173 if (!m_itemProp)
 174 m_itemProp = DOMSettableTokenList::create();
 175
 176 m_itemProp->setValue(value);
 177 }
 178
 179 DOMSettableTokenList* itemRef() const
 180 {
 181 if (!m_itemRef)
 182 m_itemRef = DOMSettableTokenList::create();
 183
 184 return m_itemRef.get();
 185 }
 186
 187 void setItemRef(const String& value)
 188 {
 189 if (!m_itemRef)
 190 m_itemRef = DOMSettableTokenList::create();
 191
 192 m_itemRef->setValue(value);
 193 }
 194
 195 DOMSettableTokenList* itemType() const
 196 {
 197 if (!m_itemType)
 198 m_itemType = DOMSettableTokenList::create();
 199
 200 return m_itemType.get();
 201 }
 202
 203 void setItemType(const String& value)
 204 {
 205 if (!m_itemType)
 206 m_itemType = DOMSettableTokenList::create();
 207
 208 m_itemType->setValue(value);
 209 }
 210
 211 HTMLPropertiesCollection* properties(Node* node)
 212 {
 213 if (!m_properties)
 214 m_properties = HTMLPropertiesCollection::create(node);
 215
 216 return m_properties.get();
 217 }
 218#endif
 219
160220 bool isFocused() const { return m_isFocused; }
161221 void setFocused(bool focused) { m_isFocused = focused; }
162222

@@private:
178238 OwnPtr<Vector<OwnPtr<MutationObserverRegistration> > > m_mutationObserverRegistry;
179239 OwnPtr<HashSet<MutationObserverRegistration*> > m_transientMutationObserverRegistry;
180240#endif
 241
 242#if ENABLE(MICRODATA)
 243 mutable RefPtr<DOMSettableTokenList> m_itemProp;
 244 mutable RefPtr<DOMSettableTokenList> m_itemRef;
 245 mutable RefPtr<DOMSettableTokenList> m_itemType;
 246 mutable RefPtr<HTMLPropertiesCollection> m_properties;
 247#endif
181248};
182249
183250} // namespace WebCore
100611

Source/WebCore/html/CollectionType.h

@@enum CollectionType {
5454 DataListOptions,
5555 MapAreas,
5656
 57#if ENABLE(MICRODATA)
 58 ItemProperties, // Microdata item properties in the document
 59#endif
 60
5761 OtherCollection
5862};
5963
100611

Source/WebCore/html/HTMLCollection.cpp

@@Element* HTMLCollection::itemAfter(Eleme
105105 case SelectOptions:
106106 case DataListOptions:
107107 case WindowNamedItems:
 108#if ENABLE(MICRODATA)
 109 case ItemProperties:
 110#endif
108111 break;
109112 case NodeChildren:
110113 case TRCells:

@@Element* HTMLCollection::itemAfter(Eleme
189192 case DocAll:
190193 case NodeChildren:
191194 return e;
 195#if ENABLE(MICRODATA)
 196 case ItemProperties:
 197 if (e->isHTMLElement() && e->hasAttribute(itempropAttr))
 198 return e;
 199 break;
 200#endif
192201 case DocumentNamedItems:
193202 case OtherCollection:
194203 case WindowNamedItems:
100611

Source/WebCore/html/HTMLElement.cpp

@@bool HTMLElement::isURLAttribute(Attribu
10051005}
10061006
10071007#if ENABLE(MICRODATA)
1008 PassRefPtr<DOMSettableTokenList> HTMLElement::itemProp() const
1009 {
1010  if (!m_itemProp)
1011  m_itemProp = DOMSettableTokenList::create();
1012 
1013  return m_itemProp;
1014 }
1015 
1016 void HTMLElement::setItemProp(const String& value)
1017 {
1018  if (!m_itemProp)
1019  m_itemProp = DOMSettableTokenList::create();
1020 
1021  m_itemProp->setValue(value);
1022 }
1023 
1024 PassRefPtr<DOMSettableTokenList> HTMLElement::itemRef() const
1025 {
1026  if (!m_itemRef)
1027  m_itemRef = DOMSettableTokenList::create();
1028 
1029  return m_itemRef;
1030 }
1031 
1032 void HTMLElement::setItemRef(const String& value)
1033 {
1034  if (!m_itemRef)
1035  m_itemRef = DOMSettableTokenList::create();
1036 
1037  m_itemRef->setValue(value);
1038 }
1039 
10401008void HTMLElement::setItemValue(const String& value, ExceptionCode& ec)
10411009{
10421010 if (!hasAttribute(itempropAttr) || hasAttribute(itemscopeAttr)) {

@@void HTMLElement::setItemValueText(const
10671035{
10681036 setTextContent(value, ec);
10691037}
1070 
1071 PassRefPtr<DOMSettableTokenList> HTMLElement::itemType() const
1072 {
1073  if (!m_itemType)
1074  m_itemType = DOMSettableTokenList::create();
1075 
1076  return m_itemType;
1077 }
1078 
1079 void HTMLElement::setItemType(const String& value)
1080 {
1081  if (!m_itemType)
1082  m_itemType = DOMSettableTokenList::create();
1083 
1084  m_itemType->setValue(value);
1085 }
10861038#endif
10871039
10881040} // namespace WebCore
100611

Source/WebCore/html/HTMLElement.h

2525
2626#include "StyledElement.h"
2727
28 #if ENABLE(MICRODATA)
29 #include "DOMSettableTokenList.h"
30 #endif
31 
3228namespace WebCore {
3329
3430class DocumentFragment;

@@public:
9086 TextDirection directionalityIfhasDirAutoAttribute(bool& isAuto) const;
9187
9288#if ENABLE(MICRODATA)
93  PassRefPtr<DOMSettableTokenList> itemRef() const;
94  PassRefPtr<DOMSettableTokenList> itemProp() const;
95  PassRefPtr<DOMSettableTokenList> itemType() const;
96 
9789 void setItemValue(const String&, ExceptionCode&);
9890 PassRefPtr<MicroDataItemValue> itemValue() const;
9991#endif

@@private:
128120 TextDirection directionality(Node** strongDirectionalityTextNode= 0) const;
129121
130122#if ENABLE(MICRODATA)
131  void setItemProp(const String&);
132  void setItemRef(const String&);
133  void setItemType(const String&);
134 
135123 virtual String itemValueText() const;
136124 virtual void setItemValueText(const String&, ExceptionCode&);
137 
138  mutable RefPtr<DOMSettableTokenList> m_itemProp;
139  mutable RefPtr<DOMSettableTokenList> m_itemRef;
140  mutable RefPtr<DOMSettableTokenList> m_itemType;
141125#endif
142126};
143127
100611

Source/WebCore/html/HTMLElement.idl

@@module html {
7373 readonly attribute [Conditional=MICRODATA] DOMSettableTokenList itemRef;
7474 readonly attribute [Conditional=MICRODATA] DOMSettableTokenList itemProp;
7575
 76#if defined(ENABLE_MICRODATA) && ENABLE_MICRODATA
 77 readonly attribute [Conditional=MICRODATA] HTMLPropertiesCollection properties;
 78#endif
 79
7680#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
7781#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
7882 attribute [Conditional=MICRODATA, Custom] DOMObject itemValue
100611

Source/WebCore/html/HTMLPropertiesCollection.cpp

 1/*
 2 * Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without modification,
 5 * are permitted provided that the following conditions are met:
 6 *
 7 * Redistributions of source code must retain the above copyright notice,
 8 * this list of conditions and the following disclaimer.
 9 *
 10 * Redistributions in binary form must reproduce the above copyright notice,
 11 * this list of conditions and the following disclaimer in the documentation and/or
 12 * other materials provided with the distribution.
 13 *
 14 * Neither the name of Motorola Mobility, Inc. nor the names of its contributors may
 15 * be used to endorse or promote products derived from this software without
 16 * specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31#include "config.h"
 32
 33#if ENABLE(MICRODATA)
 34#include "HTMLPropertiesCollection.h"
 35
 36#include "DOMSettableTokenList.h"
 37#include "DOMStringList.h"
 38#include "HTMLElement.h"
 39#include "HTMLNames.h"
 40#include "Node.h"
 41
 42namespace WebCore {
 43
 44using namespace HTMLNames;
 45
 46static inline bool compareTreeOrder(Node* node1, Node* node2)
 47{
 48 return (node2->compareDocumentPosition(node1) & (Node::DOCUMENT_POSITION_PRECEDING | Node::DOCUMENT_POSITION_DISCONNECTED)) == Node::DOCUMENT_POSITION_PRECEDING;
 49}
 50
 51PassRefPtr<HTMLPropertiesCollection> HTMLPropertiesCollection::create(PassRefPtr<Node> itemNode)
 52{
 53 return adoptRef(new HTMLPropertiesCollection(itemNode));
 54}
 55
 56HTMLPropertiesCollection::HTMLPropertiesCollection(PassRefPtr<Node> itemNode)
 57 : HTMLCollection(itemNode, ItemProperties)
 58 , m_propertyNames(DOMStringList::create())
 59{
 60}
 61
 62HTMLPropertiesCollection::~HTMLPropertiesCollection()
 63{
 64}
 65
 66void HTMLPropertiesCollection::findPropetiesOfAnItem(Node* root) const
 67{
 68 // 5.2.5 Associating names with items.
 69 Vector<Node*> memory, pending;
 70
 71 memory.append(root);
 72
 73 // Add the child elements of root, if any, to pending.
 74 for (Node* child = root->firstChild(); child; child = child->nextSibling())
 75 if (child->isHTMLElement())
 76 pending.append(child);
 77
 78 // If root has an itemref attribute, split the value of that itemref attribute on spaces.
 79 // For each resulting token ID, if there is an element in the home subtree of root with the ID ID,
 80 // then add the first such element to pending.
 81 if (toHTMLElement(root)->fastHasAttribute(itemrefAttr)) {
 82 DOMSettableTokenList* itemRef = root->itemRef();
 83
 84 for (size_t i = 0; i < itemRef->length(); ++i) {
 85 AtomicString id = itemRef->item(i);
 86
 87 Element* element = root->document()->getElementById(id);
 88 if (element && element->isHTMLElement())
 89 pending.append(element);
 90 }
 91 }
 92
 93 // Loop till we have processed all pending elements
 94 while (!pending.isEmpty()) {
 95
 96 // Remove first element from pending and let current be that element.
 97 Node* current = pending[0];
 98 pending.remove(0);
 99
 100 // If current is already in memory, there is a microdata error;
 101 if (memory.contains(current)) {
 102 // microdata error;
 103 continue;
 104 }
 105
 106 memory.append(current);
 107
 108 // If current does not have an itemscope attribute, then: add all the child elements of current to pending.
 109 HTMLElement* element = toHTMLElement(current);
 110 if (!element->fastHasAttribute(itemscopeAttr)) {
 111 for (Node* child = current->firstChild(); child; child = child->nextSibling())
 112 if (child->isHTMLElement())
 113 pending.append(child);
 114 }
 115
 116 // If current has an itemprop attribute specified, add it to results.
 117 if (element->fastHasAttribute(itempropAttr))
 118 m_properties.append(current);
 119 }
 120}
 121
 122unsigned HTMLPropertiesCollection::length() const
 123{
 124 if (!base()->isHTMLElement() || !toHTMLElement(base())->fastHasAttribute(itemscopeAttr))
 125 return 0;
 126
 127 m_properties.clear();
 128 findPropetiesOfAnItem(base());
 129 return m_properties.size();
 130}
 131
 132Node* HTMLPropertiesCollection::item(unsigned index) const
 133{
 134 if (!base()->isHTMLElement() || !toHTMLElement(base())->fastHasAttribute(itemscopeAttr))
 135 return 0;
 136
 137 m_properties.clear();
 138 findPropetiesOfAnItem(base());
 139
 140 if (m_properties.size() <= index)
 141 return 0;
 142
 143 std::sort(m_properties.begin(), m_properties.end(), compareTreeOrder);
 144 return m_properties[index];
 145}
 146
 147PassRefPtr<DOMStringList> HTMLPropertiesCollection::names() const
 148{
 149 m_properties.clear();
 150 m_propertyNames->clear();
 151
 152 if (!base()->isHTMLElement() || !toHTMLElement(base())->fastHasAttribute(itemscopeAttr))
 153 return m_propertyNames;
 154
 155 findPropetiesOfAnItem(base());
 156
 157 std::sort(m_properties.begin(), m_properties.end(), compareTreeOrder);
 158
 159 for (size_t i = 0; i < m_properties.size(); ++i) {
 160 // For each item properties, split the value of that itemprop attribute on spaces.
 161 // Add all tokens to property names, with the order preserved but with duplicates removed.
 162 DOMSettableTokenList* itemProperty = m_properties[i]->itemProp();
 163 for (size_t i = 0; i < itemProperty->length(); ++i) {
 164 AtomicString propertyName = itemProperty->item(i);
 165 if (m_propertyNames->isEmpty() || !m_propertyNames->contains(propertyName))
 166 m_propertyNames->append(propertyName);
 167 }
 168 }
 169
 170 return m_propertyNames;
 171}
 172
 173} // namespace WebCore
 174
 175#endif // ENABLE(MICRODATA)
0

Source/WebCore/html/HTMLPropertiesCollection.h

 1/*
 2 * Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without modification,
 5 * are permitted provided that the following conditions are met:
 6 *
 7 * Redistributions of source code must retain the above copyright notice,
 8 * this list of conditions and the following disclaimer.
 9 *
 10 * Redistributions in binary form must reproduce the above copyright notice,
 11 * this list of conditions and the following disclaimer in the documentation and/or
 12 * other materials provided with the distribution.
 13 *
 14 * Neither the name of Motorola Mobility, Inc. nor the names of its contributors may
 15 * be used to endorse or promote products derived from this software without
 16 * specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31#ifndef HTMLPropertiesCollection_h
 32#define HTMLPropertiesCollection_h
 33
 34#if ENABLE(MICRODATA)
 35
 36#include "HTMLCollection.h"
 37
 38namespace WebCore {
 39class DOMStringList;
 40
 41class HTMLPropertiesCollection : public HTMLCollection {
 42public:
 43 static PassRefPtr<HTMLPropertiesCollection> create(PassRefPtr<Node>);
 44 virtual ~HTMLPropertiesCollection();
 45
 46 unsigned length() const OVERRIDE;
 47
 48 virtual Node* item(unsigned) const OVERRIDE;
 49
 50 PassRefPtr<DOMStringList> names() const;
 51
 52private:
 53 HTMLPropertiesCollection(PassRefPtr<Node>);
 54
 55 void findPropetiesOfAnItem(Node* current) const;
 56
 57 mutable Vector<Node*> m_properties;
 58 mutable RefPtr<DOMStringList> m_propertyNames;
 59};
 60
 61} // namespace WebCore
 62
 63#endif // ENABLE(MICRODATA)
 64
 65#endif // HTMLPropertiesCollection_h
0

Source/WebCore/html/HTMLPropertiesCollection.idl

 1/*
 2 * Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without modification,
 5 * are permitted provided that the following conditions are met:
 6 *
 7 * Redistributions of source code must retain the above copyright notice,
 8 * this list of conditions and the following disclaimer.
 9 *
 10 * Redistributions in binary form must reproduce the above copyright notice,
 11 * this list of conditions and the following disclaimer in the documentation and/or
 12 * other materials provided with the distribution.
 13 *
 14 * Neither the name of Motorola Mobility, Inc. nor the names of its contributors may
 15 * be used to endorse or promote products derived from this software without
 16 * specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31module html {
 32
 33 interface [
 34 Conditional=MICRODATA,
 35 HasIndexGetter
 36 ] HTMLPropertiesCollection : HTMLCollection {
 37 readonly attribute unsigned long length;
 38 Node item(in unsigned long index);
 39
 40 readonly attribute DOMStringList names;
 41
 42 // FIXME: override inherited namedItem()
 43 };
 44}
0

Source/WebCore/page/DOMWindow.idl

@@module window {
488488
489489 attribute HTMLCollectionConstructor HTMLCollection;
490490 attribute HTMLAllCollectionConstructor HTMLAllCollection;
 491 attribute [Conditional=MICRODATA] HTMLPropertiesCollectionConstructor HTMLPropertiesCollection;
491492 attribute HTMLUnknownElementConstructor HTMLUnknownElement;
492493
493494 attribute [JSCCustomGetter, CustomConstructor] HTMLImageElementConstructorConstructor Image; // Usable with new operator
100611

LayoutTests/ChangeLog

 12011-11-17 Arko Saha <arko@motorola.com>
 2
 3 Microdata: Support for properties attribute.
 4 https://bugs.webkit.org/show_bug.cgi?id=71050
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Added test for html properties collections.
 9
 10 * fast/dom/MicroData/names-property-must-be-correct-expected.txt: Added.
 11 * fast/dom/MicroData/names-property-must-be-correct.html: Added.
 12 * fast/dom/MicroData/names-property-test-expected.txt: Added.
 13 * fast/dom/MicroData/names-property-test.html: Added.
 14 * fast/dom/MicroData/properties-collection-behavior-add-remove-itemscope-attr-expected.txt: Added.
 15 * fast/dom/MicroData/properties-collection-behavior-add-remove-itemscope-attr.html: Added.
 16 * fast/dom/MicroData/properties-collection-must-be-correct-expected.txt: Added.
 17 * fast/dom/MicroData/properties-collection-must-be-correct.html: Added.
 18 * fast/dom/MicroData/properties-collection-must-ignore-properties-of-nested-items-expected.txt: Added.
 19 * fast/dom/MicroData/properties-collection-must-ignore-properties-of-nested-items.html: Added.
 20 * fast/dom/MicroData/properties-collection-must-see-the-properties-added-in-itemref-expected.txt: Added.
 21 * fast/dom/MicroData/properties-collection-must-see-the-properties-added-in-itemref.html: Added.
 22 * fast/dom/MicroData/properties-collection-test-expected.txt: Added.
 23 * fast/dom/MicroData/properties-collection-test.html: Added.
 24
1252011-11-17 Steve Block <steveblock@google.com>
226
327 Several animations/ tests flakily fail due to fragile setTimeout()-based framework
100611

LayoutTests/fast/dom/MicroData/names-property-must-be-correct-expected.txt

 1This tests that names.item() and names[index] must return correct property name in tree order and it should not contain duplicate tokens.
 2
 3Created element of type: div
 4Set attribute: itemscope, value: itemscope
 5PASS element.properties.names[0] == 'foo' is true
 6PASS element.properties.names[1] == 'bar' is true
 7PASS element.properties.names[2] == 'baz' is true
 8PASS element.properties.names[3] == 'qux' is true
 9
 10PASS element.properties.names.item(0) == 'foo' is true
 11PASS element.properties.names.item(1) == 'bar' is true
 12PASS element.properties.names.item(2) == 'baz' is true
 13PASS element.properties.names.item(3) == 'qux' is true
 14PASS successfullyParsed is true
 15
 16TEST COMPLETE
 17
0

LayoutTests/fast/dom/MicroData/names-property-must-be-correct.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../js/resources/js-test-pre.js"></script>
 5<script src="resources/microdata-common.js"></script>
 6</head>
 7<body>
 8<p>This tests that names.item() and names[index] must return correct property name in tree order and it should not contain duplicate tokens.</p>
 9<div id="console"></div>
 10<script>
 11var element = createElement('div', {itemscope: 'itemscope'},'<div itemprop="foo"></div><div itemprop="bar"><div itemprop="foo"></div><div itemprop="foo"></div></div><div itemprop="baz qux"></div>');
 12shouldBeTrue("element.properties.names[0] == 'foo'");
 13shouldBeTrue("element.properties.names[1] == 'bar'");
 14shouldBeTrue("element.properties.names[2] == 'baz'");
 15shouldBeTrue("element.properties.names[3] == 'qux'");
 16
 17debug('');
 18shouldBeTrue("element.properties.names.item(0) == 'foo'");
 19shouldBeTrue("element.properties.names.item(1) == 'bar'");
 20shouldBeTrue("element.properties.names.item(2) == 'baz'");
 21shouldBeTrue("element.properties.names.item(3) == 'qux'");
 22
 23</script>
 24<script src="../../js/resources/js-test-post.js"></script>
 25</body>
 26</html>
0

LayoutTests/fast/dom/MicroData/names-property-test-expected.txt

 1names property simple test.
 2
 3Created element of type: div
 4
 5The names property must be defined.
 6PASS element.properties.names is defined.
 7
 8The names property must return a DOMStringList object.
 9PASS element.properties.names == '[object DOMStringList]' is true
 10PASS successfullyParsed is true
 11
 12TEST COMPLETE
 13
0

LayoutTests/fast/dom/MicroData/names-property-test.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../js/resources/js-test-pre.js"></script>
 5<script src="resources/microdata-common.js"></script>
 6</head>
 7<body>
 8<p>names property simple test.</p>
 9<div id="console"></div>
 10<script>
 11var element = createElement('div', {});
 12
 13debug("<br>The names property must be defined.");
 14shouldBeDefined("element.properties.names");
 15
 16debug("<br>The names property must return a DOMStringList object.");
 17shouldBeTrue("element.properties.names == '[object DOMStringList]'");
 18
 19</script>
 20<script src="../../js/resources/js-test-post.js"></script>
 21</body>
 22</html>
0

LayoutTests/fast/dom/MicroData/properties-collection-behavior-add-remove-itemscope-attr-expected.txt

 1This tests the behavior of properties collection on adding or removing itemscope attribute.
 2
 3Created element of type: div
 4
 5The properties collection must be empty if the element does not have an itemscope attribute.
 6PASS element.properties.length == '0' is true
 7PASS element.properties[0] == undefined is true
 8PASS element.properties.item(0) == undefined is true
 9
 10The properties collection must become populated if we add itemscope attribute.
 11PASS element.properties.length == '1' is true
 12PASS element.properties[0] == element.firstChild is true
 13PASS element.properties.item(0) == element.firstChild is true
 14
 15The properties collection must become empty if we remove itemscope attribute.
 16PASS element.properties.length == '0' is true
 17PASS element.properties[0] == undefined is true
 18PASS element.properties.item(0) == undefined is true
 19PASS successfullyParsed is true
 20
 21TEST COMPLETE
 22
0

LayoutTests/fast/dom/MicroData/properties-collection-behavior-add-remove-itemscope-attr.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../js/resources/js-test-pre.js"></script>
 5<script src="resources/microdata-common.js"></script>
 6</head>
 7<body>
 8<p>This tests the behavior of properties collection on adding or removing itemscope attribute.</p>
 9<div id="console"></div>
 10<script>
 11var element = createElement('div', {}, '<div itemprop="foo">bar</div>');
 12
 13debug("<br>The properties collection must be empty if the element does not have an itemscope attribute.");
 14shouldBeTrue("element.properties.length == '0'");
 15shouldBeTrue("element.properties[0] == undefined");
 16shouldBeTrue("element.properties.item(0) == undefined");
 17
 18debug("<br>The properties collection must become populated if we add itemscope attribute.");
 19element.itemScope = true;
 20shouldBeTrue("element.properties.length == '1'");
 21shouldBeTrue("element.properties[0] == element.firstChild");
 22shouldBeTrue("element.properties.item(0) == element.firstChild");
 23
 24debug("<br>The properties collection must become empty if we remove itemscope attribute.");
 25element.itemScope = false;
 26shouldBeTrue("element.properties.length == '0'");
 27shouldBeTrue("element.properties[0] == undefined");
 28shouldBeTrue("element.properties.item(0) == undefined");
 29
 30</script>
 31<script src="../../js/resources/js-test-post.js"></script>
 32</body>
 33</html>
0

LayoutTests/fast/dom/MicroData/properties-collection-must-be-correct-expected.txt

 1This test ensures that properties collection of a Microdata item must be correct.
 2
 3Created element of type: div
 4Set attribute: itemscope, value: itemscope
 5
 6properties.length must be the total number of properties.
 7PASS propertiesCollection.length == '4' is true
 8
 9properties.item(index) and properties[index] must give each property in tree order'
 10PASS propertiesCollection.item(0) == childNodes[0] is true
 11PASS propertiesCollection.item(1) == childNodes[1] is true
 12PASS propertiesCollection.item(2) == childNodes[1].childNodes[0] is true
 13PASS propertiesCollection.item(3) == childNodes[2] is true
 14
 15PASS propertiesCollection[0] == childNodes[0] is true
 16PASS propertiesCollection[1] == childNodes[1] is true
 17PASS propertiesCollection[2] == childNodes[1].childNodes[0] is true
 18PASS propertiesCollection[3] == childNodes[2] is true
 19properties[index] and properties.item(index) must return undefined for out of range index.
 20PASS propertiesCollection[4] == undefined is true
 21PASS propertiesCollection.item(4) == undefined is true
 22PASS successfullyParsed is true
 23
 24TEST COMPLETE
 25
0

LayoutTests/fast/dom/MicroData/properties-collection-must-be-correct.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../js/resources/js-test-pre.js"></script>
 5<script src="resources/microdata-common.js"></script>
 6</head>
 7<body>
 8<p>This test ensures that properties collection of a Microdata item must be correct.</p>
 9<div id="console"></div>
 10<script>
 11var element = createElement('div', {itemscope: 'itemscope'}, '<div itemprop="foo"></div><div itemprop="bar"><div itemprop="foo"></div></div><div itemprop="baz qux"></div>');
 12var propertiesCollection = element.properties;
 13var childNodes = element.childNodes;
 14
 15debug("<br>properties.length must be the total number of properties.");
 16shouldBeTrue("propertiesCollection.length == '4'");
 17
 18debug("<br>properties.item(index) and properties[index] must give each property in tree order'");
 19shouldBeTrue("propertiesCollection.item(0) == childNodes[0]");
 20shouldBeTrue("propertiesCollection.item(1) == childNodes[1]");
 21shouldBeTrue("propertiesCollection.item(2) == childNodes[1].childNodes[0]");
 22shouldBeTrue("propertiesCollection.item(3) == childNodes[2]");
 23debug('');
 24
 25shouldBeTrue("propertiesCollection[0] == childNodes[0]");
 26shouldBeTrue("propertiesCollection[1] == childNodes[1]");
 27shouldBeTrue("propertiesCollection[2] == childNodes[1].childNodes[0]");
 28shouldBeTrue("propertiesCollection[3] == childNodes[2]");
 29
 30debug("properties[index] and properties.item(index) must return undefined for out of range index.");
 31shouldBeTrue("propertiesCollection[4] == undefined");
 32shouldBeTrue("propertiesCollection.item(4) == undefined");
 33
 34</script>
 35<script src="../../js/resources/js-test-post.js"></script>
 36</body>
 37</html>
0

LayoutTests/fast/dom/MicroData/properties-collection-must-ignore-properties-of-nested-items-expected.txt

 1This test ensures thet properties.item and length must ignore properties of nested items.
 2
 3Created element of type: div
 4Set attribute: itemscope, value: itemscope
 5PASS propertiesCollection.length == '2' is true
 6PASS propertiesCollection[0] == childNodes[0] is true
 7PASS propertiesCollection.item(0) == childNodes[0] is true
 8PASS propertiesCollection[1] == childNodes[1].firstChild is true
 9PASS propertiesCollection.item(1) == childNodes[1].firstChild is true
 10PASS successfullyParsed is true
 11
 12TEST COMPLETE
 13
0

LayoutTests/fast/dom/MicroData/properties-collection-must-ignore-properties-of-nested-items.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../js/resources/js-test-pre.js"></script>
 5<script src="resources/microdata-common.js"></script>
 6</head>
 7<body>
 8<p>This test ensures thet properties.item and length must ignore properties of nested items.</p>
 9<div id="console"></div>
 10<script>
 11var element = createElement('div', {itemscope: 'itemscope'}, '<div itemscope itemprop="foo"><div itemprop="bar"></div></div><div><div itemprop="baz"></div></div>');
 12var propertiesCollection = element.properties;
 13var childNodes = element.childNodes;
 14
 15shouldBeTrue("propertiesCollection.length == '2'");
 16shouldBeTrue("propertiesCollection[0] == childNodes[0]");
 17shouldBeTrue("propertiesCollection.item(0) == childNodes[0]");
 18shouldBeTrue("propertiesCollection[1] == childNodes[1].firstChild");
 19shouldBeTrue("propertiesCollection.item(1) == childNodes[1].firstChild");
 20
 21</script>
 22<script src="../../js/resources/js-test-post.js"></script>
 23</body>
 24</html>
0

LayoutTests/fast/dom/MicroData/properties-collection-must-see-the-properties-added-in-itemref-expected.txt

 1This tests that properties.item and length must see the properties added with itemref.
 2
 3PASS propertiesCollection.length == '4' is true
 4PASS propertiesCollection.item(0) == divs[0] is true
 5PASS propertiesCollection.item(1) == divs[2] is true
 6PASS propertiesCollection.item(2) == divs[3] is true
 7PASS propertiesCollection.item(3) == divs[4] is true
 8PASS successfullyParsed is true
 9
 10TEST COMPLETE
 11
0

LayoutTests/fast/dom/MicroData/properties-collection-must-see-the-properties-added-in-itemref.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../js/resources/js-test-pre.js"></script>
 5<script src="resources/microdata-common.js"></script>
 6</head>
 7<body>
 8<p>This tests that properties.item and length must see the properties added with itemref.</p>
 9
 10<div itemprop="foo" id="id1"></div>
 11<div itemscope itemref="id2 id1">
 12<div itemprop="bar"></div>
 13</div>
 14<div itemprop="baz" id="id2">
 15<div itemprop="qux"></div>
 16</div>
 17
 18<div id="console"></div>
 19<script>
 20var item = document.getItems()[0];
 21var propertiesCollection = item.properties;
 22var divs = document.getElementsByTagName('div');
 23
 24shouldBeTrue("propertiesCollection.length == '4'");
 25shouldBeTrue("propertiesCollection.item(0) == divs[0]");
 26shouldBeTrue("propertiesCollection.item(1) == divs[2]");
 27shouldBeTrue("propertiesCollection.item(2) == divs[3]");
 28shouldBeTrue("propertiesCollection.item(3) == divs[4]");
 29
 30
 31</script>
 32<script src="../../js/resources/js-test-post.js"></script>
 33</body>
 34</html>
0

LayoutTests/fast/dom/MicroData/properties-collection-test-expected.txt

 1Microdata properties collection simple test.
 2
 3Created element of type: div
 4
 5The properties property must be defined.
 6PASS element.properties is defined.
 7
 8The properties property must return a HTMLPropertiesCollection object.
 9PASS element.properties == '[object HTMLPropertiesCollection]' is true
 10PASS successfullyParsed is true
 11
 12TEST COMPLETE
 13
0

LayoutTests/fast/dom/MicroData/properties-collection-test.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../js/resources/js-test-pre.js"></script>
 5<script src="resources/microdata-common.js"></script>
 6</head>
 7<body>
 8<p>Microdata properties collection simple test.</p>
 9<div id="console"></div>
 10<script>
 11var element = createElement('div', {});
 12
 13debug("<br>The properties property must be defined.");
 14shouldBeDefined("element.properties");
 15
 16debug("<br>The properties property must return a HTMLPropertiesCollection object.");
 17shouldBeTrue("element.properties == '[object HTMLPropertiesCollection]'");
 18
 19</script>
 20<script src="../../js/resources/js-test-post.js"></script>
 21</body>
 22</html>
0