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
Created attachment 2126 [details] Webpage with simple test case
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
Created attachment 2218 [details] Implementation of Object.prototype.hasOwnProperty
Created attachment 2219 [details] Layout test
Created attachment 2220 [details] Expected layout test output
Created attachment 2286 [details] Updated implementation that handles special properties correctly
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.
Created attachment 2287 [details] Updated layout test
Created attachment 2288 [details] Updated layout test output
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.
Created attachment 2483 [details] Updated patch with Object::hasProperty improved for the integer case
I have this in my tree and ready to commit, just need to complete ChangeLog entries.
Landed.
This change has caused two failures in the layout-tests. I'm rolling the fix out.
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
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
Created attachment 2747 [details] Fixed version of patch - passes all layout tests.
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.
*** Bug 4203 has been marked as a duplicate of this bug. ***
*** Bug 5569 has been marked as a duplicate of this bug. ***