RESOLVED FIXED 3293
Object.prototype.hasOwnProperty() missing
https://bugs.webkit.org/show_bug.cgi?id=3293
Summary Object.prototype.hasOwnProperty() missing
Gavin Kistner
Reported 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
Attachments
Webpage with simple test case (1.63 KB, text/html)
2005-06-07 05:34 PDT, Gavin Kistner
no flags
Implementation of Object.prototype.hasOwnProperty (2.70 KB, patch)
2005-06-10 07:21 PDT, Mark Rowe (bdash)
no flags
Layout test (679 bytes, text/html)
2005-06-10 07:30 PDT, Mark Rowe (bdash)
no flags
Expected layout test output (464 bytes, text/plain)
2005-06-10 07:34 PDT, Mark Rowe (bdash)
no flags
Updated implementation that handles special properties correctly (32.77 KB, patch)
2005-06-12 21:40 PDT, Mark Rowe (bdash)
darin: review-
Updated layout test (1.60 KB, text/html)
2005-06-12 21:43 PDT, Mark Rowe (bdash)
no flags
Updated layout test output (1.96 KB, text/plain)
2005-06-12 21:44 PDT, Mark Rowe (bdash)
no flags
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-
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
Fixed version of patch - passes all layout tests. (29.53 KB, patch)
2005-07-02 00:55 PDT, Maciej Stachowiak
sullivan: review+
Gavin Kistner
Comment 1 2005-06-07 05:34:05 PDT
Created attachment 2126 [details] Webpage with simple test case
Gavin Kistner
Comment 2 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
Mark Rowe (bdash)
Comment 3 2005-06-10 07:21:01 PDT
Created attachment 2218 [details] Implementation of Object.prototype.hasOwnProperty
Mark Rowe (bdash)
Comment 4 2005-06-10 07:30:13 PDT
Created attachment 2219 [details] Layout test
Mark Rowe (bdash)
Comment 5 2005-06-10 07:34:09 PDT
Created attachment 2220 [details] Expected layout test output
Mark Rowe (bdash)
Comment 6 2005-06-12 21:40:57 PDT
Created attachment 2286 [details] Updated implementation that handles special properties correctly
Mark Rowe (bdash)
Comment 7 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.
Mark Rowe (bdash)
Comment 8 2005-06-12 21:43:46 PDT
Created attachment 2287 [details] Updated layout test
Mark Rowe (bdash)
Comment 9 2005-06-12 21:44:31 PDT
Created attachment 2288 [details] Updated layout test output
Darin Adler
Comment 10 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.
Mark Rowe (bdash)
Comment 11 2005-06-19 23:56:33 PDT
Created attachment 2483 [details] Updated patch with Object::hasProperty improved for the integer case
Maciej Stachowiak
Comment 12 2005-06-20 03:27:01 PDT
I have this in my tree and ready to commit, just need to complete ChangeLog entries.
Maciej Stachowiak
Comment 13 2005-06-20 19:00:56 PDT
Landed.
Adele Peterson
Comment 14 2005-06-21 17:32:06 PDT
This change has caused two failures in the layout-tests. I'm rolling the fix out.
Adele Peterson
Comment 15 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
Adele Peterson
Comment 16 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
Maciej Stachowiak
Comment 17 2005-07-02 00:55:11 PDT
Created attachment 2747 [details] Fixed version of patch - passes all layout tests.
John Sullivan
Comment 18 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.
Maciej Stachowiak
Comment 19 2005-07-29 14:56:01 PDT
*** Bug 4203 has been marked as a duplicate of this bug. ***
Mark Rowe (bdash)
Comment 20 2005-11-01 02:09:43 PST
*** Bug 5569 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.