[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

tkent at chromium.org tkent at chromium.org
Wed Dec 22 12:46:53 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit cff83f5ca613a2c2ebb5c9f4a1de2b213d3b7310
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Aug 30 04:47:24 2010 +0000

    Change lower and higher limits of date/datetime/datetime-local/month/week types
    https://bugs.webkit.org/show_bug.cgi?id=39737
    
    Reviewed by Darin Adler.
    
    WebCore:
    
    According to the latest draft of HTML5, ISO-8601 dates in HTML5
    should support A.D.0001 in Gregorian calendar though Gregorian
    calendar started in 1582. So, we change the lower limits of
    date&time types to 0001-01-01T00:00.
    
    We also introduce the common higher limit, 275760-09-13T00:00. It
    is the higher limit of Date type of ECMAScript.
    
    * html/DateComponents.cpp:
    (WebCore::DateComponents::parseYear):
     Rejects years less than A.D.1 and years greater than 275760.
    (WebCore::withinHTMLDateLimits):
     Helper functions to check lower and higher limits.
    (WebCore::DateComponents::addDay):
     - Remove an overflow check. 'year' can't be so large number because
       parseYear() rejects such numbers.
     - Add withinHTMLDateLimits() calls.
    (WebCore::DateComponents::addMinute):
     - Add an assertion for the base date.
     - Add withinHTMLDateLimits() calls.
    (WebCore::DateComponents::parseMonth):
     Add withinHTMLDateLimits() call.
    (WebCore::DateComponents::parseDate): ditto.
    (WebCore::DateComponents::parseWeek): ditto.
    (WebCore::DateComponents::parseDateTimeLocal): ditto.
    (WebCore::DateComponents::parseDateTime): ditto.
    (WebCore::DateComponents::setMillisecondsSinceEpochForDate): ditto.
    (WebCore::DateComponents::setMillisecondsSinceEpochForDateTime): ditto.
    (WebCore::DateComponents::setMillisecondsSinceEpochForMonth): ditto.
    (WebCore::DateComponents::setMonthsSinceEpoch):
     Add year range check and withinHTMLDateLimits() call.
    (WebCore::DateComponents::setMillisecondsSinceEpochForWeek):
     Add year range check and week range check.
    * html/DateComponents.h:
     Update minimum/maximum constant values.
    (WebCore::DateComponents::minimumDate):
    (WebCore::DateComponents::minimumDateTime):
    (WebCore::DateComponents::minimumMonth):
    (WebCore::DateComponents::minimumWeek):
    (WebCore::DateComponents::maximumDate):
    (WebCore::DateComponents::maximumDateTime):
    (WebCore::DateComponents::maximumMonth):
    (WebCore::DateComponents::maximumWeek):
    
    LayoutTests:
    
    Update tests and test results for the new DateComponents behavior.
    
    * fast/forms/ValidityState-rangeOverflow-expected.txt:
    * fast/forms/ValidityState-stepMismatch-expected.txt:
    * fast/forms/ValidityState-typeMismatch-date-expected.txt:
    * fast/forms/ValidityState-typeMismatch-datetime-expected.txt:
    * fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt:
    * fast/forms/ValidityState-typeMismatch-month-expected.txt:
    * fast/forms/ValidityState-typeMismatch-week-expected.txt:
    * fast/forms/input-valueasdate-date-expected.txt:
    * fast/forms/input-valueasdate-datetime-expected.txt:
    * fast/forms/input-valueasdate-month-expected.txt:
    * fast/forms/input-valueasdate-week-expected.txt:
    * fast/forms/input-valueasnumber-date-expected.txt:
    * fast/forms/input-valueasnumber-datetime-expected.txt:
    * fast/forms/input-valueasnumber-datetimelocal-expected.txt:
    * fast/forms/input-valueasnumber-month-expected.txt:
    * fast/forms/input-valueasnumber-week-expected.txt:
    * fast/forms/script-tests/ValidityState-rangeOverflow.js:
    * fast/forms/script-tests/ValidityState-stepMismatch.js:
    * fast/forms/script-tests/ValidityState-typeMismatch-date.js:
    * fast/forms/script-tests/ValidityState-typeMismatch-datetime.js:
    * fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js:
    * fast/forms/script-tests/ValidityState-typeMismatch-month.js:
    * fast/forms/script-tests/ValidityState-typeMismatch-week.js:
    * fast/forms/script-tests/input-valueasdate-date.js:
    * fast/forms/script-tests/input-valueasdate-datetime.js:
    * fast/forms/script-tests/input-valueasdate-month.js:
    * fast/forms/script-tests/input-valueasdate-week.js:
    * fast/forms/script-tests/input-valueasnumber-date.js:
    * fast/forms/script-tests/input-valueasnumber-datetime.js:
    * fast/forms/script-tests/input-valueasnumber-datetimelocal.js:
    * fast/forms/script-tests/input-valueasnumber-month.js:
    * fast/forms/script-tests/input-valueasnumber-week.js:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66355 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 3de857a..a02acf9 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,45 @@
+2010-08-29  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Change lower and higher limits of date/datetime/datetime-local/month/week types
+        https://bugs.webkit.org/show_bug.cgi?id=39737
+
+        Update tests and test results for the new DateComponents behavior.
+
+        * fast/forms/ValidityState-rangeOverflow-expected.txt:
+        * fast/forms/ValidityState-stepMismatch-expected.txt:
+        * fast/forms/ValidityState-typeMismatch-date-expected.txt:
+        * fast/forms/ValidityState-typeMismatch-datetime-expected.txt:
+        * fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt:
+        * fast/forms/ValidityState-typeMismatch-month-expected.txt:
+        * fast/forms/ValidityState-typeMismatch-week-expected.txt:
+        * fast/forms/input-valueasdate-date-expected.txt:
+        * fast/forms/input-valueasdate-datetime-expected.txt:
+        * fast/forms/input-valueasdate-month-expected.txt:
+        * fast/forms/input-valueasdate-week-expected.txt:
+        * fast/forms/input-valueasnumber-date-expected.txt:
+        * fast/forms/input-valueasnumber-datetime-expected.txt:
+        * fast/forms/input-valueasnumber-datetimelocal-expected.txt:
+        * fast/forms/input-valueasnumber-month-expected.txt:
+        * fast/forms/input-valueasnumber-week-expected.txt:
+        * fast/forms/script-tests/ValidityState-rangeOverflow.js:
+        * fast/forms/script-tests/ValidityState-stepMismatch.js:
+        * fast/forms/script-tests/ValidityState-typeMismatch-date.js:
+        * fast/forms/script-tests/ValidityState-typeMismatch-datetime.js:
+        * fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js:
+        * fast/forms/script-tests/ValidityState-typeMismatch-month.js:
+        * fast/forms/script-tests/ValidityState-typeMismatch-week.js:
+        * fast/forms/script-tests/input-valueasdate-date.js:
+        * fast/forms/script-tests/input-valueasdate-datetime.js:
+        * fast/forms/script-tests/input-valueasdate-month.js:
+        * fast/forms/script-tests/input-valueasdate-week.js:
+        * fast/forms/script-tests/input-valueasnumber-date.js:
+        * fast/forms/script-tests/input-valueasnumber-datetime.js:
+        * fast/forms/script-tests/input-valueasnumber-datetimelocal.js:
+        * fast/forms/script-tests/input-valueasnumber-month.js:
+        * fast/forms/script-tests/input-valueasnumber-week.js:
+
 2010-08-29  Yuzo Fujishima  <yuzo at google.com>
 
         Unreviewed Chromium test expectation change for r66296.
diff --git a/LayoutTests/fast/forms/ValidityState-rangeOverflow-expected.txt b/LayoutTests/fast/forms/ValidityState-rangeOverflow-expected.txt
index ee45bd0..b77aa59 100644
--- a/LayoutTests/fast/forms/ValidityState-rangeOverflow-expected.txt
+++ b/LayoutTests/fast/forms/ValidityState-rangeOverflow-expected.txt
@@ -14,7 +14,7 @@ PASS The value "2010-01-27" doesn't overflow the maximum value "2010-01-27".
 PASS The value "2010-01-27" doesn't overflow the maximum value "2010-01-28".
 PASS The value "2010-01-27" doesn't overflow the maximum value "2011-01-26".
 PASS The value "foo" doesn't overflow the maximum value "2011-01-26".
-PASS The value "2010-01-27" doesn't overflow the maximum value "1000-01-01".
+PASS The value "2010-01-27" doesn't overflow the maximum value "0000-01-01".
 PASS The value "2010-01-27" overflows the maximum value "2010-01-26".
 PASS The value "9999-01-01" overflows the maximum value "2010-12-31".
 PASS The value "2010-01-27" overflows the maximum value "2010-01-26".
@@ -27,7 +27,7 @@ PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "2010-01-2
 PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "2010-01-27T12:34:56Z".
 PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "2011-01-26T12:34Z".
 PASS The value "foo" doesn't overflow the maximum value "2011-01-26T12:34Z".
-PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "1000-01-01T00:00Z".
+PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "0000-01-01T00:00Z".
 PASS The value "2010-01-27T12:34Z" overflows the maximum value "2010-01-26T12:33:59.999Z".
 PASS The value "9999-01-01T23:59Z" overflows the maximum value "2010-12-31T00:00Z".
 PASS The value "2010-01-27T12:34Z" overflows the maximum value "2010-01-26T12:34Z".
@@ -40,7 +40,7 @@ PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "2010-01-27
 PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "2010-01-27T12:34:56".
 PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "2011-01-26T12:34".
 PASS The value "foo" doesn't overflow the maximum value "2011-01-26T12:34".
-PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "1000-01-01T00:00".
+PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "0000-01-01T00:00".
 PASS The value "2010-01-27T12:34" overflows the maximum value "2010-01-26T12:33:59.999".
 PASS The value "9999-01-01T23:59" overflows the maximum value "2010-12-31T00:00".
 PASS The value "2010-01-27T12:34" overflows the maximum value "2010-01-26T12:34".
@@ -53,7 +53,7 @@ PASS The value "2010-01" doesn't overflow the maximum value "2010-01".
 PASS The value "2010-01" doesn't overflow the maximum value "2010-02".
 PASS The value "2010-01" doesn't overflow the maximum value "2011-01".
 PASS The value "foo" doesn't overflow the maximum value "2011-01".
-PASS The value "2010-01" doesn't overflow the maximum value "1000-01".
+PASS The value "2010-01" doesn't overflow the maximum value "0000-01".
 PASS The value "2010-01" overflows the maximum value "2009-12".
 PASS The value "9999-01" overflows the maximum value "2010-12".
 PASS The value "2010-01" overflows the maximum value "2009-12".
@@ -93,7 +93,8 @@ PASS The value "2010-W01" doesn't overflow the maximum value "2010-W01".
 PASS The value "2010-W01" doesn't overflow the maximum value "2010-W02".
 PASS The value "2010-W01" doesn't overflow the maximum value "2011-W01".
 PASS The value "foo" doesn't overflow the maximum value "2011-W01".
-PASS The value "2010-W01" doesn't overflow the maximum value "1582-W01".
+PASS The value "2010-W01" doesn't overflow the maximum value "0000-W01".
+PASS The value "2010-W01" overflows the maximum value "1582-W01".
 PASS The value "2010-W01" overflows the maximum value "2009-W12".
 PASS The value "9999-W01" overflows the maximum value "2010-W12".
 PASS The value "2010-W01" overflows the maximum value "2009-W50".
diff --git a/LayoutTests/fast/forms/ValidityState-stepMismatch-expected.txt b/LayoutTests/fast/forms/ValidityState-stepMismatch-expected.txt
index 522c50e..7b76075 100644
--- a/LayoutTests/fast/forms/ValidityState-stepMismatch-expected.txt
+++ b/LayoutTests/fast/forms/ValidityState-stepMismatch-expected.txt
@@ -42,8 +42,10 @@ PASS stepMismatchFor("2010-02-09T12:34:55Z", "0.333", "2010-02-09T12:34:56Z") is
 PASS stepMismatchFor("2010-02-09T12:34:55.001Z", "0.333", "2010-02-09T12:34:56Z") is false
 PASS stepMismatchFor("2010-02-09T12:34Z", "86400", "2010-02-08T12:34Z") is false
 PASS stepMismatchFor("2010-02-09T12:34:56Z", "86400", "2010-02-08T12:34Z") is true
-PASS stepMismatchFor("275760-09-13T00:00Z", "3", "275760-09-13T23:50:50Z") is true
-PASS stepMismatchFor("275760-09-13T00:00Z", "2", "275760-09-13T23:50:50Z") is false
+PASS stepMismatchFor("275760-09-13T00:00Z", "3", "275760-09-12T23:59:50Z") is true
+PASS stepMismatchFor("275760-09-13T00:00Z", "2", "275760-09-12T23:59:50Z") is false
+PASS stepMismatchFor("0001-01-01T00:00Z", "3", "0001-01-11T00:00:02Z") is true
+PASS stepMismatchFor("0001-01-01T00:00Z", "2", "0001-01-11T00:00:02Z") is false
 Implicit step base
 PASS stepMismatchFor("1970-01-01T12:34Z", "120", null) is false
 PASS stepMismatchFor("1970-01-01T12:35Z", "120", null) is true
@@ -70,8 +72,10 @@ PASS stepMismatchFor("2010-02-09T12:34:55", "0.333", "2010-02-09T12:34:56") is t
 PASS stepMismatchFor("2010-02-09T12:34:55.001", "0.333", "2010-02-09T12:34:56") is false
 PASS stepMismatchFor("2010-02-09T12:34", "86400", "2010-02-08T12:34") is false
 PASS stepMismatchFor("2010-02-09T12:34:56", "86400", "2010-02-08T12:34") is true
-PASS stepMismatchFor("275760-09-13T00:00", "3", "275760-09-13T23:50:50") is true
-PASS stepMismatchFor("275760-09-13T00:00", "2", "275760-09-13T23:50:50") is false
+PASS stepMismatchFor("275760-09-13T00:00", "3", "275760-09-12T23:59:50") is true
+PASS stepMismatchFor("275760-09-13T00:00", "2", "275760-09-12T23:59:50") is false
+PASS stepMismatchFor("0001-01-01T00:00", "3", "0001-01-11T00:00:02") is true
+PASS stepMismatchFor("0001-01-01T00:00", "2", "0001-01-11T00:00:02") is false
 Implicit step base
 PASS stepMismatchFor("1970-01-01T12:34", "120", null) is false
 PASS stepMismatchFor("1970-01-01T12:35", "120", null) is true
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-date-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-date-expected.txt
index 0aa2c1e..46febff 100644
--- a/LayoutTests/fast/forms/ValidityState-typeMismatch-date-expected.txt
+++ b/LayoutTests/fast/forms/ValidityState-typeMismatch-date-expected.txt
@@ -6,8 +6,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS "" is a correct valid date string.
 PASS "2009-09-07" is a correct valid date string.
 PASS "9999-12-31" is a correct valid date string.
-PASS "2147483647-12-31" is a correct valid date string.
+PASS "275760-09-13" is a correct valid date string.
 PASS "1582-10-15" is a correct valid date string.
+PASS "0001-01-01" is a correct valid date string.
 PASS "2009-01-31" is a correct valid date string.
 PASS "2009-02-28" is a correct valid date string.
 PASS "2009-03-31" is a correct valid date string.
@@ -25,15 +26,15 @@ PASS "2000-02-29" is a correct valid date string.
 PASS " 2009-09-07 " is a correct invalid date string.
 PASS "a" is a correct invalid date string.
 PASS "-1-09-07" is a correct invalid date string.
-PASS "1581-09-07" is a correct invalid date string.
-PASS "1582-10-14" is a correct invalid date string.
+PASS "0000-12-31" is a correct invalid date string.
+PASS "0000-01-01" is a correct invalid date string.
+PASS "275760-09-14" is a correct invalid date string.
 PASS "2147483648-12-31" is a correct invalid date string.
 PASS "2009/09/07" is a correct invalid date string.
 PASS "20090907" is a correct invalid date string.
 PASS "2009--2-07" is a correct invalid date string.
 PASS "2009-00-07" is a correct invalid date string.
 PASS "2009-13-07" is a correct invalid date string.
-PASS "1582-09-30" is a correct invalid date string.
 PASS "2009-xx-30" is a correct invalid date string.
 PASS "2009-01-32" is a correct invalid date string.
 PASS "2009-02-29" is a correct invalid date string.
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-datetime-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-datetime-expected.txt
index 9c57ce1..67a4866 100644
--- a/LayoutTests/fast/forms/ValidityState-typeMismatch-datetime-expected.txt
+++ b/LayoutTests/fast/forms/ValidityState-typeMismatch-datetime-expected.txt
@@ -10,11 +10,12 @@ PASS "2009-09-07T16:49:31.1Z" is a correct valid datetime string.
 PASS "2009-09-07T16:49:31.12Z" is a correct valid datetime string.
 PASS "2009-09-07T16:49:31.123Z" is a correct valid datetime string.
 PASS "2009-09-07T16:49:31.1234567890Z" is a correct valid datetime string.
-PASS "2147483647-12-31T23:59:59.999Z" is a correct valid datetime string.
-PASS "1582-10-15T00:00:00.000Z" is a correct valid datetime string.
-PASS "1582-10-15T00:00:00.000+00:00" is a correct valid datetime string.
-PASS "1582-10-15T01:30+01:30" is a correct valid datetime string.
-PASS "1582-10-15T00:00+01:00" is a correct valid datetime string.
+PASS "275760-09-12T23:59:59.999Z" is a correct valid datetime string.
+PASS "275760-09-13T00:00:00.000Z" is a correct valid datetime string.
+PASS "0001-01-01T00:00:00.000Z" is a correct valid datetime string.
+PASS "0001-01-01T00:00:00.000+00:00" is a correct valid datetime string.
+PASS "0001-01-01T01:30+01:30" is a correct valid datetime string.
+PASS "0001-01-01T00:00+01:00" is a correct valid datetime string.
 PASS " 2009-09-07T16:49Z " is a correct invalid datetime string.
 PASS "2009-09-07T16:49z" is a correct invalid datetime string.
 PASS "2009-09-07t16:49Z" is a correct invalid datetime string.
@@ -30,7 +31,7 @@ PASS "2009-09-07T16:49-23" is a correct invalid datetime string.
 PASS "2009-09-07T16:49-23:" is a correct invalid datetime string.
 PASS "2009-09-07T16:49-24:00" is a correct invalid datetime string.
 PASS "2009-09-07T16:49-23:60" is a correct invalid datetime string.
-PASS "1582-10-14T23:59:59Z" is a correct invalid datetime string.
+PASS "0000-12-31T23:59:59Z" is a correct invalid datetime string.
 PASS "2147483647-12-31T23:59-00:01" is a correct invalid datetime string.
 PASS "2147483648-01-01T00:00:00Z" is a correct invalid datetime string.
 PASS successfullyParsed is true
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt
index 9897d06..5472469 100644
--- a/LayoutTests/fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt
+++ b/LayoutTests/fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt
@@ -10,16 +10,16 @@ PASS "2009-09-07T16:49:31.1" is a correct valid datetime-local string.
 PASS "2009-09-07T16:49:31.12" is a correct valid datetime-local string.
 PASS "2009-09-07T16:49:31.123" is a correct valid datetime-local string.
 PASS "2009-09-07T16:49:31.1234567890" is a correct valid datetime-local string.
-PASS "2147483647-12-31T23:59:59.999" is a correct valid datetime-local string.
-PASS "1582-10-15T00:00:00.000" is a correct valid datetime-local string.
+PASS "275760-09-13T00:00:00.000" is a correct valid datetime-local string.
+PASS "0001-01-01T00:00:00.000" is a correct valid datetime-local string.
 PASS " 2009-09-07T16:49 " is a correct invalid datetime-local string.
 PASS "2009-09-07t16:49" is a correct invalid datetime-local string.
 PASS "2009-09-07 16:49" is a correct invalid datetime-local string.
 PASS "2009/09/07T16:49" is a correct invalid datetime-local string.
 PASS "a" is a correct invalid datetime-local string.
 PASS "-1-09-07T16:49" is a correct invalid datetime-local string.
-PASS "1582-10-14T23:59:59" is a correct invalid datetime-local string.
-PASS "2147483648-01-01T00:00:00" is a correct invalid datetime-local string.
+PASS "0000-12-31T23:59:59.999" is a correct invalid datetime-local string.
+PASS "275760-09-13T00:00:00.001" is a correct invalid datetime-local string.
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-month-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-month-expected.txt
index 4ab8e4f..2f01b93 100644
--- a/LayoutTests/fast/forms/ValidityState-typeMismatch-month-expected.txt
+++ b/LayoutTests/fast/forms/ValidityState-typeMismatch-month-expected.txt
@@ -4,9 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 PASS "" is a correct valid month string.
-PASS "1582-10" is a correct valid month string.
+PASS "0001-01" is a correct valid month string.
 PASS "9999-12" is a correct valid month string.
-PASS "2147483647-12" is a correct valid month string.
+PASS "275760-09" is a correct valid month string.
 PASS "2009-01" is a correct valid month string.
 PASS "2009-02" is a correct valid month string.
 PASS "2009-03" is a correct valid month string.
@@ -22,9 +22,9 @@ PASS "2009-12" is a correct valid month string.
 PASS " 2009-09 " is a correct invalid month string.
 PASS "a" is a correct invalid month string.
 PASS "-1-09" is a correct invalid month string.
-PASS "1581-10" is a correct invalid month string.
-PASS "1582-09" is a correct invalid month string.
+PASS "0000-12" is a correct invalid month string.
 PASS "2147483648-12" is a correct invalid month string.
+PASS "275760-10" is a correct invalid month string.
 PASS "2009/09" is a correct invalid month string.
 PASS "200909" is a correct invalid month string.
 PASS "2009--2" is a correct invalid month string.
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-week-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-week-expected.txt
index df9a26b..2ff27dc 100644
--- a/LayoutTests/fast/forms/ValidityState-typeMismatch-week-expected.txt
+++ b/LayoutTests/fast/forms/ValidityState-typeMismatch-week-expected.txt
@@ -4,9 +4,10 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 PASS "" is a correct valid week string.
+PASS "0001-W01" is a correct valid week string.
 PASS "1583-W01" is a correct valid week string.
 PASS "9999-W52" is a correct valid week string.
-PASS "2147483647-W52" is a correct valid week string.
+PASS "275760-W37" is a correct valid week string.
 PASS "2009-W01" is a correct valid week string.
 PASS "2004-W53" is a correct valid week string.
 PASS "2003-W52" is a correct valid week string.
@@ -18,8 +19,9 @@ PASS "2009-W1" is a correct invalid week string.
 PASS "2009-W001" is a correct invalid week string.
 PASS "a" is a correct invalid week string.
 PASS "-1-W09" is a correct invalid week string.
-PASS "1582-W52" is a correct invalid week string.
+PASS "0000-W52" is a correct invalid week string.
 PASS "2147483648-W01" is a correct invalid week string.
+PASS "275760-W38" is a correct invalid week string.
 PASS "2009-W00" is a correct invalid week string.
 PASS "2009-W-1" is a correct invalid week string.
 PASS "2004-W54" is a correct invalid week string.
diff --git a/LayoutTests/fast/forms/input-valueasdate-date-expected.txt b/LayoutTests/fast/forms/input-valueasdate-date-expected.txt
index 74e4b73..6951bd3 100644
--- a/LayoutTests/fast/forms/input-valueasdate-date-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasdate-date-expected.txt
@@ -11,8 +11,9 @@ PASS setValueAsDateAndGetValue(1969, 11, 1) is "1969-12-01"
 PASS setValueAsDateAndGetValue(1970, 0, 1) is "1970-01-01"
 PASS setValueAsDateAndGetValue(2009, 11, 31) is "2009-12-31"
 PASS setValueAsDateAndGetValue(10000, 0, 1) is "10000-01-01"
-PASS setValueAsDateAndGetValue(794, 9, 22) is ""
-PASS setValueAsDateAndGetValue(1582, 8, 30) is ""
+PASS setValueAsDateAndGetValue(-1, 0, 1) is ""
+PASS setValueAsDateAndGetValue(0, 11, 31) is ""
+PASS setValueAsDateAndGetValue(1, 0, 1) is "0001-01-01"
 PASS setValueAsDateAndGetValue(1582, 9, 15) is "1582-10-15"
 PASS setValueAsDateAndGetValue(1582, 9, 31) is "1582-10-31"
 PASS setValueAsDateAndGetValue(275760, 8, 13) is "275760-09-13"
diff --git a/LayoutTests/fast/forms/input-valueasdate-datetime-expected.txt b/LayoutTests/fast/forms/input-valueasdate-datetime-expected.txt
index 033412c..8381992 100644
--- a/LayoutTests/fast/forms/input-valueasdate-datetime-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasdate-datetime-expected.txt
@@ -11,9 +11,9 @@ PASS setValueAsDateAndGetValue(1969, 11, 1, 0, 0, 0, 0) is "1969-12-01T00:00Z"
 PASS setValueAsDateAndGetValue(1970, 0, 1, 10, 1, 0, 100) is "1970-01-01T10:01:00.100Z"
 PASS setValueAsDateAndGetValue(2009, 11, 31, 23, 59, 59, 999) is "2009-12-31T23:59:59.999Z"
 PASS setValueAsDateAndGetValue(10000, 0, 1, 12, 0, 1, 0) is "10000-01-01T12:00:01Z"
-PASS setValueAsDateAndGetValue(794, 9, 22, 0, 0, 0, 0) is ""
-PASS setValueAsDateAndGetValue(1582, 9, 14, 23, 59, 59, 999) is ""
-PASS setValueAsDateAndGetValue(1582, 9, 15, 0, 0, 0, 0) is "1582-10-15T00:00Z"
+PASS setValueAsDateAndGetValue(-1, 9, 22, 0, 0, 0, 0) is ""
+PASS setValueAsDateAndGetValue(0, 11, 31, 23, 59, 59, 999) is ""
+PASS setValueAsDateAndGetValue(1, 0, 1, 0, 0, 0, 0) is "0001-01-01T00:00Z"
 PASS setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 0) is "275760-09-13T00:00Z"
 PASS setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 1) is ""
 Invalid objects:
diff --git a/LayoutTests/fast/forms/input-valueasdate-month-expected.txt b/LayoutTests/fast/forms/input-valueasdate-month-expected.txt
index ac5ef74..f426ecc 100644
--- a/LayoutTests/fast/forms/input-valueasdate-month-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasdate-month-expected.txt
@@ -11,10 +11,10 @@ PASS setValueAsDateAndGetValue(1969, 11, 1) is "1969-12"
 PASS setValueAsDateAndGetValue(1970, 0, 1) is "1970-01"
 PASS setValueAsDateAndGetValue(2009, 11, 31) is "2009-12"
 PASS setValueAsDateAndGetValue(10000, 0, 1) is "10000-01"
-PASS setValueAsDateAndGetValue(794, 9, 22) is ""
-PASS setValueAsDateAndGetValue(1582, 8, 30) is ""
-PASS setValueAsDateAndGetValue(1582, 9, 1) is "1582-10"
-PASS setValueAsDateAndGetValue(1582, 9, 31) is "1582-10"
+PASS setValueAsDateAndGetValue(-1, 9, 22) is ""
+PASS setValueAsDateAndGetValue(0, 11, 30) is ""
+PASS setValueAsDateAndGetValue(0001, 0, 1) is "0001-01"
+PASS setValueAsDateAndGetValue(0001, 0, 31) is "0001-01"
 PASS setValueAsDateAndGetValue(275760, 8, 13) is "275760-09"
 PASS setValueAsDateAndGetValue(275760, 8, 14) is ""
 Sets null to valueAsDate:
diff --git a/LayoutTests/fast/forms/input-valueasdate-week-expected.txt b/LayoutTests/fast/forms/input-valueasdate-week-expected.txt
index 21e7028..2dab9af 100644
--- a/LayoutTests/fast/forms/input-valueasdate-week-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasdate-week-expected.txt
@@ -12,6 +12,7 @@ PASS valueAsDateFor("2010-W01").getTime() is Date.UTC(2010, 0, 4)
 PASS valueAsDateFor("2005-W01").getTime() is Date.UTC(2005, 0, 3)
 PASS valueAsDateFor("2006-W01").getTime() is Date.UTC(2006, 0, 2)
 Various January 1st:
+PASS setValueAsDateAndGetValue(1, 0, 1) is "0001-W01"
 PASS setValueAsDateAndGetValue(2007, 0, 1) is "2007-W01"
 PASS setValueAsDateAndGetValue(2008, 0, 1) is "2008-W01"
 PASS setValueAsDateAndGetValue(2003, 0, 1) is "2003-W01"
@@ -26,13 +27,9 @@ PASS setValueAsDateAndGetValue(2010, 0, 10) is "2010-W01"
 PASS setValueAsDateAndGetValue(2010, 0, 11) is "2010-W02"
 PASS setValueAsDateAndGetValue(2010, 0, 17) is "2010-W02"
 PASS setValueAsDateAndGetValue(2010, 11, 31) is "2010-W52"
-Around Gregorian calendar starting year:
-PASS setValueAsDateAndGetValue(1582, 9, 14) is ""
-PASS setValueAsDateAndGetValue(1582, 9, 15) is ""
-PASS setValueAsDateAndGetValue(1582, 11, 31) is ""
-PASS setValueAsDateAndGetValue(1583, 0, 1) is ""
-PASS setValueAsDateAndGetValue(1583, 0, 2) is ""
-PASS setValueAsDateAndGetValue(1583, 0, 3) is "1583-W01"
+Around the minimum value:
+PASS setValueAsDateAndGetValue(0, 11, 31) is ""
+PASS setValueAsDateAndGetValue(0, 0, 1) is ""
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/forms/input-valueasnumber-date-expected.txt b/LayoutTests/fast/forms/input-valueasnumber-date-expected.txt
index b6aef9b..6983a97 100644
--- a/LayoutTests/fast/forms/input-valueasnumber-date-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasnumber-date-expected.txt
@@ -11,10 +11,9 @@ PASS setValueAsNumberAndGetValue(1969, 11, 1) is "1969-12-01"
 PASS setValueAsNumberAndGetValue(1970, 0, 1) is "1970-01-01"
 PASS setValueAsNumberAndGetValue(2009, 11, 31) is "2009-12-31"
 PASS setValueAsNumberAndGetValue(10000, 0, 1) is "10000-01-01"
-PASS setValueAsNumberAndGetValue(794, 9, 22) is ""
-PASS setValueAsNumberAndGetValue(1582, 8, 30) is ""
-PASS setValueAsNumberAndGetValue(1582, 9, 15) is "1582-10-15"
-PASS setValueAsNumberAndGetValue(1582, 9, 31) is "1582-10-31"
+PASS setValueAsNumberAndGetValue(-1, 0, 1) is ""
+PASS setValueAsNumberAndGetValue(0, 11, 31) is ""
+PASS setValueAsNumberAndGetValue(1, 0, 1) is "0001-01-01"
 PASS setValueAsNumberAndGetValue(275760, 8, 13) is "275760-09-13"
 Tests to set invalid values to valueAsNumber:
 PASS input.value = ""; input.valueAsNumber = null; input.value is "1970-01-01"
@@ -24,6 +23,7 @@ PASS input.valueAsNumber = Number.NaN threw exception Error: NOT_SUPPORTED_ERR:
 PASS input.valueAsNumber = Infinity threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS input.valueAsNumber = Number.POSITIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS input.valueAsNumber = Number.NEGATIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
+PASS input.valueAsNumber = Date.UTC(275760, 8, 14) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/forms/input-valueasnumber-datetime-expected.txt b/LayoutTests/fast/forms/input-valueasnumber-datetime-expected.txt
index 81e4b1f..f1d88fd 100644
--- a/LayoutTests/fast/forms/input-valueasnumber-datetime-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasnumber-datetime-expected.txt
@@ -11,9 +11,9 @@ PASS setValueAsNumberAndGetValue(1969, 11, 1, 0, 0, 0, 0) is "1969-12-01T00:00Z"
 PASS setValueAsNumberAndGetValue(1970, 0, 1, 10, 1, 0, 100) is "1970-01-01T10:01:00.100Z"
 PASS setValueAsNumberAndGetValue(2009, 11, 31, 23, 59, 59, 999) is "2009-12-31T23:59:59.999Z"
 PASS setValueAsNumberAndGetValue(10000, 0, 1, 12, 0, 1, 0) is "10000-01-01T12:00:01Z"
-PASS setValueAsNumberAndGetValue(794, 9, 22, 0, 0, 0, 0) is ""
-PASS setValueAsNumberAndGetValue(1582, 9, 14, 23, 59, 59, 999) is ""
-PASS setValueAsNumberAndGetValue(1582, 9, 15, 0, 0, 0, 0) is "1582-10-15T00:00Z"
+PASS setValueAsNumberAndGetValue(-1, 0, 1, 0, 0, 0, 0) is ""
+PASS setValueAsNumberAndGetValue(0, 11, 31, 23, 59, 59, 999) is ""
+PASS setValueAsNumberAndGetValue(1, 0, 1, 0, 0, 0, 0) is "0001-01-01T00:00Z"
 PASS setValueAsNumberAndGetValue(275760, 8, 12, 0, 0, 0, 1) is "275760-09-12T00:00:00.001Z"
 PASS setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 0) is "275760-09-13T00:00Z"
 Tests to set invalid values to valueAsNumber:
@@ -24,6 +24,7 @@ PASS input.valueAsNumber = Number.NaN threw exception Error: NOT_SUPPORTED_ERR:
 PASS input.valueAsNumber = Infinity threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS input.valueAsNumber = Number.POSITIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS input.valueAsNumber = Number.NEGATIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
+PASS input.valueAsNumber = Date.UTC(275760, 8, 13, 0, 0, 0, 1) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 Step attribute value and string representation:
 PASS input.step = "1"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00:00Z"
 PASS input.step = "0.001"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00:00.000Z"
diff --git a/LayoutTests/fast/forms/input-valueasnumber-datetimelocal-expected.txt b/LayoutTests/fast/forms/input-valueasnumber-datetimelocal-expected.txt
index c154d49..3a88734 100644
--- a/LayoutTests/fast/forms/input-valueasnumber-datetimelocal-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasnumber-datetimelocal-expected.txt
@@ -11,9 +11,10 @@ PASS setValueAsNumberAndGetValue(1969, 11, 1, 0, 0, 0, 0) is "1969-12-01T00:00"
 PASS setValueAsNumberAndGetValue(1970, 0, 1, 10, 1, 0, 100) is "1970-01-01T10:01:00.100"
 PASS setValueAsNumberAndGetValue(2009, 11, 31, 23, 59, 59, 999) is "2009-12-31T23:59:59.999"
 PASS setValueAsNumberAndGetValue(10000, 0, 1, 12, 0, 1, 0) is "10000-01-01T12:00:01"
-PASS setValueAsNumberAndGetValue(794, 9, 22, 0, 0, 0, 0) is ""
-PASS setValueAsNumberAndGetValue(1582, 9, 14, 23, 59, 59, 999) is ""
-PASS setValueAsNumberAndGetValue(1582, 9, 15, 0, 0, 0, 0) is "1582-10-15T00:00"
+PASS setValueAsNumberAndGetValue(-1, 0, 1, 0, 0, 0, 0) is ""
+PASS setValueAsNumberAndGetValue(0, 11, 31, 23, 59, 59, 999) is ""
+PASS setValueAsNumberAndGetValue(1, 0, 1, 0, 0, 0, 0) is "0001-01-01T00:00"
+PASS setValueAsNumberAndGetValue(275760, 8, 12, 0, 0, 0, 1) is "275760-09-12T00:00:00.001"
 PASS setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 0) is "275760-09-13T00:00"
 Tests to set invalid values to valueAsNumber:
 PASS input.value = ""; input.valueAsNumber = null; input.value is "1970-01-01T00:00"
@@ -23,6 +24,7 @@ PASS input.valueAsNumber = Number.NaN threw exception Error: NOT_SUPPORTED_ERR:
 PASS input.valueAsNumber = Infinity threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS input.valueAsNumber = Number.POSITIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS input.valueAsNumber = Number.NEGATIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
+PASS input.valueAsNumber = Date.UTC(275760, 8, 13, 0, 0, 0, 1) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 Step attribute value and string representation:
 PASS input.step = "1"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00:00"
 PASS input.step = "0.001"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00:00.000"
diff --git a/LayoutTests/fast/forms/input-valueasnumber-month-expected.txt b/LayoutTests/fast/forms/input-valueasnumber-month-expected.txt
index 5abf265..d5f3f00 100644
--- a/LayoutTests/fast/forms/input-valueasnumber-month-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasnumber-month-expected.txt
@@ -14,12 +14,12 @@ PASS input.valueAsNumber = -1; input.value is "1969-12"
 PASS input.valueAsNumber = 0; input.value is "1970-01"
 PASS setValueAsNumberAndGetValue(2009, 12) is "2009-12"
 PASS setValueAsNumberAndGetValue(10000, 1) is "10000-01"
-PASS setValueAsNumberAndGetValue(794, 9) is ""
-PASS setValueAsNumberAndGetValue(1582, 9) is ""
-PASS setValueAsNumberAndGetValue(1582, 10) is "1582-10"
-PASS setValueAsNumberAndGetValue(1582, 11) is "1582-11"
+PASS setValueAsNumberAndGetValue(-1, 1) is ""
+PASS setValueAsNumberAndGetValue(0, 12) is ""
+PASS setValueAsNumberAndGetValue(1, 1) is "0001-01"
+PASS setValueAsNumberAndGetValue(1, 2) is "0001-02"
 PASS setValueAsNumberAndGetValue(275760, 9) is "275760-09"
-PASS setValueAsNumberAndGetValue(2147483647, 12) is "2147483647-12"
+PASS setValueAsNumberAndGetValue(275760, 10) is ""
 Tests to set invalid values to valueAsNumber:
 PASS input.value = ""; input.valueAsNumber = null; input.value is "1970-01"
 PASS input.valueAsNumber = "foo" threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
diff --git a/LayoutTests/fast/forms/input-valueasnumber-week-expected.txt b/LayoutTests/fast/forms/input-valueasnumber-week-expected.txt
index f8078d6..77afbfe 100644
--- a/LayoutTests/fast/forms/input-valueasnumber-week-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasnumber-week-expected.txt
@@ -26,13 +26,11 @@ PASS setValueAsNumberAndGetValue(2010, 0, 10) is "2010-W01"
 PASS setValueAsNumberAndGetValue(2010, 0, 11) is "2010-W02"
 PASS setValueAsNumberAndGetValue(2010, 0, 17) is "2010-W02"
 PASS setValueAsNumberAndGetValue(2010, 11, 31) is "2010-W52"
-Around Gregorian calendar starting year:
-PASS setValueAsNumberAndGetValue(1582, 9, 14) is ""
-PASS setValueAsNumberAndGetValue(1582, 9, 15) is ""
-PASS setValueAsNumberAndGetValue(1582, 11, 31) is ""
-PASS setValueAsNumberAndGetValue(1583, 0, 1) is ""
-PASS setValueAsNumberAndGetValue(1583, 0, 2) is ""
-PASS setValueAsNumberAndGetValue(1583, 0, 3) is "1583-W01"
+Around the minimum/maximum values:
+PASS setValueAsNumberAndGetValue(0, 11, 31) is ""
+PASS setValueAsNumberAndGetValue(1, 0, 1) is "0001-W01"
+PASS setValueAsNumberAndGetValue(275760, 8, 8) is "275760-W37"
+PASS setValueAsNumberAndGetValue(275760, 8, 13) is "275760-W37"
 Tests to set invalid values to valueAsNumber:
 PASS input.value = ""; input.valueAsNumber = null; input.value is "1970-W01"
 PASS input.valueAsNumber = "foo" threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
@@ -41,6 +39,7 @@ PASS input.valueAsNumber = Number.NaN threw exception Error: NOT_SUPPORTED_ERR:
 PASS input.valueAsNumber = Infinity threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS input.valueAsNumber = Number.POSITIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS input.valueAsNumber = Number.NEGATIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
+PASS input.valueAsNumber = Date.UTC(275760, 8, 14) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-rangeOverflow.js b/LayoutTests/fast/forms/script-tests/ValidityState-rangeOverflow.js
index 6bcaa70..a059d02 100644
--- a/LayoutTests/fast/forms/script-tests/ValidityState-rangeOverflow.js
+++ b/LayoutTests/fast/forms/script-tests/ValidityState-rangeOverflow.js
@@ -48,7 +48,7 @@ checkNotOverflow('2010-01-27', '2010-01-27');
 checkNotOverflow('2010-01-27', '2010-01-28');
 checkNotOverflow('2010-01-27', '2011-01-26');
 checkNotOverflow('foo', '2011-01-26');
-checkNotOverflow('2010-01-27', '1000-01-01'); // Too small max value.
+checkNotOverflow('2010-01-27', '0000-01-01'); // Too small max value.
 
 // Overflow cases
 checkOverflow('2010-01-27', '2010-01-26');
@@ -69,7 +69,7 @@ checkNotOverflow('2010-01-27T12:34Z', '2010-01-27T12:34Z');
 checkNotOverflow('2010-01-27T12:34Z', '2010-01-27T12:34:56Z');
 checkNotOverflow('2010-01-27T12:34Z', '2011-01-26T12:34Z');
 checkNotOverflow('foo', '2011-01-26T12:34Z');
-checkNotOverflow('2010-01-27T12:34Z', '1000-01-01T00:00Z'); // Too small max value.
+checkNotOverflow('2010-01-27T12:34Z', '0000-01-01T00:00Z'); // Too small max value.
 
 // Overflow cases
 checkOverflow('2010-01-27T12:34Z', '2010-01-26T12:33:59.999Z');
@@ -90,7 +90,7 @@ checkNotOverflow('2010-01-27T12:34', '2010-01-27T12:34');
 checkNotOverflow('2010-01-27T12:34', '2010-01-27T12:34:56');
 checkNotOverflow('2010-01-27T12:34', '2011-01-26T12:34');
 checkNotOverflow('foo', '2011-01-26T12:34');
-checkNotOverflow('2010-01-27T12:34', '1000-01-01T00:00'); // Too small max value.
+checkNotOverflow('2010-01-27T12:34', '0000-01-01T00:00'); // Too small max value.
 
 // Overflow cases
 checkOverflow('2010-01-27T12:34', '2010-01-26T12:33:59.999');
@@ -111,7 +111,7 @@ checkNotOverflow('2010-01', '2010-01');
 checkNotOverflow('2010-01', '2010-02');
 checkNotOverflow('2010-01', '2011-01');
 checkNotOverflow('foo', '2011-01');
-checkNotOverflow('2010-01', '1000-01'); // Too small max value.
+checkNotOverflow('2010-01', '0000-01'); // Too small max value.
 
 // Overflow cases
 checkOverflow('2010-01', '2009-12');
@@ -175,9 +175,10 @@ checkNotOverflow('2010-W01', '2010-W01');
 checkNotOverflow('2010-W01', '2010-W02');
 checkNotOverflow('2010-W01', '2011-W01');
 checkNotOverflow('foo', '2011-W01');
-checkNotOverflow('2010-W01', '1582-W01'); // Too small max value.
+checkNotOverflow('2010-W01', '0000-W01'); // Invalid max value.
 
 // Overflow cases
+checkOverflow('2010-W01', '1582-W01');
 checkOverflow('2010-W01', '2009-W12');
 checkOverflow('9999-W01', '2010-W12');
 input.min = '2010-W02';  // value < min && value > max
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-stepMismatch.js b/LayoutTests/fast/forms/script-tests/ValidityState-stepMismatch.js
index e86d3b5..61faec9 100644
--- a/LayoutTests/fast/forms/script-tests/ValidityState-stepMismatch.js
+++ b/LayoutTests/fast/forms/script-tests/ValidityState-stepMismatch.js
@@ -52,8 +52,10 @@ shouldBeTrue('stepMismatchFor("2010-02-09T12:34:55Z", "0.333", "2010-02-09T12:34
 shouldBeFalse('stepMismatchFor("2010-02-09T12:34:55.001Z", "0.333", "2010-02-09T12:34:56Z")');
 shouldBeFalse('stepMismatchFor("2010-02-09T12:34Z", "86400", "2010-02-08T12:34Z")');
 shouldBeTrue('stepMismatchFor("2010-02-09T12:34:56Z", "86400", "2010-02-08T12:34Z")');
-shouldBeTrue('stepMismatchFor("275760-09-13T00:00Z", "3", "275760-09-13T23:50:50Z")');
-shouldBeFalse('stepMismatchFor("275760-09-13T00:00Z", "2", "275760-09-13T23:50:50Z")');
+shouldBeTrue('stepMismatchFor("275760-09-13T00:00Z", "3", "275760-09-12T23:59:50Z")');
+shouldBeFalse('stepMismatchFor("275760-09-13T00:00Z", "2", "275760-09-12T23:59:50Z")');
+shouldBeTrue('stepMismatchFor("0001-01-01T00:00Z", "3", "0001-01-11T00:00:02Z")');
+shouldBeFalse('stepMismatchFor("0001-01-01T00:00Z", "2", "0001-01-11T00:00:02Z")');
 debug('Implicit step base');
 shouldBeFalse('stepMismatchFor("1970-01-01T12:34Z", "120", null)');
 shouldBeTrue('stepMismatchFor("1970-01-01T12:35Z", "120", null)');
@@ -82,8 +84,10 @@ shouldBeTrue('stepMismatchFor("2010-02-09T12:34:55", "0.333", "2010-02-09T12:34:
 shouldBeFalse('stepMismatchFor("2010-02-09T12:34:55.001", "0.333", "2010-02-09T12:34:56")');
 shouldBeFalse('stepMismatchFor("2010-02-09T12:34", "86400", "2010-02-08T12:34")');
 shouldBeTrue('stepMismatchFor("2010-02-09T12:34:56", "86400", "2010-02-08T12:34")');
-shouldBeTrue('stepMismatchFor("275760-09-13T00:00", "3", "275760-09-13T23:50:50")');
-shouldBeFalse('stepMismatchFor("275760-09-13T00:00", "2", "275760-09-13T23:50:50")');
+shouldBeTrue('stepMismatchFor("275760-09-13T00:00", "3", "275760-09-12T23:59:50")');
+shouldBeFalse('stepMismatchFor("275760-09-13T00:00", "2", "275760-09-12T23:59:50")');
+shouldBeTrue('stepMismatchFor("0001-01-01T00:00", "3", "0001-01-11T00:00:02")');
+shouldBeFalse('stepMismatchFor("0001-01-01T00:00", "2", "0001-01-11T00:00:02")');
 debug('Implicit step base');
 shouldBeFalse('stepMismatchFor("1970-01-01T12:34", "120", null)');
 shouldBeTrue('stepMismatchFor("1970-01-01T12:35", "120", null)');
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-date.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-date.js
index 4972800..c416473 100644
--- a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-date.js
+++ b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-date.js
@@ -28,8 +28,9 @@ function shouldBeInvalid(value)
 shouldBeValid('');
 shouldBeValid('2009-09-07');
 shouldBeValid('9999-12-31');
-shouldBeValid('2147483647-12-31');
+shouldBeValid('275760-09-13');
 shouldBeValid('1582-10-15');
+shouldBeValid('0001-01-01');
 shouldBeValid('2009-01-31');
 shouldBeValid('2009-02-28');
 shouldBeValid('2009-03-31');
@@ -49,15 +50,15 @@ shouldBeValid('2000-02-29');
 shouldBeInvalid(' 2009-09-07 ');
 shouldBeInvalid('a');
 shouldBeInvalid('-1-09-07');
-shouldBeInvalid('1581-09-07');
-shouldBeInvalid('1582-10-14');
+shouldBeInvalid('0000-12-31');
+shouldBeInvalid('0000-01-01');
+shouldBeInvalid('275760-09-14');
 shouldBeInvalid('2147483648-12-31');
 shouldBeInvalid('2009/09/07');
 shouldBeInvalid('20090907');
 shouldBeInvalid('2009--2-07');
 shouldBeInvalid('2009-00-07');
 shouldBeInvalid('2009-13-07');
-shouldBeInvalid('1582-09-30');
 shouldBeInvalid('2009-xx-30');
 shouldBeInvalid('2009-01-32');
 shouldBeInvalid('2009-02-29');
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetime.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetime.js
index e8f5ddd..70b088b 100644
--- a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetime.js
+++ b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetime.js
@@ -32,11 +32,12 @@ shouldBeValid('2009-09-07T16:49:31.1Z');
 shouldBeValid('2009-09-07T16:49:31.12Z');
 shouldBeValid('2009-09-07T16:49:31.123Z');
 shouldBeValid('2009-09-07T16:49:31.1234567890Z');
-shouldBeValid('2147483647-12-31T23:59:59.999Z');
-shouldBeValid('1582-10-15T00:00:00.000Z');
-shouldBeValid('1582-10-15T00:00:00.000+00:00');
-shouldBeValid('1582-10-15T01:30+01:30');
-shouldBeValid('1582-10-15T00:00+01:00');
+shouldBeValid('275760-09-12T23:59:59.999Z');
+shouldBeValid('275760-09-13T00:00:00.000Z');
+shouldBeValid('0001-01-01T00:00:00.000Z');
+shouldBeValid('0001-01-01T00:00:00.000+00:00');
+shouldBeValid('0001-01-01T01:30+01:30');
+shouldBeValid('0001-01-01T00:00+01:00');
 
 // Invalid values
 shouldBeInvalid(' 2009-09-07T16:49Z ');
@@ -54,7 +55,7 @@ shouldBeInvalid('2009-09-07T16:49-23');
 shouldBeInvalid('2009-09-07T16:49-23:');
 shouldBeInvalid('2009-09-07T16:49-24:00');
 shouldBeInvalid('2009-09-07T16:49-23:60');
-shouldBeInvalid('1582-10-14T23:59:59Z');
+shouldBeInvalid('0000-12-31T23:59:59Z');
 shouldBeInvalid('2147483647-12-31T23:59-00:01');
 shouldBeInvalid('2147483648-01-01T00:00:00Z');
 
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js
index c406e12..70b6014 100644
--- a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js
+++ b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js
@@ -32,8 +32,8 @@ shouldBeValid('2009-09-07T16:49:31.1');
 shouldBeValid('2009-09-07T16:49:31.12');
 shouldBeValid('2009-09-07T16:49:31.123');
 shouldBeValid('2009-09-07T16:49:31.1234567890');
-shouldBeValid('2147483647-12-31T23:59:59.999');
-shouldBeValid('1582-10-15T00:00:00.000');
+shouldBeValid('275760-09-13T00:00:00.000');
+shouldBeValid('0001-01-01T00:00:00.000');
 
 // Invalid values
 shouldBeInvalid(' 2009-09-07T16:49 ');
@@ -42,7 +42,7 @@ shouldBeInvalid('2009-09-07 16:49');
 shouldBeInvalid('2009/09/07T16:49');
 shouldBeInvalid('a');
 shouldBeInvalid('-1-09-07T16:49');
-shouldBeInvalid('1582-10-14T23:59:59');
-shouldBeInvalid('2147483648-01-01T00:00:00');
+shouldBeInvalid('0000-12-31T23:59:59.999');
+shouldBeInvalid('275760-09-13T00:00:00.001');
 
 var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-month.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-month.js
index 1276204..3a3826a 100644
--- a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-month.js
+++ b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-month.js
@@ -26,9 +26,9 @@ function shouldBeInvalid(value)
 
 // Valid values
 shouldBeValid('');
-shouldBeValid('1582-10');
+shouldBeValid('0001-01');
 shouldBeValid('9999-12');
-shouldBeValid('2147483647-12');
+shouldBeValid('275760-09');
 shouldBeValid('2009-01');
 shouldBeValid('2009-02');
 shouldBeValid('2009-03');
@@ -46,9 +46,9 @@ shouldBeValid('2009-12');
 shouldBeInvalid(' 2009-09 ');
 shouldBeInvalid('a');
 shouldBeInvalid('-1-09');
-shouldBeInvalid('1581-10');
-shouldBeInvalid('1582-09');
+shouldBeInvalid('0000-12');
 shouldBeInvalid('2147483648-12');
+shouldBeInvalid('275760-10');
 shouldBeInvalid('2009/09');
 shouldBeInvalid('200909');
 shouldBeInvalid('2009--2');
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-week.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-week.js
index 6b1d9dd..4fe0086 100644
--- a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-week.js
+++ b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-week.js
@@ -26,9 +26,10 @@ function shouldBeInvalid(value)
 
 // Valid values
 shouldBeValid('');
+shouldBeValid('0001-W01');
 shouldBeValid('1583-W01');
 shouldBeValid('9999-W52');
-shouldBeValid('2147483647-W52');
+shouldBeValid('275760-W37');
 shouldBeValid('2009-W01');
 shouldBeValid('2004-W53');  // 2004 started on Thursday.
 shouldBeValid('2003-W52');  // 2003 started on Wednesday, but wasn't a leap year.
@@ -42,8 +43,9 @@ shouldBeInvalid('2009-W1');
 shouldBeInvalid('2009-W001');
 shouldBeInvalid('a');
 shouldBeInvalid('-1-W09');
-shouldBeInvalid('1582-W52');
+shouldBeInvalid('0000-W52');
 shouldBeInvalid('2147483648-W01');
+shouldBeInvalid('275760-W38');
 shouldBeInvalid('2009-W00');
 shouldBeInvalid('2009-W-1');
 shouldBeInvalid('2004-W54');  // 2004 started on Thursday.
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasdate-date.js b/LayoutTests/fast/forms/script-tests/input-valueasdate-date.js
index 895d8c0..93aa705 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasdate-date.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasdate-date.js
@@ -11,6 +11,8 @@ function valueAsDateFor(stringValue) {
 function setValueAsDateAndGetValue(year, month, day) {
     var date = new Date();
     date.setTime(Date.UTC(year, month, day));
+    if (year < 100)
+        date.setUTCFullYear(year);
     input.valueAsDate = date;
     return input.value;
 }
@@ -25,8 +27,9 @@ shouldBe('setValueAsDateAndGetValue(1970, 0, 1)', '"1970-01-01"');
 shouldBe('setValueAsDateAndGetValue(2009, 11, 31)', '"2009-12-31"');
 shouldBe('setValueAsDateAndGetValue(10000, 0, 1)', '"10000-01-01"');
 
-shouldBe('setValueAsDateAndGetValue(794, 9, 22)', '""');
-shouldBe('setValueAsDateAndGetValue(1582, 8, 30)', '""');
+shouldBe('setValueAsDateAndGetValue(-1, 0, 1)', '""');
+shouldBe('setValueAsDateAndGetValue(0, 11, 31)', '""');
+shouldBe('setValueAsDateAndGetValue(1, 0, 1)', '"0001-01-01"');
 shouldBe('setValueAsDateAndGetValue(1582, 9, 15)', '"1582-10-15"');
 shouldBe('setValueAsDateAndGetValue(1582, 9, 31)', '"1582-10-31"');
 shouldBe('setValueAsDateAndGetValue(275760, 8, 13)', '"275760-09-13"');
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasdate-datetime.js b/LayoutTests/fast/forms/script-tests/input-valueasdate-datetime.js
index 2771f85..86d75be 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasdate-datetime.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasdate-datetime.js
@@ -11,6 +11,8 @@ function valueAsDateFor(stringValue) {
 function setValueAsDateAndGetValue(year, month, day, hour, minute, second, msec) {
     var date = new Date();
     date.setTime(Date.UTC(year, month, day, hour, minute, second, msec));
+    if (year < 100)
+        date.setUTCFullYear(year);
     input.valueAsDate = date;
     return input.value;
 }
@@ -25,9 +27,9 @@ shouldBe('setValueAsDateAndGetValue(1970, 0, 1, 10, 1, 0, 100)', '"1970-01-01T10
 shouldBe('setValueAsDateAndGetValue(2009, 11, 31, 23, 59, 59, 999)', '"2009-12-31T23:59:59.999Z"');
 shouldBe('setValueAsDateAndGetValue(10000, 0, 1, 12, 0, 1, 0)', '"10000-01-01T12:00:01Z"');
 
-shouldBe('setValueAsDateAndGetValue(794, 9, 22, 0, 0, 0, 0)', '""');
-shouldBe('setValueAsDateAndGetValue(1582, 9, 14, 23, 59, 59, 999)', '""');
-shouldBe('setValueAsDateAndGetValue(1582, 9, 15, 0, 0, 0, 0)', '"1582-10-15T00:00Z"');
+shouldBe('setValueAsDateAndGetValue(-1, 9, 22, 0, 0, 0, 0)', '""');
+shouldBe('setValueAsDateAndGetValue(0, 11, 31, 23, 59, 59, 999)', '""');
+shouldBe('setValueAsDateAndGetValue(1, 0, 1, 0, 0, 0, 0)', '"0001-01-01T00:00Z"');
 shouldBe('setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 0)', '"275760-09-13T00:00Z"');
 shouldBe('setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 1)', '""'); // Date of JavaScript can't represent this.
 
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasdate-month.js b/LayoutTests/fast/forms/script-tests/input-valueasdate-month.js
index b34d69d..e34b1c2 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasdate-month.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasdate-month.js
@@ -11,6 +11,8 @@ function valueAsDateFor(stringValue) {
 function setValueAsDateAndGetValue(year, month, day) {
     var date = new Date();
     date.setTime(Date.UTC(year, month, day));
+    if (year < 100)
+        date.setUTCFullYear(year);
     input.valueAsDate = date;
     return input.value;
 }
@@ -25,10 +27,10 @@ shouldBe('setValueAsDateAndGetValue(1970, 0, 1)', '"1970-01"');
 shouldBe('setValueAsDateAndGetValue(2009, 11, 31)', '"2009-12"');
 shouldBe('setValueAsDateAndGetValue(10000, 0, 1)', '"10000-01"');
 
-shouldBe('setValueAsDateAndGetValue(794, 9, 22)', '""');
-shouldBe('setValueAsDateAndGetValue(1582, 8, 30)', '""');
-shouldBe('setValueAsDateAndGetValue(1582, 9, 1)', '"1582-10"');
-shouldBe('setValueAsDateAndGetValue(1582, 9, 31)', '"1582-10"');
+shouldBe('setValueAsDateAndGetValue(-1, 9, 22)', '""');
+shouldBe('setValueAsDateAndGetValue(0, 11, 30)', '""');
+shouldBe('setValueAsDateAndGetValue(0001, 0, 1)', '"0001-01"');
+shouldBe('setValueAsDateAndGetValue(0001, 0, 31)', '"0001-01"');
 shouldBe('setValueAsDateAndGetValue(275760, 8, 13)', '"275760-09"');
 shouldBe('setValueAsDateAndGetValue(275760, 8, 14)', '""'); // Date of JavaScript can't represent this.
 
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasdate-week.js b/LayoutTests/fast/forms/script-tests/input-valueasdate-week.js
index fd9b6ca..557eba8 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasdate-week.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasdate-week.js
@@ -11,6 +11,8 @@ function valueAsDateFor(stringValue) {
 function setValueAsDateAndGetValue(year, month, day) {
     var date = new Date();
     date.setTime(Date.UTC(year, month, day));
+    if (year < 100)
+        date.setUTCFullYear(year);
     input.valueAsDate = date;
     return input.value;
 }
@@ -32,6 +34,7 @@ shouldBe('valueAsDateFor("2005-W01").getTime()', 'Date.UTC(2005, 0, 3)');
 shouldBe('valueAsDateFor("2006-W01").getTime()', 'Date.UTC(2006, 0, 2)');
 
 debug('Various January 1st:');
+shouldBe('setValueAsDateAndGetValue(1, 0, 1)', '"0001-W01"');
 shouldBe('setValueAsDateAndGetValue(2007, 0, 1)', '"2007-W01"');
 shouldBe('setValueAsDateAndGetValue(2008, 0, 1)', '"2008-W01"');
 shouldBe('setValueAsDateAndGetValue(2003, 0, 1)', '"2003-W01"');
@@ -48,14 +51,9 @@ shouldBe('setValueAsDateAndGetValue(2010, 0, 11)', '"2010-W02"');
 shouldBe('setValueAsDateAndGetValue(2010, 0, 17)', '"2010-W02"');
 shouldBe('setValueAsDateAndGetValue(2010, 11, 31)', '"2010-W52"');
 
-debug('Around Gregorian calendar starting year:');
+debug('Around the minimum value:');
 // Gregorian calendar started in 1582. We don't support that year.
-shouldBe('setValueAsDateAndGetValue(1582, 9, 14)', '""');
-shouldBe('setValueAsDateAndGetValue(1582, 9, 15)', '""');
-shouldBe('setValueAsDateAndGetValue(1582, 11, 31)', '""');
-// January 1st is Saturday. W01 starts on January 3rd.
-shouldBe('setValueAsDateAndGetValue(1583, 0, 1)', '""');
-shouldBe('setValueAsDateAndGetValue(1583, 0, 2)', '""');
-shouldBe('setValueAsDateAndGetValue(1583, 0, 3)', '"1583-W01"');
+shouldBe('setValueAsDateAndGetValue(0, 11, 31)', '""');
+shouldBe('setValueAsDateAndGetValue(0, 0, 1)', '""');
 
 var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasnumber-date.js b/LayoutTests/fast/forms/script-tests/input-valueasnumber-date.js
index e5cdd7a..ef60a83 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasnumber-date.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasnumber-date.js
@@ -9,7 +9,11 @@ function valueAsNumberFor(stringValue) {
 }
 
 function setValueAsNumberAndGetValue(year, month, day) {
-    input.valueAsNumber = Date.UTC(year, month, day);
+    var date = new Date();
+    date.setTime(Date.UTC(year, month, day));
+    if (year < 100)
+        date.setUTCFullYear(year);
+    input.valueAsNumber = date.getTime();
     return input.value;
 }
 
@@ -23,13 +27,10 @@ shouldBe('setValueAsNumberAndGetValue(1970, 0, 1)', '"1970-01-01"');
 shouldBe('setValueAsNumberAndGetValue(2009, 11, 31)', '"2009-12-31"');
 shouldBe('setValueAsNumberAndGetValue(10000, 0, 1)', '"10000-01-01"');
 
-shouldBe('setValueAsNumberAndGetValue(794, 9, 22)', '""');
-shouldBe('setValueAsNumberAndGetValue(1582, 8, 30)', '""');
-shouldBe('setValueAsNumberAndGetValue(1582, 9, 15)', '"1582-10-15"');
-shouldBe('setValueAsNumberAndGetValue(1582, 9, 31)', '"1582-10-31"');
+shouldBe('setValueAsNumberAndGetValue(-1, 0, 1)', '""');
+shouldBe('setValueAsNumberAndGetValue(0, 11, 31)', '""');
+shouldBe('setValueAsNumberAndGetValue(1, 0, 1)', '"0001-01-01"');
 shouldBe('setValueAsNumberAndGetValue(275760, 8, 13)', '"275760-09-13"');
-// Date.UTC() of V8 throws an exception for the following value though JavaScriptCore doesn't.
-// shouldBe('setValueAsNumberAndGetValue(275760, 8, 14)', '"275760-09-14"');
 
 debug('Tests to set invalid values to valueAsNumber:');
 shouldBe('input.value = ""; input.valueAsNumber = null; input.value', '"1970-01-01"');
@@ -39,5 +40,6 @@ shouldThrow('input.valueAsNumber = Number.NaN', '"Error: NOT_SUPPORTED_ERR: DOM
 shouldThrow('input.valueAsNumber = Infinity', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 shouldThrow('input.valueAsNumber = Number.POSITIVE_INFINITY', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 shouldThrow('input.valueAsNumber = Number.NEGATIVE_INFINITY', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
+shouldThrow('input.valueAsNumber = Date.UTC(275760, 8, 14)', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 
 var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetime.js b/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetime.js
index 0b94a88..2c8bdc0 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetime.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetime.js
@@ -9,7 +9,11 @@ function valueAsNumberFor(stringValue) {
 }
 
 function setValueAsNumberAndGetValue(year, month, day, hour, minute, second, msec) {
-    input.valueAsNumber = Date.UTC(year, month, day, hour, minute, second, msec);
+    var date = new Date();
+    date.setTime(Date.UTC(year, month, day, hour, minute, second, msec));
+    if (year < 100)
+        date.setUTCFullYear(year);
+    input.valueAsNumber = date.getTime();
     return input.value;
 }
 
@@ -23,13 +27,11 @@ shouldBe('setValueAsNumberAndGetValue(1970, 0, 1, 10, 1, 0, 100)', '"1970-01-01T
 shouldBe('setValueAsNumberAndGetValue(2009, 11, 31, 23, 59, 59, 999)', '"2009-12-31T23:59:59.999Z"');
 shouldBe('setValueAsNumberAndGetValue(10000, 0, 1, 12, 0, 1, 0)', '"10000-01-01T12:00:01Z"');
 
-shouldBe('setValueAsNumberAndGetValue(794, 9, 22, 0, 0, 0, 0)', '""');
-shouldBe('setValueAsNumberAndGetValue(1582, 9, 14, 23, 59, 59, 999)', '""');
-shouldBe('setValueAsNumberAndGetValue(1582, 9, 15, 0, 0, 0, 0)', '"1582-10-15T00:00Z"');
+shouldBe('setValueAsNumberAndGetValue(-1, 0, 1, 0, 0, 0, 0)', '""');
+shouldBe('setValueAsNumberAndGetValue(0, 11, 31, 23, 59, 59, 999)', '""');
+shouldBe('setValueAsNumberAndGetValue(1, 0, 1, 0, 0, 0, 0)', '"0001-01-01T00:00Z"');
 shouldBe('setValueAsNumberAndGetValue(275760, 8, 12, 0, 0, 0, 1)', '"275760-09-12T00:00:00.001Z"');
 shouldBe('setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 0)', '"275760-09-13T00:00Z"');
-// Date.UTC() of V8 throws an exception for the following value though JavaScriptCore doesn't.
-// shouldBe('setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 1)', '"275760-09-13T00:00:00.001Z"');
 
 debug('Tests to set invalid values to valueAsNumber:');
 shouldBe('input.value = ""; input.valueAsNumber = null; input.value', '"1970-01-01T00:00Z"');
@@ -39,6 +41,7 @@ shouldThrow('input.valueAsNumber = Number.NaN', '"Error: NOT_SUPPORTED_ERR: DOM
 shouldThrow('input.valueAsNumber = Infinity', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 shouldThrow('input.valueAsNumber = Number.POSITIVE_INFINITY', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 shouldThrow('input.valueAsNumber = Number.NEGATIVE_INFINITY', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
+shouldThrow('input.valueAsNumber = Date.UTC(275760, 8, 13, 0, 0, 0, 1)', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 
 debug('Step attribute value and string representation:');
 // If the step attribute value is 1 second and the second part is 0, we should show the second part.
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetimelocal.js b/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetimelocal.js
index 2a947ac..d9953e4 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetimelocal.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetimelocal.js
@@ -9,7 +9,11 @@ function valueAsNumberFor(stringValue) {
 }
 
 function setValueAsNumberAndGetValue(year, month, day, hour, minute, second, msec) {
-    input.valueAsNumber = Date.UTC(year, month, day, hour, minute, second, msec);
+    var date = new Date();
+    date.setTime(Date.UTC(year, month, day, hour, minute, second, msec));
+    if (year < 100)
+        date.setUTCFullYear(year);
+    input.valueAsNumber = date.getTime();
     return input.value;
 }
 
@@ -23,12 +27,11 @@ shouldBe('setValueAsNumberAndGetValue(1970, 0, 1, 10, 1, 0, 100)', '"1970-01-01T
 shouldBe('setValueAsNumberAndGetValue(2009, 11, 31, 23, 59, 59, 999)', '"2009-12-31T23:59:59.999"');
 shouldBe('setValueAsNumberAndGetValue(10000, 0, 1, 12, 0, 1, 0)', '"10000-01-01T12:00:01"');
 
-shouldBe('setValueAsNumberAndGetValue(794, 9, 22, 0, 0, 0, 0)', '""');
-shouldBe('setValueAsNumberAndGetValue(1582, 9, 14, 23, 59, 59, 999)', '""');
-shouldBe('setValueAsNumberAndGetValue(1582, 9, 15, 0, 0, 0, 0)', '"1582-10-15T00:00"');
+shouldBe('setValueAsNumberAndGetValue(-1, 0, 1, 0, 0, 0, 0)', '""');
+shouldBe('setValueAsNumberAndGetValue(0, 11, 31, 23, 59, 59, 999)', '""');
+shouldBe('setValueAsNumberAndGetValue(1, 0, 1, 0, 0, 0, 0)', '"0001-01-01T00:00"');
+shouldBe('setValueAsNumberAndGetValue(275760, 8, 12, 0, 0, 0, 1)', '"275760-09-12T00:00:00.001"');
 shouldBe('setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 0)', '"275760-09-13T00:00"');
-// Date.UTC() of V8 throws an exception for the following value though JavaScriptCore doesn't.
-// shouldBe('setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 1)', '"275760-09-13T00:00:00.001"');
 
 debug('Tests to set invalid values to valueAsNumber:');
 shouldBe('input.value = ""; input.valueAsNumber = null; input.value', '"1970-01-01T00:00"');
@@ -38,6 +41,7 @@ shouldThrow('input.valueAsNumber = Number.NaN', '"Error: NOT_SUPPORTED_ERR: DOM
 shouldThrow('input.valueAsNumber = Infinity', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 shouldThrow('input.valueAsNumber = Number.POSITIVE_INFINITY', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 shouldThrow('input.valueAsNumber = Number.NEGATIVE_INFINITY', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
+shouldThrow('input.valueAsNumber = Date.UTC(275760, 8, 13, 0, 0, 0, 1)', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 
 debug('Step attribute value and string representation:');
 // If the step attribute value is 1 second and the second part is 0, we should show the second part.
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasnumber-month.js b/LayoutTests/fast/forms/script-tests/input-valueasnumber-month.js
index cc7e5af..bebdb9a 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasnumber-month.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasnumber-month.js
@@ -26,12 +26,12 @@ shouldBe('input.valueAsNumber = 0; input.value', '"1970-01"');
 shouldBe('setValueAsNumberAndGetValue(2009, 12)', '"2009-12"');
 shouldBe('setValueAsNumberAndGetValue(10000, 1)', '"10000-01"');
 
-shouldBe('setValueAsNumberAndGetValue(794, 9)', '""');
-shouldBe('setValueAsNumberAndGetValue(1582, 9)', '""');
-shouldBe('setValueAsNumberAndGetValue(1582, 10)', '"1582-10"');
-shouldBe('setValueAsNumberAndGetValue(1582, 11)', '"1582-11"');
+shouldBe('setValueAsNumberAndGetValue(-1, 1)', '""');
+shouldBe('setValueAsNumberAndGetValue(0, 12)', '""');
+shouldBe('setValueAsNumberAndGetValue(1, 1)', '"0001-01"');
+shouldBe('setValueAsNumberAndGetValue(1, 2)', '"0001-02"');
 shouldBe('setValueAsNumberAndGetValue(275760, 9)', '"275760-09"');
-shouldBe('setValueAsNumberAndGetValue(2147483647, 12)', '"2147483647-12"');
+shouldBe('setValueAsNumberAndGetValue(275760, 10)', '""');
 
 // Date.UTC() of V8 throws an exception for the following value though JavaScriptCore doesn't.
 // shouldBe('setValueAsNumberAndGetValue(275760, 8, 14)', '"275760-09"');
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasnumber-week.js b/LayoutTests/fast/forms/script-tests/input-valueasnumber-week.js
index 00b788b..e50b18c 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasnumber-week.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasnumber-week.js
@@ -9,7 +9,11 @@ function valueAsNumberFor(stringValue) {
 }
 
 function setValueAsNumberAndGetValue(year, month, day) {
-    input.valueAsNumber = Date.UTC(year, month, day);
+    var date = new Date();
+    date.setTime(Date.UTC(year, month, day));
+    if (year < 100)
+        date.setUTCFullYear(year);
+    input.valueAsNumber = date.getTime();
     return input.value;
 }
 
@@ -46,15 +50,11 @@ shouldBe('setValueAsNumberAndGetValue(2010, 0, 11)', '"2010-W02"');
 shouldBe('setValueAsNumberAndGetValue(2010, 0, 17)', '"2010-W02"');
 shouldBe('setValueAsNumberAndGetValue(2010, 11, 31)', '"2010-W52"');
 
-debug('Around Gregorian calendar starting year:');
-// Gregorian calendar started in 1582. We don't support that year.
-shouldBe('setValueAsNumberAndGetValue(1582, 9, 14)', '""');
-shouldBe('setValueAsNumberAndGetValue(1582, 9, 15)', '""');
-shouldBe('setValueAsNumberAndGetValue(1582, 11, 31)', '""');
-// January 1st is Saturday. W01 starts on January 3rd.
-shouldBe('setValueAsNumberAndGetValue(1583, 0, 1)', '""');
-shouldBe('setValueAsNumberAndGetValue(1583, 0, 2)', '""');
-shouldBe('setValueAsNumberAndGetValue(1583, 0, 3)', '"1583-W01"');
+debug('Around the minimum/maximum values:');
+shouldBe('setValueAsNumberAndGetValue(0, 11, 31)', '""');
+shouldBe('setValueAsNumberAndGetValue(1, 0, 1)', '"0001-W01"');
+shouldBe('setValueAsNumberAndGetValue(275760, 8, 8)', '"275760-W37"');
+shouldBe('setValueAsNumberAndGetValue(275760, 8, 13)', '"275760-W37"');
 
 debug('Tests to set invalid values to valueAsNumber:');
 shouldBe('input.value = ""; input.valueAsNumber = null; input.value', '"1970-W01"');
@@ -64,5 +64,6 @@ shouldThrow('input.valueAsNumber = Number.NaN', '"Error: NOT_SUPPORTED_ERR: DOM
 shouldThrow('input.valueAsNumber = Infinity', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 shouldThrow('input.valueAsNumber = Number.POSITIVE_INFINITY', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 shouldThrow('input.valueAsNumber = Number.NEGATIVE_INFINITY', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
+shouldThrow('input.valueAsNumber = Date.UTC(275760, 8, 14)', '"Error: NOT_SUPPORTED_ERR: DOM Exception 9"');
 
 var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7b74442..ffff17b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,54 @@
+2010-08-29  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Change lower and higher limits of date/datetime/datetime-local/month/week types
+        https://bugs.webkit.org/show_bug.cgi?id=39737
+
+        According to the latest draft of HTML5, ISO-8601 dates in HTML5
+        should support A.D.0001 in Gregorian calendar though Gregorian
+        calendar started in 1582. So, we change the lower limits of
+        date&time types to 0001-01-01T00:00.
+
+        We also introduce the common higher limit, 275760-09-13T00:00. It
+        is the higher limit of Date type of ECMAScript.
+
+        * html/DateComponents.cpp:
+        (WebCore::DateComponents::parseYear):
+         Rejects years less than A.D.1 and years greater than 275760.
+        (WebCore::withinHTMLDateLimits):
+         Helper functions to check lower and higher limits.
+        (WebCore::DateComponents::addDay):
+         - Remove an overflow check. 'year' can't be so large number because
+           parseYear() rejects such numbers.
+         - Add withinHTMLDateLimits() calls.
+        (WebCore::DateComponents::addMinute):
+         - Add an assertion for the base date.
+         - Add withinHTMLDateLimits() calls.
+        (WebCore::DateComponents::parseMonth):
+         Add withinHTMLDateLimits() call.
+        (WebCore::DateComponents::parseDate): ditto.
+        (WebCore::DateComponents::parseWeek): ditto.
+        (WebCore::DateComponents::parseDateTimeLocal): ditto.
+        (WebCore::DateComponents::parseDateTime): ditto.
+        (WebCore::DateComponents::setMillisecondsSinceEpochForDate): ditto.
+        (WebCore::DateComponents::setMillisecondsSinceEpochForDateTime): ditto.
+        (WebCore::DateComponents::setMillisecondsSinceEpochForMonth): ditto.
+        (WebCore::DateComponents::setMonthsSinceEpoch):
+         Add year range check and withinHTMLDateLimits() call.
+        (WebCore::DateComponents::setMillisecondsSinceEpochForWeek):
+         Add year range check and week range check.
+        * html/DateComponents.h:
+         Update minimum/maximum constant values.
+        (WebCore::DateComponents::minimumDate):
+        (WebCore::DateComponents::minimumDateTime):
+        (WebCore::DateComponents::minimumMonth):
+        (WebCore::DateComponents::minimumWeek):
+        (WebCore::DateComponents::maximumDate):
+        (WebCore::DateComponents::maximumDateTime):
+        (WebCore::DateComponents::maximumMonth):
+        (WebCore::DateComponents::maximumWeek):
+
 2010-08-29  Kwang Yul Seo  <skyul at company100.net>
 
         Reviewed by Kent Tamura.
diff --git a/WebCore/html/DateComponents.cpp b/WebCore/html/DateComponents.cpp
index 39dd733..88e303e 100644
--- a/WebCore/html/DateComponents.cpp
+++ b/WebCore/html/DateComponents.cpp
@@ -41,10 +41,15 @@ using namespace std;
 
 namespace WebCore {
 
-// The oldest day of Gregorian Calendar is 1582-10-15. We don't support dates older than it.
-static const int gregorianStartYear = 1582;
-static const int gregorianStartMonth = 9; // This is October, since months are 0 based.
-static const int gregorianStartDay = 15;
+// HTML5 uses ISO-8601 format with year >= 1. Gregorian calendar started in
+// 1582. However, we need to support 0001-01-01 in Gregorian calendar rule.
+static const int minimumYear = 1;
+// Date in ECMAScript can't represent dates later than 275760-09-13T00:00Z.
+// So, we have the same upper limit in HTML5 dates.
+static const int maximumYear = 275760;
+static const int maximumMonthInMaximumYear = 8; // This is September, since months are 0 based.
+static const int maximumDayInMaximumMonth = 13;
+static const int maximumWeekInMaximumYear = 37; // The week of 275760-09-13
 
 static const int daysInMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
@@ -134,19 +139,47 @@ bool DateComponents::parseYear(const UChar* src, unsigned length, unsigned start
     int year;
     if (!toInt(src, length, start, digitsLength, year))
         return false;
-    // No support for years before Gregorian calendar.
-    if (year < gregorianStartYear)
+    if (year < minimumYear || year > maximumYear)
         return false;
     m_year = year;
     end = start + digitsLength;
     return true;
 }
 
-static bool beforeGregorianStartDate(int year, int month, int monthDay)
+static bool withinHTMLDateLimits(int year, int month)
 {
-    return year < gregorianStartYear
-        || (year == gregorianStartYear && month < gregorianStartMonth)
-        || (year == gregorianStartYear && month == gregorianStartMonth && monthDay < gregorianStartDay);
+    if (year < minimumYear)
+        return false;
+    if (year < maximumYear)
+        return true;
+    return month <= maximumMonthInMaximumYear;
+}
+
+static bool withinHTMLDateLimits(int year, int month, int monthDay)
+{
+    if (year < minimumYear)
+        return false;
+    if (year < maximumYear)
+        return true;
+    if (month < maximumMonthInMaximumYear)
+        return true;
+    return monthDay <= maximumDayInMaximumMonth;
+}
+
+static bool withinHTMLDateLimits(int year, int month, int monthDay, int hour, int minute, int second, int millisecond)
+{
+    if (year < minimumYear)
+        return false;
+    if (year < maximumYear)
+        return true;
+    if (month < maximumMonthInMaximumYear)
+        return true;
+    if (monthDay < maximumDayInMaximumMonth)
+        return true;
+    if (monthDay > maximumDayInMaximumMonth)
+        return false;
+    // (year, month, monthDay) = (maximumYear, maximumMonthInMaximumYear, maximumDayInMaximumMonth)
+    return !hour && !minute && !second && !millisecond;
 }
 
 bool DateComponents::addDay(int dayDiff)
@@ -167,12 +200,12 @@ bool DateComponents::addDay(int dayDiff)
                 if (month >= 12) { // month is 0-origin.
                     month = 0;
                     ++year;
-                    if (year < 0) // Check for overflow.
-                        return false;
                 }
                 maxDay = maxDayOfMonth(year, month);
             }
         }
+        if (!withinHTMLDateLimits(year, month, day))
+            return false;
         m_year = year;
         m_month = month;
     } else if (day < 1) {
@@ -189,11 +222,14 @@ bool DateComponents::addDay(int dayDiff)
                 }
                 day = maxDayOfMonth(year, month);
             }
-            if (beforeGregorianStartDate(year, month, day))
-                return false;
         }
+        if (!withinHTMLDateLimits(year, month, day))
+            return false;
         m_year = year;
         m_month = month;
+    } else {
+        if (!withinHTMLDateLimits(m_year, m_month, day))
+            return false;
     }
     m_monthDay = day;
     return true;
@@ -201,8 +237,12 @@ bool DateComponents::addDay(int dayDiff)
 
 bool DateComponents::addMinute(int minute)
 {
+    // This function is used to adjust timezone offset. So m_year, m_month,
+    // m_monthDay have values between the lower and higher limits.
+    ASSERT(withinHTMLDateLimits(m_year, m_month, m_monthDay));
+
     int carry;
-    // min can be negative or greater than 59.
+    // minute can be negative or greater than 59.
     minute += m_minute;
     if (minute > 59) {
         carry = minute / 60;
@@ -213,6 +253,8 @@ bool DateComponents::addMinute(int minute)
         carry = -carry;
         ASSERT(minute >= 0 && minute <= 59);
     } else {
+        if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, m_hour, minute, m_second, m_millisecond))
+            return false;
         m_minute = minute;
         return true;
     }
@@ -227,12 +269,16 @@ bool DateComponents::addMinute(int minute)
         carry = -carry;
         ASSERT(hour >= 0 && hour <= 23);
     } else {
+        if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, hour, minute, m_second, m_millisecond))
+            return false;
         m_minute = minute;
         m_hour = hour;
         return true;
     }
     if (!addDay(carry))
         return false;
+    if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, hour, minute, m_second, m_millisecond))
+        return false;
     m_minute = minute;
     m_hour = hour;
     return true;
@@ -298,8 +344,7 @@ bool DateComponents::parseMonth(const UChar* src, unsigned length, unsigned star
     if (!toInt(src, length, index, 2, month) || month < 1 || month > 12)
         return false;
     --month;
-    // No support for months before Gregorian calendar.
-    if (beforeGregorianStartDate(m_year, month, gregorianStartDay))
+    if (!withinHTMLDateLimits(m_year, month))
         return false;
     m_month = month;
     end = index + 2;
@@ -323,8 +368,7 @@ bool DateComponents::parseDate(const UChar* src, unsigned length, unsigned start
     int day;
     if (!toInt(src, length, index, 2, day) || day < 1 || day > maxDayOfMonth(m_year, m_month))
         return false;
-    // No support for dates before Gregorian calendar.
-    if (m_year == gregorianStartYear && m_month == gregorianStartMonth && day < gregorianStartDay)
+    if (!withinHTMLDateLimits(m_year, m_month, day))
         return false;
     m_monthDay = day;
     end = index + 2;
@@ -352,8 +396,7 @@ bool DateComponents::parseWeek(const UChar* src, unsigned length, unsigned start
     int week;
     if (!toInt(src, length, index, 2, week) || week < 1 || week > maxWeekNumberInYear())
         return false;
-    // No support for years older than or equals to Gregorian calendar start year.
-    if (m_year <= gregorianStartYear)
+    if (m_year == maximumYear && week > maximumWeekInMaximumYear)
         return false;
     m_week = week;
     end = index + 2;
@@ -429,6 +472,8 @@ bool DateComponents::parseDateTimeLocal(const UChar* src, unsigned length, unsig
     ++index;
     if (!parseTime(src, length, index, end))
         return false;
+    if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, m_hour, m_minute, m_second, m_millisecond))
+        return false;
     m_type = DateTimeLocal;
     return true;
 }
@@ -448,6 +493,8 @@ bool DateComponents::parseDateTime(const UChar* src, unsigned length, unsigned s
         return false;
     if (!parseTimeZone(src, length, index, end))
         return false;
+    if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, m_hour, m_minute, m_second, m_millisecond))
+        return false;
     m_type = DateTime;
     return true;
 }
@@ -485,7 +532,7 @@ bool DateComponents::setMillisecondsSinceEpochForDate(double ms)
         return false;
     if (!setMillisecondsSinceEpochForDateInternal(round(ms)))
         return false;
-    if (beforeGregorianStartDate(m_year, m_month, m_monthDay))
+    if (!withinHTMLDateLimits(m_year, m_month, m_monthDay))
         return false;
     m_type = Date;
     return true;
@@ -500,7 +547,7 @@ bool DateComponents::setMillisecondsSinceEpochForDateTime(double ms)
     setMillisecondsSinceMidnightInternal(positiveFmod(ms, msPerDay));
     if (!setMillisecondsSinceEpochForDateInternal(ms))
         return false;
-    if (beforeGregorianStartDate(m_year, m_month, m_monthDay))
+    if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, m_hour, m_minute, m_second, m_millisecond))
         return false;
     m_type = DateTime;
     return true;
@@ -522,8 +569,7 @@ bool DateComponents::setMillisecondsSinceEpochForMonth(double ms)
         return false;
     if (!setMillisecondsSinceEpochForDateInternal(round(ms)))
         return false;
-    // Ignore m_monthDay updated by setMillisecondsSinceEpochForDateInternal().
-    if (beforeGregorianStartDate(m_year, m_month, gregorianStartDay))
+    if (!withinHTMLDateLimits(m_year, m_month))
         return false;
     m_type = Month;
     return true;
@@ -546,11 +592,11 @@ bool DateComponents::setMonthsSinceEpoch(double months)
     months = round(months);
     double doubleMonth = positiveFmod(months, 12);
     double doubleYear = 1970 + (months - doubleMonth) / 12;
-    if (doubleYear < gregorianStartYear || numeric_limits<int>::max() < doubleYear)
+    if (doubleYear < minimumYear || maximumYear < doubleYear)
         return false;
     int year = static_cast<int>(doubleYear);
     int month = static_cast<int>(doubleMonth);
-    if (beforeGregorianStartDate(year, month, gregorianStartDay))
+    if (!withinHTMLDateLimits(year, month))
         return false;
     m_year = year;
     m_month = month;
@@ -576,8 +622,7 @@ bool DateComponents::setMillisecondsSinceEpochForWeek(double ms)
     ms = round(ms);
 
     m_year = msToYear(ms);
-    // We don't support gregorianStartYear. Week numbers are undefined in that year.
-    if (m_year <= gregorianStartYear)
+    if (m_year < minimumYear || m_year > maximumYear)
         return false;
 
     int yearDay = dayInYear(ms, m_year);
@@ -585,7 +630,7 @@ bool DateComponents::setMillisecondsSinceEpochForWeek(double ms)
     if (yearDay < offset) {
         // The day belongs to the last week of the previous year.
         m_year--;
-        if (m_year <= gregorianStartYear)
+        if (m_year <= minimumYear)
             return false;
         m_week = maxWeekNumberInYear();
     } else {
@@ -594,6 +639,8 @@ bool DateComponents::setMillisecondsSinceEpochForWeek(double ms)
             m_year++;
             m_week = 1;
         }
+        if (m_year > maximumYear || m_year == maximumYear && m_week > maximumWeekInMaximumYear)
+            return false;
     }
     m_type = Week;
     return true;
diff --git a/WebCore/html/DateComponents.h b/WebCore/html/DateComponents.h
index efc3248..9bce0c3 100644
--- a/WebCore/html/DateComponents.h
+++ b/WebCore/html/DateComponents.h
@@ -137,17 +137,16 @@ public:
 
     // Minimum and maxmimum limits for setMillisecondsSince*(),
     // setMonthsSinceEpoch(), millisecondsSinceEpoch(), and monthsSinceEpoch().
-    static inline double minimumDate() { return -12219292800000.0; } // This means 1582-10-15T00:00Z.
-    static inline double minimumDateTime() { return -12219292800000.0; } // ditto.
-    static inline double minimumMonth() { return (1582.0 - 1970) * 12 + 10 - 1; } // 1582-10
+    static inline double minimumDate() { return -62135596800000.0; } // 0001-01-01T00:00Z
+    static inline double minimumDateTime() { return -62135596800000.0; } // ditto.
+    static inline double minimumMonth() { return (1 - 1970) * 12.0 + 1 - 1; } // 0001-01
     static inline double minimumTime() { return 0; } // 00:00:00.000
-    static inline double minimumWeek() { return -12212380800000.0; } // 1583-01-03, the first Monday of 1583.
-    static inline double maximumDate() { return std::numeric_limits<double>::max(); }
-    static inline double maximumDateTime() { return std::numeric_limits<double>::max(); }
-    // DateComponents::m_year can't represent a year greater than INT_MAX.
-    static inline double maximumMonth() { return (std::numeric_limits<int>::max() - 1970) * 12.0 + 12 - 1; }
+    static inline double minimumWeek() { return -62135596800000.0; } // 0001-01-01, the first Monday of 0001.
+    static inline double maximumDate() { return 8640000000000000.0; } // 275760-09-13T00:00Z
+    static inline double maximumDateTime() { return 8640000000000000.0; } // ditto.
+    static inline double maximumMonth() { return (275760 - 1970) * 12.0 + 9 - 1; } // 275760-09
     static inline double maximumTime() { return 86399999; } // 23:59:59.999
-    static inline double maximumWeek() { return std::numeric_limits<double>::max(); }
+    static inline double maximumWeek() { return 8639999568000000.0; } // 275760-09-08, the Monday of the week including 275760-09-13.
 
 private:
     // Returns the maximum week number in this DateComponents's year.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list