Bug 4203
| Summary: | hasOwnProperty() returns true for Object.protoype properties | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Vicki Murley <vicki> |
| Component: | JavaScriptCore | Assignee: | Maciej Stachowiak <mjs> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | Normal | ||
| Priority: | P2 | ||
| Version: | 420+ | ||
| Hardware: | Mac | ||
| OS: | OS X 10.4 | ||
Vicki Murley
This bug is also in Radar as <rdar://4190700>
See http://phrogz.net/JS/hasOwnProperty_test.html:
Object.prototype.toSourceCode = function(){ /*stuff*/ }
var animalSounds = { cat:'meow', dog:'woof' };
var output = '';
for (var animal in animalSounds){
if ( !animalSounds.hasOwnProperty || animalSounds.hasOwnProperty(animal) ){
output += 'The '+animal+' says "'+animalSounds[animal]+'"\n';
}
}
Expected output:
The cat says "meow"
The dog says "woof"
Actual output from Safari 2.0 release 1:
The toSourceCode says "function ()
{
}"
The cat says "meow"
The dog says "woof"
-------------------------------------------
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Maciej Stachowiak
Already fixed.
*** This bug has been marked as a duplicate of 3293 ***