Bug 6639 - for/in returns duplicate keys when key exists on object and its prototype
Summary: for/in returns duplicate keys when key exists on object and its prototype
Status: RESOLVED DUPLICATE of bug 9950
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 420+
Hardware: Macintosh OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords: HasReduction
: 7658 (view as bug list)
Depends on:
Blocks: 10489
  Show dependency treegraph
 
Reported: 2006-01-17 20:52 PST by Jesse Costello-Good
Modified: 2007-09-04 14:42 PDT (History)
5 users (show)

See Also:


Attachments
Test case packged suitable for a layout test (1.08 KB, text/html)
2006-01-17 21:56 PST, Mark Rowe (bdash)
no flags Details
Further simplified test case (931 bytes, text/html)
2006-03-08 02:51 PST, Mark Rowe (bdash)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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