Bug 6639

Summary: for/in returns duplicate keys when key exists on object and its prototype
Product: WebKit Reporter: Jesse Costello-Good <jesse>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: ap, ian, maksim, mrowe, tolmasky
Priority: P2 Keywords: HasReduction
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
Bug Depends on:    
Bug Blocks: 10489    
Attachments:
Description Flags
Test case packged suitable for a layout test
none
Further simplified test case none

Description Jesse Costello-Good 2006-01-17 20:52:55 PST
The following code evaluates to "toString toString", however, for...in should never return duplicate keys.

var A = function() {};
A.prototype.toString = function() { "A" };

var B = function() {};
B.prototype = new A();
B.prototype.toString = function() { "B" };

var s = "";
for (var f in B.prototype) s += f + " ";
s
Comment 1 Jesse Costello-Good 2006-01-17 20:53:15 PST
I am evaluating Safari for a port of TIBCO(R) General Interface, a mature AJAX platform that is currently IE 
only. Fixing this bug would make the port more feasible.
Comment 2 Mark Rowe (bdash) 2006-01-17 21:56:42 PST
Created attachment 5754 [details]
Test case packged suitable for a layout test
Comment 3 Mark Rowe (bdash) 2006-01-17 21:58:26 PST
Thanks for the bug report.  I can confirm this fails in both WebKit 417.9 and ToT WebKit.
Comment 4 Maciej Stachowiak 2006-02-20 06:42:51 PST
I had a possible fix for this at one point but it caused an apparent performance regression. Maybe time to retest.
Comment 5 Mark Rowe (bdash) 2006-03-08 02:51:22 PST
Created attachment 6937 [details]
Further simplified test case
Comment 6 Mark Rowe (bdash) 2006-03-08 02:52:03 PST
*** Bug 7658 has been marked as a duplicate of this bug. ***
Comment 7 Alexey Proskuryakov 2006-07-16 21:44:23 PDT

*** This bug has been marked as a duplicate of 9950 ***
Comment 8 Jesse Costello-Good 2006-11-18 17:22:33 PST
Thanks to the Safari team for being so responsive regarding requests for better advanced AJAX support. Safari is quickly becoming a 1st class AJAX platform.
Comment 9 Jesse Costello-Good 2007-09-04 14:42:32 PDT
This is fixed in Safari 3 for iPhone 1.0.2