Bug 6870 - REGRESSION: JavaScript Date constructor won't accept another Date object
Summary: REGRESSION: JavaScript Date constructor won't accept another Date object
Status: VERIFIED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P1 Normal
Assignee: Darin Adler
URL: http://www.qantas.com.au/regions/dyn/...
Keywords: HasReduction, Regression
Depends on:
Blocks: 6908
  Show dependency treegraph
 
Reported: 2006-01-27 02:29 PST by andrew
Modified: 2006-02-26 04:20 PST (History)
0 users

See Also:


Attachments
Test case v1 (241 bytes, text/html)
2006-01-27 20:07 PST, David Kilzer (:ddkilzer)
no flags Details
patch to fix bug, including a test (10.32 KB, patch)
2006-01-28 20:25 PST, Darin Adler
sullivan: review+
Details | Formatted Diff | Diff

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