Title: [104267] trunk
Revision
104267
Author
[email protected]
Date
2012-01-05 21:29:28 -0800 (Thu, 05 Jan 2012)

Log Message

Date constructor handles infinite values incorrectly.
https://bugs.webkit.org/show_bug.cgi?id=70998

Reviewed by Filip Pizlo.

Source/_javascript_Core: 

* runtime/DateConstructor.cpp:
(JSC::constructDate):
    - should be checking !finite rather then isnan.

LayoutTests: 

* fast/js/date-constructor-expected.txt:
* fast/js/script-tests/date-constructor.js:
    - Added test cases.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (104266 => 104267)


--- trunk/LayoutTests/ChangeLog	2012-01-06 04:48:14 UTC (rev 104266)
+++ trunk/LayoutTests/ChangeLog	2012-01-06 05:29:28 UTC (rev 104267)
@@ -1,5 +1,16 @@
 2012-01-05  Gavin Barraclough  <[email protected]>
 
+        Date constructor handles infinite values incorrectly.
+        https://bugs.webkit.org/show_bug.cgi?id=70998
+
+        Reviewed by Filip Pizlo.
+
+        * fast/js/date-constructor-expected.txt:
+        * fast/js/script-tests/date-constructor.js:
+            - Added test cases.
+
+2012-01-05  Gavin Barraclough  <[email protected]>
+
         date.toISOString produces incorrect results for dates with ms prior to 1970
         https://bugs.webkit.org/show_bug.cgi?id=75684
 

Modified: trunk/LayoutTests/fast/js/date-constructor-expected.txt (104266 => 104267)


--- trunk/LayoutTests/fast/js/date-constructor-expected.txt	2012-01-06 04:48:14 UTC (rev 104266)
+++ trunk/LayoutTests/fast/js/date-constructor-expected.txt	2012-01-06 05:29:28 UTC (rev 104267)
@@ -24,6 +24,14 @@
 PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
 PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
 PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
+PASS Number(new Date(new Date(Infinity, 1, 1, 1, 1, 1, 1, 1, 1))) is Number.NaN
+PASS Number(new Date(new Date(1, Infinity, 1, 1, 1, 1, 1, 1, 1))) is Number.NaN
+PASS Number(new Date(new Date(1, 1, Infinity, 1, 1, 1, 1, 1, 1))) is Number.NaN
+PASS Number(new Date(new Date(1, 1, 1, Infinity, 1, 1, 1, 1, 1))) is Number.NaN
+PASS Number(new Date(new Date(1, 1, 1, 1, Infinity, 1, 1, 1, 1))) is Number.NaN
+PASS Number(new Date(new Date(1, 1, 1, 1, 1, Infinity, 1, 1, 1))) is Number.NaN
+PASS Number(new Date(new Date(1, 1, 1, 1, 1, 1, Infinity, 1, 1))) is Number.NaN
+PASS Number(new Date(new Date(1, 1, 1, 1, 1, 1, 1, 1, Infinity))) is -2174741938999
 PASS testStr is "1234567"
 PASS testStr is "1234567"
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/fast/js/script-tests/date-constructor.js (104266 => 104267)


--- trunk/LayoutTests/fast/js/script-tests/date-constructor.js	2012-01-06 04:48:14 UTC (rev 104266)
+++ trunk/LayoutTests/fast/js/script-tests/date-constructor.js	2012-01-06 05:29:28 UTC (rev 104267)
@@ -35,6 +35,15 @@
 shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799538999');
 shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799538999');
 
+shouldBe("Number(new Date(new Date(Infinity, 1, 1, 1, 1, 1, 1, 1, 1)))", 'Number.NaN');
+shouldBe("Number(new Date(new Date(1, Infinity, 1, 1, 1, 1, 1, 1, 1)))", 'Number.NaN');
+shouldBe("Number(new Date(new Date(1, 1, Infinity, 1, 1, 1, 1, 1, 1)))", 'Number.NaN');
+shouldBe("Number(new Date(new Date(1, 1, 1, Infinity, 1, 1, 1, 1, 1)))", 'Number.NaN');
+shouldBe("Number(new Date(new Date(1, 1, 1, 1, Infinity, 1, 1, 1, 1)))", 'Number.NaN');
+shouldBe("Number(new Date(new Date(1, 1, 1, 1, 1, Infinity, 1, 1, 1)))", 'Number.NaN');
+shouldBe("Number(new Date(new Date(1, 1, 1, 1, 1, 1, Infinity, 1, 1)))", 'Number.NaN');
+shouldBe("Number(new Date(new Date(1, 1, 1, 1, 1, 1, 1, 1, Infinity)))", '-2174741938999');
+
 // In Firefox, the results of the following tests are timezone-dependent, which likely implies that the implementation is not quite correct.
 // Our results are even worse, though, as the dates are clipped: (new Date(1111, 1201).getTime()) == (new Date(1111, 601).getTime())
 // shouldBe('new Date(1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111).getTime() - timeZoneOffset', '-24085894227889');

Modified: trunk/Source/_javascript_Core/ChangeLog (104266 => 104267)


--- trunk/Source/_javascript_Core/ChangeLog	2012-01-06 04:48:14 UTC (rev 104266)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-01-06 05:29:28 UTC (rev 104267)
@@ -1,5 +1,16 @@
 2012-01-05  Gavin Barraclough  <[email protected]>
 
+        Date constructor handles infinite values incorrectly.
+        https://bugs.webkit.org/show_bug.cgi?id=70998
+
+        Reviewed by Filip Pizlo.
+
+        * runtime/DateConstructor.cpp:
+        (JSC::constructDate):
+            - should be checking !finite rather then isnan.
+
+2012-01-05  Gavin Barraclough  <[email protected]>
+
         date.toISOString produces incorrect results for dates with ms prior to 1970
         https://bugs.webkit.org/show_bug.cgi?id=75684
 

Modified: trunk/Source/_javascript_Core/runtime/DateConstructor.cpp (104266 => 104267)


--- trunk/Source/_javascript_Core/runtime/DateConstructor.cpp	2012-01-06 04:48:14 UTC (rev 104266)
+++ trunk/Source/_javascript_Core/runtime/DateConstructor.cpp	2012-01-06 05:29:28 UTC (rev 104267)
@@ -125,13 +125,13 @@
             args.at(5).toNumber(exec), 
             args.at(6).toNumber(exec)
         };
-        if (isnan(doubleArguments[0])
-                || isnan(doubleArguments[1])
-                || (numArgs >= 3 && isnan(doubleArguments[2]))
-                || (numArgs >= 4 && isnan(doubleArguments[3]))
-                || (numArgs >= 5 && isnan(doubleArguments[4]))
-                || (numArgs >= 6 && isnan(doubleArguments[5]))
-                || (numArgs >= 7 && isnan(doubleArguments[6])))
+        if (!isfinite(doubleArguments[0])
+            || !isfinite(doubleArguments[1])
+            || (numArgs >= 3 && !isfinite(doubleArguments[2]))
+            || (numArgs >= 4 && !isfinite(doubleArguments[3]))
+            || (numArgs >= 5 && !isfinite(doubleArguments[4]))
+            || (numArgs >= 6 && !isfinite(doubleArguments[5]))
+            || (numArgs >= 7 && !isfinite(doubleArguments[6])))
             value = std::numeric_limits<double>::quiet_NaN();
         else {
             GregorianDateTime t;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to