Bug 98025

Summary: [Microdata] itemprop names must not override builtin properties
Product: WebKit Reporter: Arko Saha <arko>
Component: DOMAssignee: Arko Saha <arko>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, haraken, japhet, rniwa, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 92986    
Attachments:
Description Flags
Patch haraken: review+

Description Arko Saha 2012-10-01 06:28:43 PDT
HTMLPropertiesCollection[propertyName] must not return PropertyNodeList if 'propertyName' is a method of HTMLPropertiesCollection interface.

Sample test:

test(function () {
	var testEl = makeEl('div',{itemscope:'itemscope', id:'outerDiv'});
	var item = testEl.properties.item;
	testEl.innerHTML = '<div itemprop="item" id="innerDiv"></div>';
	assert_equals( testEl.properties['item'], item, 'item' );
}, 'itemprop names must not override builtin properties');

Expected: testEl.properties['item'] should not return PropertyNodeList (NodeList contains innerDiv) because 'item' is a method of HTMLPropertiesCollection interface.

It should return -

function item() {
    [native code]
}

Actual: Returns "[object PropertyNodeList]"
Comment 1 Arko Saha 2012-10-01 06:36:43 PDT
Created attachment 166464 [details]
Patch
Comment 2 Kentaro Hara 2012-10-01 06:47:23 PDT
Comment on attachment 166464 [details]
Patch

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

Looks good.

> Source/WebCore/ChangeLog:10
> +        We should look in the prototype for functions before assuming it as
> +        an item's name. Return false if the prototype of the object has a
> +        property (function) with propertyName.

Would you add a spec link to the ChangeLog? (I'm sure this change would be correct, but I'd like to verify it in the spec just in case.)
Comment 3 Arko Saha 2012-10-01 07:39:23 PDT
(In reply to comment #2)
> Would you add a spec link to the ChangeLog? (I'm sure this change would be correct, but I'd like to verify it in the spec just in case.)

Named properties spec is defined http://dev.w3.org/2006/webapi/WebIDL/#idl-named-properties
According to named property visibility algorithm http://dev.w3.org/2006/webapi/WebIDL/#indexed-and-named-properties
...
7. If the result of calling the [[HasProperty]] internal method on prototype with property name P is true, then return false.
...

Also [OverrideBuiltins] is not declared for any of the properties, hence no overriding is allowed in this case.
Comment 4 Kentaro Hara 2012-10-01 08:12:24 PDT
Comment on attachment 166464 [details]
Patch

Thanks for the clarification!
Comment 5 Arko Saha 2012-10-02 23:28:45 PDT
Committed r130255: <http://trac.webkit.org/changeset/130255>