Bug 3293 - Object.prototype.hasOwnProperty() missing
Summary: Object.prototype.hasOwnProperty() missing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Major
Assignee: Maciej Stachowiak
URL:
Keywords:
: 4203 5569 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-07 05:31 PDT by Gavin Kistner
Modified: 2005-11-01 02:09 PST (History)
3 users (show)

See Also:


Attachments
Webpage with simple test case (1.63 KB, text/html)
2005-06-07 05:34 PDT, Gavin Kistner
no flags Details
Implementation of Object.prototype.hasOwnProperty (2.70 KB, patch)
2005-06-10 07:21 PDT, Mark Rowe (bdash)
no flags Details | Formatted Diff | Diff
Layout test (679 bytes, text/html)
2005-06-10 07:30 PDT, Mark Rowe (bdash)
no flags Details
Expected layout test output (464 bytes, text/plain)
2005-06-10 07:34 PDT, Mark Rowe (bdash)
no flags Details
Updated implementation that handles special properties correctly (32.77 KB, patch)
2005-06-12 21:40 PDT, Mark Rowe (bdash)
darin: review-
Details | Formatted Diff | Diff
Updated layout test (1.60 KB, text/html)
2005-06-12 21:43 PDT, Mark Rowe (bdash)
no flags Details
Updated layout test output (1.96 KB, text/plain)
2005-06-12 21:44 PDT, Mark Rowe (bdash)
no flags Details
Updated patch with Object::hasProperty improved for the integer case (33.11 KB, patch)
2005-06-19 23:56 PDT, Mark Rowe (bdash)
adele: review-
Details | Formatted Diff | Diff
other layout test that uses hasOwnProperty that needs to be added (625 bytes, text/html)
2005-06-21 18:06 PDT, Adele Peterson
no flags Details
Fixed version of patch - passes all layout tests. (29.53 KB, patch)
2005-07-02 00:55 PDT, Maciej Stachowiak
sullivan: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gavin Kistner 2005-06-07 05:31:29 PDT
The hasOwnProperty() method is specified in ECMAScript-262 rev3 section 15.2.4.5 (page 85), but is 
missing from Safari/JavascriptCore.

Test pages at http://phrogz.net/JS/hasOwnProperty.html and http://phrogz.net/JS/
hasOwnProperty_test.html

This bug is copied from Apple's Bug Reporter #3749342
Comment 1 Gavin Kistner 2005-06-07 05:34:05 PDT
Created attachment 2126 [details]
Webpage with simple test case
Comment 2 Gavin Kistner 2005-06-07 06:14:39 PDT
The severity of this bug is due to the fact that--without this feature--it is impossible to extend objects 
through the prototype without breaking the iteration of properties in an object using the
for ( var propName in myObj )
loop style.

A real-world case where this breaks is http://phrogz.net/JS/Object.prototype.toSourceCode.js (which was 
'hacked' to look for 'toSourceCode' as an explicit key, but which breaks if any other key is added to the 
prototype, such as http://phrogz.net/JS/Object.prototype.duplicate.js 
Comment 3 Mark Rowe (bdash) 2005-06-10 07:21:01 PDT
Created attachment 2218 [details]
Implementation of Object.prototype.hasOwnProperty
Comment 4 Mark Rowe (bdash) 2005-06-10 07:30:13 PDT
Created attachment 2219 [details]
Layout test
Comment 5 Mark Rowe (bdash) 2005-06-10 07:34:09 PDT
Created attachment 2220 [details]
Expected layout test output
Comment 6 Mark Rowe (bdash) 2005-06-12 21:40:57 PDT
Created attachment 2286 [details]
Updated implementation that handles special properties correctly
Comment 7 Mark Rowe (bdash) 2005-06-12 21:42:36 PDT
Comment on attachment 2286 [details]
Updated implementation that handles special properties correctly

This patch adds a new hasOwnProperty method to ObjectImp, and alters
hasProperty to delegate to it.	Subclasses are updated to implement
hasOwnProperty rather than hasProperty where needed.
Comment 8 Mark Rowe (bdash) 2005-06-12 21:43:46 PDT
Created attachment 2287 [details]
Updated layout test
Comment 9 Mark Rowe (bdash) 2005-06-12 21:44:31 PDT
Created attachment 2288 [details]
Updated layout test output
Comment 10 Darin Adler 2005-06-13 23:34:23 PDT
Comment on attachment 2286 [details]
Updated implementation that handles special properties correctly

ObjectImp::hasProperty that takes an integer needs to call through to
hasOwnProperty that takes an integer; it's important to stay in the integer
code path until you get to the array implementation of hasOwnProperty.

Other than that, this patch looks good.
Comment 11 Mark Rowe (bdash) 2005-06-19 23:56:33 PDT
Created attachment 2483 [details]
Updated patch with Object::hasProperty improved for the integer case
Comment 12 Maciej Stachowiak 2005-06-20 03:27:01 PDT
I have this in my tree and ready to commit, just need to complete ChangeLog entries.
Comment 13 Maciej Stachowiak 2005-06-20 19:00:56 PDT
Landed.
Comment 14 Adele Peterson 2005-06-21 17:32:06 PDT
This change has caused two failures in the layout-tests.  I'm rolling the fix out.
Comment 15 Adele Peterson 2005-06-21 18:04:56 PDT
Comment on attachment 2483 [details]
Updated patch with Object::hasProperty improved for the integer case

Setting the review - flag.  We need a new patch that fixes the layout-test
issues.  When this gets fixed, we also need to re-add a few layout tests
Comment 16 Adele Peterson 2005-06-21 18:06:46 PDT
Created attachment 2537 [details]
other layout test that uses hasOwnProperty that needs to be added

This is another layout test that we need to land when we fix this bug
Comment 17 Maciej Stachowiak 2005-07-02 00:55:11 PDT
Created attachment 2747 [details]
Fixed version of patch - passes all layout tests.
Comment 18 John Sullivan 2005-07-02 13:31:12 PDT
Comment on attachment 2747 [details]
Fixed version of patch - passes all layout tests.

Don't forget to commit the new layout test that Adele attached.
Comment 19 Maciej Stachowiak 2005-07-29 14:56:01 PDT
*** Bug 4203 has been marked as a duplicate of this bug. ***
Comment 20 Mark Rowe (bdash) 2005-11-01 02:09:43 PST
*** Bug 5569 has been marked as a duplicate of this bug. ***