Bug 6870

Summary: REGRESSION: JavaScript Date constructor won't accept another Date object
Product: WebKit Reporter: andrew
Component: JavaScriptCoreAssignee: Darin Adler <darin>
Status: VERIFIED FIXED    
Severity: Normal Keywords: HasReduction, Regression
Priority: P1    
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
URL: http://www.qantas.com.au/regions/dyn/home/qualifier-region-au
Bug Depends on:    
Bug Blocks: 6908    
Attachments:
Description Flags
Test case v1
none
patch to fix bug, including a test sullivan: review+

Description andrew 2006-01-27 02:29:47 PST
Go to www.qantas.com.au.  Click on the tab labelled "International" and you'll find you can't select departure dates at all.
Comment 1 Joost de Valk (AlthA) 2006-01-27 04:05:59 PST
Confirmed, this one needs reduction.
Comment 2 David Kilzer (:ddkilzer) 2006-01-27 05:12:37 PST
This is a regression.  Works for me in Safari 2.0.3 (417.8) on 10.4.4.
Comment 3 Joost de Valk (AlthA) 2006-01-27 05:16:27 PST
If it's a regression, it should be P1 :)
Comment 4 David Kilzer (:ddkilzer) 2006-01-27 18:55:02 PST
This is broken in WebKit-CVS-2005-10-01 03-27-01 GMT.dmg, the very first nightly build available.

It broke between the time WebKit was open-sourced and the date on the above nightly.
Comment 5 David Kilzer (:ddkilzer) 2006-01-27 20:07:17 PST
Created attachment 6035 [details]
Test case v1
Comment 6 David Kilzer (:ddkilzer) 2006-01-27 20:11:08 PST
The Date object in JavaScript won't accept another Date object in a single-argument constructor:

  var d = new Date(new Date());  // Results in "Invalid Date" 

Works correctly in Firefox 1.5 and Safari 2.0.3 (417.8) on 10.4.4.
Comment 7 Darin Adler 2006-01-28 19:18:45 PST
I've got a fix. The Date constructor was not following the algorithm from the JavaScript specification properly. It was supposed to convert to a primitive, then check to see if the result is a string. Instead it was checking to see if the result was a string first.
Comment 8 Darin Adler 2006-01-28 20:25:49 PST
Created attachment 6060 [details]
patch to fix bug, including a test
Comment 9 David Kilzer (:ddkilzer) 2006-01-31 05:56:17 PST
Verified fix.
Comment 10 Eric Seidel (no email) 2006-01-31 21:20:57 PST
Removing Regression keyword from bugs already fixed.
Comment 11 David Kilzer (:ddkilzer) 2006-02-26 04:20:17 PST
Added back removed keywords.