[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 00:32:25 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit a0a45e5c2e2524f8b5ccad225dc43b12c3f7f891
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Dec 11 15:39:30 2009 +0000

    2009-12-11  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            Fix a problem that JSC::gregorianDateTimeToMS() returns a negative
            value for a huge year value.
            https://bugs.webkit.org/show_bug.cgi?id=32304
    
            * wtf/DateMath.cpp:
            (WTF::dateToDaysFrom1970): Renamed from dateToDayInYear, and changed the return type to double.
            (WTF::calculateDSTOffset): Follow the dateToDaysFrom1970() change.
            (WTF::timeClip): Use maxECMAScriptTime.
            (JSC::gregorianDateTimeToMS): Follow the dateToDaysFrom1970() change.
    2009-12-11  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            Fix a problem that JSC::gregorianDateTimeToMS() returns a negative
            value for a huge year value.
            https://bugs.webkit.org/show_bug.cgi?id=32304
    
            * fast/js/date-daysfrom1970-overflow-expected.txt: Added.
            * fast/js/date-daysfrom1970-overflow.html: Added.
            * fast/js/script-tests/date-daysfrom1970-overflow.js: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51986 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 829cc98..d1e1e66 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,17 @@
+2009-12-11  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Fix a problem that JSC::gregorianDateTimeToMS() returns a negative
+        value for a huge year value.
+        https://bugs.webkit.org/show_bug.cgi?id=32304
+
+        * wtf/DateMath.cpp:
+        (WTF::dateToDaysFrom1970): Renamed from dateToDayInYear, and changed the return type to double.
+        (WTF::calculateDSTOffset): Follow the dateToDaysFrom1970() change.
+        (WTF::timeClip): Use maxECMAScriptTime.
+        (JSC::gregorianDateTimeToMS): Follow the dateToDaysFrom1970() change.
+
 2009-12-10  Adam Barth  <abarth at webkit.org>
 
         No review, rolling out r51975.
diff --git a/JavaScriptCore/wtf/DateMath.cpp b/JavaScriptCore/wtf/DateMath.cpp
index 187fa63..df416d1 100644
--- a/JavaScriptCore/wtf/DateMath.cpp
+++ b/JavaScriptCore/wtf/DateMath.cpp
@@ -120,6 +120,10 @@ static const double secondsPerYear = 24.0 * 60.0 * 60.0 * 365.0;
 static const double usecPerSec = 1000000.0;
 
 static const double maxUnixTime = 2145859200.0; // 12/31/2037
+// ECMAScript asks not to support for a date of which total
+// millisecond value is larger than the following value.
+// See 15.9.1.14 of ECMA-262 5th edition.
+static const double maxECMAScriptTime = 8.64E15;
 
 // Day of year for the first day of each month, where index 0 is January, and day 0 is January 1.
 // First for non-leap years, then for leap years.
@@ -306,7 +310,7 @@ static inline double timeToMS(double hour, double min, double sec, double ms)
     return (((hour * minutesPerHour + min) * secondsPerMinute + sec) * msPerSecond + ms);
 }
 
-static int dateToDayInYear(int year, int month, int day)
+static double dateToDaysFrom1970(int year, int month, int day)
 {
     year += month / 12;
 
@@ -316,7 +320,8 @@ static int dateToDayInYear(int year, int month, int day)
         --year;
     }
 
-    int yearday = static_cast<int>(floor(daysFrom1970ToYear(year)));
+    double yearday = floor(daysFrom1970ToYear(year));
+    ASSERT((year >= 1970 && yearday >= 0) || (year < 1970 && yearday < 0));
     int monthday = monthToDayInYear(month, isLeapYear(year));
 
     return yearday + monthday + day - 1;
@@ -452,7 +457,7 @@ static double calculateDSTOffset(double ms, double utcOffset)
         int dayInYearLocal = dayInYear(ms, year);
         int dayInMonth = dayInMonthFromDayInYear(dayInYearLocal, leapYear);
         int month = monthFromDayInYear(dayInYearLocal, leapYear);
-        int day = dateToDayInYear(equivalentYear, month, dayInMonth);
+        double day = dateToDaysFrom1970(equivalentYear, month, dayInMonth);
         ms = (day * msPerDay) + msToMilliseconds(ms);
     }
 
@@ -841,7 +846,7 @@ double timeClip(double t)
 {
     if (!isfinite(t))
         return NaN;
-    if (fabs(t) > 8.64E15)
+    if (fabs(t) > maxECMAScriptTime)
         return NaN;
     return trunc(t);
 }
@@ -927,7 +932,7 @@ double getUTCOffset(ExecState* exec)
 
 double gregorianDateTimeToMS(ExecState* exec, const GregorianDateTime& t, double milliSeconds, bool inputIsUTC)
 {
-    int day = dateToDayInYear(t.year + 1900, t.month, t.monthDay);
+    double day = dateToDaysFrom1970(t.year + 1900, t.month, t.monthDay);
     double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds);
     double result = (day * WTF::msPerDay) + ms;
 
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index ef3246f..cf6c553 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2009-12-11  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Fix a problem that JSC::gregorianDateTimeToMS() returns a negative
+        value for a huge year value.
+        https://bugs.webkit.org/show_bug.cgi?id=32304
+
+        * fast/js/date-daysfrom1970-overflow-expected.txt: Added.
+        * fast/js/date-daysfrom1970-overflow.html: Added.
+        * fast/js/script-tests/date-daysfrom1970-overflow.js: Added.
+
 2009-12-11  Benjamin Poulain  <benjamin.poulain at nokia.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/js/date-daysfrom1970-overflow-expected.txt b/LayoutTests/fast/js/date-daysfrom1970-overflow-expected.txt
new file mode 100644
index 0000000..4af2a64
--- /dev/null
+++ b/LayoutTests/fast/js/date-daysfrom1970-overflow-expected.txt
@@ -0,0 +1,12 @@
+This test confirms an assertion in dateToDaysFrom1970() in wtf/DateMath.cpp passes. The function had a bug setting a number larger than INT_MAX to an int variable.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS d.getTime() is NaN
+PASS Date.UTC(1970, 0, 1, 0, 0, 0, 0) is 0
+PASS d.getTime() is NaN
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/js/date-daysfrom1970-overflow.html b/LayoutTests/fast/js/date-daysfrom1970-overflow.html
new file mode 100644
index 0000000..ed78643
--- /dev/null
+++ b/LayoutTests/fast/js/date-daysfrom1970-overflow.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/js-test-style.css">
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/date-daysfrom1970-overflow.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/js/script-tests/date-daysfrom1970-overflow.js b/LayoutTests/fast/js/script-tests/date-daysfrom1970-overflow.js
new file mode 100644
index 0000000..7f110de
--- /dev/null
+++ b/LayoutTests/fast/js/script-tests/date-daysfrom1970-overflow.js
@@ -0,0 +1,11 @@
+description('This test confirms an assertion in dateToDaysFrom1970() in wtf/DateMath.cpp passes. The function had a bug setting a number larger than INT_MAX to an int variable.');
+
+var d = new Date(20000000, 0, 1);
+shouldBe('d.getTime()', 'NaN');
+
+shouldBe('Date.UTC(1970, 0, 1, 0, 0, 0, 0)', '0');
+
+d = new Date(-20000000, 0, 1);
+shouldBe('d.getTime()', 'NaN');
+
+var successfullyParsed = true;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list