- Revision
- 288411
- Author
- [email protected]
- Date
- 2022-01-22 16:00:38 -0800 (Sat, 22 Jan 2022)
Log Message
[JSC] Relax Date.parse requirement
https://bugs.webkit.org/show_bug.cgi?id=235468
Reviewed by Darin Adler.
JSTests:
* stress/date-relaxed-separator.js: Added.
(shouldBe):
Source/WTF:
While the spec does not require accepting 't' / ' ' separator, ISO 8601 accepts it.
This is because ECMA262's Date format is *not* ISO 8601 (it is called simplification
of ISO 8601[1]).
This patch relaxes this strictness to accept more formats, which can be accepted in
the other engines too.
[1]: https://tc39.es/ecma262/#sec-date-time-string-format
* wtf/DateMath.cpp:
(WTF::parseES5DateFromNullTerminatedCharacters):
LayoutTests:
* js/date-parse-test-expected.txt:
* js/script-tests/date-parse-test.js:
Modified Paths
Added Paths
Diff
Modified: trunk/JSTests/ChangeLog (288410 => 288411)
--- trunk/JSTests/ChangeLog 2022-01-22 22:58:56 UTC (rev 288410)
+++ trunk/JSTests/ChangeLog 2022-01-23 00:00:38 UTC (rev 288411)
@@ -1,3 +1,13 @@
+2022-01-21 Yusuke Suzuki <[email protected]>
+
+ [JSC] Relax Date.parse requirement
+ https://bugs.webkit.org/show_bug.cgi?id=235468
+
+ Reviewed by Darin Adler.
+
+ * stress/date-relaxed-separator.js: Added.
+ (shouldBe):
+
2022-01-19 Yusuke Suzuki <[email protected]>
[JSC] Implement Temporal.Now.instant()
Added: trunk/JSTests/stress/date-relaxed-separator.js (0 => 288411)
--- trunk/JSTests/stress/date-relaxed-separator.js (rev 0)
+++ trunk/JSTests/stress/date-relaxed-separator.js 2022-01-23 00:00:38 UTC (rev 288411)
@@ -0,0 +1,7 @@
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error('bad value: ' + actual);
+}
+
+shouldBe(new Date("2022-01-01 00:00:00Z").getTime(), 1640995200000);
+shouldBe(new Date("2022-01-01t00:00:00Z").getTime(), 1640995200000);
Modified: trunk/LayoutTests/ChangeLog (288410 => 288411)
--- trunk/LayoutTests/ChangeLog 2022-01-22 22:58:56 UTC (rev 288410)
+++ trunk/LayoutTests/ChangeLog 2022-01-23 00:00:38 UTC (rev 288411)
@@ -1,3 +1,13 @@
+2022-01-21 Yusuke Suzuki <[email protected]>
+
+ [JSC] Relax Date.parse requirement
+ https://bugs.webkit.org/show_bug.cgi?id=235468
+
+ Reviewed by Darin Adler.
+
+ * js/date-parse-test-expected.txt:
+ * js/script-tests/date-parse-test.js:
+
2022-01-22 Alan Bujtas <[email protected]>
REGRESSION (r288069): Bits of selection left after deselecting on bugzilla page
Modified: trunk/LayoutTests/js/date-parse-test-expected.txt (288410 => 288411)
--- trunk/LayoutTests/js/date-parse-test-expected.txt 2022-01-22 22:58:56 UTC (rev 288410)
+++ trunk/LayoutTests/js/date-parse-test-expected.txt 2022-01-23 00:00:38 UTC (rev 288411)
@@ -27,7 +27,7 @@
PASS Date.parse("1995-12-25T01:30:00Z ") is NaN
PASS Date.parse("1995-12-25T01:30:00+00:00 ") is NaN
PASS Date.parse("1995-02-29T00:00:00Z") is NaN
-PASS Date.parse("1995-12-25 01:30:00Z") is NaN
+PASS Date.parse("1995-12-25 01:30:00Z") == 819855000000 is true
PASS Date.parse("1995-12-25T01:30:00z") is NaN
PASS Number(Date.parse('1970')) is 0
PASS Number(Date.parse('1970-01')) is 0
Modified: trunk/LayoutTests/js/script-tests/date-parse-test.js (288410 => 288411)
--- trunk/LayoutTests/js/script-tests/date-parse-test.js 2022-01-22 22:58:56 UTC (rev 288410)
+++ trunk/LayoutTests/js/script-tests/date-parse-test.js 2022-01-23 00:00:38 UTC (rev 288411)
@@ -66,7 +66,7 @@
testDateParseExact("1995-12-25T01:30:00Z ", "NaN");
testDateParseExact("1995-12-25T01:30:00+00:00 ", "NaN");
testDateParseExact("1995-02-29T00:00:00Z", "NaN");
-testDateParseExact("1995-12-25 01:30:00Z", "NaN");
+testDateParseExact("1995-12-25 01:30:00Z", "819855000000");
testDateParseExact("1995-12-25T01:30:00z", "NaN");
// Date-only dates.
Modified: trunk/Source/WTF/ChangeLog (288410 => 288411)
--- trunk/Source/WTF/ChangeLog 2022-01-22 22:58:56 UTC (rev 288410)
+++ trunk/Source/WTF/ChangeLog 2022-01-23 00:00:38 UTC (rev 288411)
@@ -1,3 +1,21 @@
+2022-01-21 Yusuke Suzuki <[email protected]>
+
+ [JSC] Relax Date.parse requirement
+ https://bugs.webkit.org/show_bug.cgi?id=235468
+
+ Reviewed by Darin Adler.
+
+ While the spec does not require accepting 't' / ' ' separator, ISO 8601 accepts it.
+ This is because ECMA262's Date format is *not* ISO 8601 (it is called simplification
+ of ISO 8601[1]).
+ This patch relaxes this strictness to accept more formats, which can be accepted in
+ the other engines too.
+
+ [1]: https://tc39.es/ecma262/#sec-date-time-string-format
+
+ * wtf/DateMath.cpp:
+ (WTF::parseES5DateFromNullTerminatedCharacters):
+
2022-01-21 Sihui Liu <[email protected]>
Disable CFURLCache in WebKit2
Modified: trunk/Source/WTF/wtf/DateMath.cpp (288410 => 288411)
--- trunk/Source/WTF/wtf/DateMath.cpp 2022-01-22 22:58:56 UTC (rev 288410)
+++ trunk/Source/WTF/wtf/DateMath.cpp 2022-01-23 00:00:38 UTC (rev 288411)
@@ -645,7 +645,7 @@
return std::numeric_limits<double>::quiet_NaN();
// Look for a time portion.
// Note: As of ES2016, when a UTC offset is missing, date-time forms are local time while date-only forms are UTC.
- if (*currentPosition == 'T') {
+ if (*currentPosition == 'T' || *currentPosition == 't' || *currentPosition == ' ') {
// Parse the time HH:mm[:ss[.sss]][Z|(+|-)(00:00|0000|00)]
currentPosition = parseES5TimePortion(currentPosition + 1, hours, minutes, seconds, milliseconds, isLocalTime, timeZoneSeconds);
if (!currentPosition)