Title: [293996] trunk
Revision
293996
Author
ross.kirsl...@sony.com
Date
2022-05-09 19:52:56 -0700 (Mon, 09 May 2022)

Log Message

Temporal and Date must reject expanded year -000000
https://bugs.webkit.org/show_bug.cgi?id=240263

Reviewed by Yusuke Suzuki.

As of the following two PRs, -000000 is officially disallowed as a representation of the year zero in ISO date strings.
https://github.com/tc39/ecma262/pull/2550
https://github.com/tc39/proposal-temporal/pull/1992

This patch implements the change for Temporal and Date alike.

* test262/expectations.yaml:
Mark 24 test cases as passing.

* runtime/ISO8601.cpp:
(JSC::ISO8601::parseDate):

* wtf/DateMath.cpp:
(WTF::parseES5DatePortion):

Canonical link: https://commits.webkit.org/250432@main

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (293995 => 293996)


--- trunk/JSTests/ChangeLog	2022-05-10 00:16:39 UTC (rev 293995)
+++ trunk/JSTests/ChangeLog	2022-05-10 02:52:56 UTC (rev 293996)
@@ -1,3 +1,13 @@
+2022-05-09  Ross Kirsling  <ross.kirsl...@sony.com>
+
+        Temporal and Date must reject expanded year -000000
+        https://bugs.webkit.org/show_bug.cgi?id=240263
+
+        Reviewed by Yusuke Suzuki.
+
+        * test262/expectations.yaml:
+        Mark 24 test cases as passing.
+
 2022-05-09  Keith Miller  <keith_mil...@apple.com>
 
         Unreviewed test gardening.

Modified: trunk/JSTests/test262/expectations.yaml (293995 => 293996)


--- trunk/JSTests/test262/expectations.yaml	2022-05-10 00:16:39 UTC (rev 293995)
+++ trunk/JSTests/test262/expectations.yaml	2022-05-10 02:52:56 UTC (rev 293996)
@@ -609,12 +609,6 @@
 test/built-ins/Date/UTC/fp-evaluation-order.js:
   default: 'Test262Error: order of operations / precision in MakeTime Expected SameValue(«NaN», «29312») to be true'
   strict mode: 'Test262Error: order of operations / precision in MakeTime Expected SameValue(«NaN», «29312») to be true'
-test/built-ins/Date/parse/year-zero.js:
-  default: 'Test262Error: reject minus zero as extended year Expected SameValue(«-62159440500000», «NaN») to be true'
-  strict mode: 'Test262Error: reject minus zero as extended year Expected SameValue(«-62159440500000», «NaN») to be true'
-test/built-ins/Date/year-zero.js:
-  default: 'Test262Error: reject minus zero as extended year Expected SameValue(«-62159440500000», «NaN») to be true'
-  strict mode: 'Test262Error: reject minus zero as extended year Expected SameValue(«-62159440500000», «NaN») to be true'
 test/built-ins/Function/internals/Construct/derived-return-val-realm.js:
   default: 'Test262Error: Expected a TypeError but got a different error constructor with the same name'
   strict mode: 'Test262Error: Expected a TypeError but got a different error constructor with the same name'
@@ -1068,15 +1062,6 @@
 test/built-ins/Temporal/Duration/prototype/total/unit-string-shorthand-string.js:
   default: 'TypeError: options argument is not an object or undefined'
   strict mode: 'TypeError: options argument is not an object or undefined'
-test/built-ins/Temporal/Instant/compare/year-zero.js:
-  default: 'Test262Error: minus zero is invalid extended year (first argument) Expected a RangeError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: minus zero is invalid extended year (first argument) Expected a RangeError to be thrown but no exception was thrown at all'
-test/built-ins/Temporal/Instant/from/year-zero.js:
-  default: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
-test/built-ins/Temporal/Instant/prototype/equals/year-zero.js:
-  default: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
 test/built-ins/Temporal/Instant/prototype/round/rounding-direction.js:
   default: 'Test262Error: Rounding down is towards the Big Bang, not the epoch or 1 BCE (roundingMode trunc) Expected SameValue(«-65261246399000000000», «-65261246400000000000») to be true'
   strict mode: 'Test262Error: Rounding down is towards the Big Bang, not the epoch or 1 BCE (roundingMode trunc) Expected SameValue(«-65261246399000000000», «-65261246400000000000») to be true'
@@ -1092,9 +1077,6 @@
 test/built-ins/Temporal/Instant/prototype/since/largestunit.js:
   default: 'Test262Error: does not include higher units than necessary (largest unit unspecified) nanoseconds result Expected SameValue(«40», «101») to be true'
   strict mode: 'Test262Error: does not include higher units than necessary (largest unit unspecified) nanoseconds result Expected SameValue(«40», «101») to be true'
-test/built-ins/Temporal/Instant/prototype/since/year-zero.js:
-  default: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
 test/built-ins/Temporal/Instant/prototype/toJSON/timezone-getoffsetnanosecondsfor-not-callable.js:
   default: 'Test262Error: Uncallable undefined getOffsetNanosecondsFor should throw TypeError Expected a TypeError to be thrown but no exception was thrown at all'
   strict mode: 'Test262Error: Uncallable undefined getOffsetNanosecondsFor should throw TypeError Expected a TypeError to be thrown but no exception was thrown at all'
@@ -1119,9 +1101,6 @@
 test/built-ins/Temporal/Instant/prototype/toString/year-format.js:
   default: 'Test262Error: year 0 formatted as 4-digit Expected SameValue(«+000000-07-01T21:30:36Z», «0000-07-01T21:30:36Z») to be true'
   strict mode: 'Test262Error: year 0 formatted as 4-digit Expected SameValue(«+000000-07-01T21:30:36Z», «0000-07-01T21:30:36Z») to be true'
-test/built-ins/Temporal/Instant/prototype/until/year-zero.js:
-  default: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
 test/built-ins/Temporal/PlainTime/compare/argument-cast.js:
   default: 'TypeError: "microsecond" field is missing'
   strict mode: 'TypeError: "microsecond" field is missing'
@@ -1137,9 +1116,6 @@
 test/built-ins/Temporal/PlainTime/compare/plaintime-propertybag-no-time-units.js:
   default: 'TypeError: "hour" field is missing'
   strict mode: 'TypeError: "hour" field is missing'
-test/built-ins/Temporal/PlainTime/compare/year-zero.js:
-  default: 'Test262Error: Cannot use minus zero as extended year (first argument) Expected a RangeError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: Cannot use minus zero as extended year (first argument) Expected a RangeError to be thrown but no exception was thrown at all'
 test/built-ins/Temporal/PlainTime/from/argument-object-leap-second.js:
   default: 'TypeError: "microsecond" field is missing'
   strict mode: 'TypeError: "microsecond" field is missing'
@@ -1179,9 +1155,6 @@
 test/built-ins/Temporal/PlainTime/from/plaintime-propertybag-no-time-units.js:
   default: 'TypeError: "hour" field is missing'
   strict mode: 'TypeError: "hour" field is missing'
-test/built-ins/Temporal/PlainTime/from/year-zero.js:
-  default: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
 test/built-ins/Temporal/PlainTime/prototype/equals/argument-cast.js:
   default: 'TypeError: "microsecond" field is missing'
   strict mode: 'TypeError: "microsecond" field is missing'
@@ -1197,9 +1170,6 @@
 test/built-ins/Temporal/PlainTime/prototype/equals/plaintime-propertybag-no-time-units.js:
   default: 'TypeError: "hour" field is missing'
   strict mode: 'TypeError: "hour" field is missing'
-test/built-ins/Temporal/PlainTime/prototype/equals/year-zero.js:
-  default: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
 test/built-ins/Temporal/PlainTime/prototype/round/roundto-invalid-string.js:
   default: 'Test262Error: "era" is not a valid value for smallest unit Expected a RangeError but got a TypeError'
   strict mode: 'Test262Error: "era" is not a valid value for smallest unit Expected a RangeError but got a TypeError'
@@ -1227,9 +1197,6 @@
 test/built-ins/Temporal/PlainTime/prototype/since/roundingmode-floor.js:
   default: 'Test262Error: hours hours result Expected SameValue(«5», «4») to be true'
   strict mode: 'Test262Error: hours hours result Expected SameValue(«5», «4») to be true'
-test/built-ins/Temporal/PlainTime/prototype/since/year-zero.js:
-  default: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
 test/built-ins/Temporal/PlainTime/prototype/until/argument-cast.js:
   default: 'TypeError: "microsecond" field is missing'
   strict mode: 'TypeError: "microsecond" field is missing'
@@ -1245,9 +1212,6 @@
 test/built-ins/Temporal/PlainTime/prototype/until/plaintime-propertybag-no-time-units.js:
   default: 'TypeError: "hour" field is missing'
   strict mode: 'TypeError: "hour" field is missing'
-test/built-ins/Temporal/PlainTime/prototype/until/year-zero.js:
-  default: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: reject minus zero as extended year Expected a RangeError to be thrown but no exception was thrown at all'
 test/built-ins/Temporal/getOwnPropertyNames.js:
   default: 'Test262Error: PlainDateTime'
   strict mode: 'Test262Error: PlainDateTime'

Modified: trunk/Source/_javascript_Core/ChangeLog (293995 => 293996)


--- trunk/Source/_javascript_Core/ChangeLog	2022-05-10 00:16:39 UTC (rev 293995)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-05-10 02:52:56 UTC (rev 293996)
@@ -1,3 +1,19 @@
+2022-05-09  Ross Kirsling  <ross.kirsl...@sony.com>
+
+        Temporal and Date must reject expanded year -000000
+        https://bugs.webkit.org/show_bug.cgi?id=240263
+
+        Reviewed by Yusuke Suzuki.
+
+        As of the following two PRs, -000000 is officially disallowed as a representation of the year zero in ISO date strings.
+        https://github.com/tc39/ecma262/pull/2550
+        https://github.com/tc39/proposal-temporal/pull/1992
+
+        This patch implements the change for Temporal and Date alike.
+
+        * runtime/ISO8601.cpp:
+        (JSC::ISO8601::parseDate):
+
 2022-05-06  Ross Kirsling  <ross.kirsl...@sony.com>
 
         Temporal.Duration#toString should never ignore fractionalSecondDigits

Modified: trunk/Source/_javascript_Core/runtime/ISO8601.cpp (293995 => 293996)


--- trunk/Source/_javascript_Core/runtime/ISO8601.cpp	2022-05-10 00:16:39 UTC (rev 293995)
+++ trunk/Source/_javascript_Core/runtime/ISO8601.cpp	2022-05-10 02:52:56 UTC (rev 293996)
@@ -862,6 +862,8 @@
                 return std::nullopt;
         }
         year = parseDecimalInt32(buffer.position(), 6) * yearFactor;
+        if (!year && yearFactor < 0)
+            return std::nullopt;
         buffer.advanceBy(6);
     } else {
         if (buffer.lengthRemaining() < 4)

Modified: trunk/Source/WTF/ChangeLog (293995 => 293996)


--- trunk/Source/WTF/ChangeLog	2022-05-10 00:16:39 UTC (rev 293995)
+++ trunk/Source/WTF/ChangeLog	2022-05-10 02:52:56 UTC (rev 293996)
@@ -1,3 +1,13 @@
+2022-05-09  Ross Kirsling  <ross.kirsl...@sony.com>
+
+        Temporal and Date must reject expanded year -000000
+        https://bugs.webkit.org/show_bug.cgi?id=240263
+
+        Reviewed by Yusuke Suzuki.
+
+        * wtf/DateMath.cpp:
+        (WTF::parseES5DatePortion):
+
 2022-05-09  Per Arne Vollan  <pvol...@apple.com>
 
         [macOS] HTTP traffic is not filtered in the parental controls filter

Modified: trunk/Source/WTF/wtf/DateMath.cpp (293995 => 293996)


--- trunk/Source/WTF/wtf/DateMath.cpp	2022-05-10 00:16:39 UTC (rev 293995)
+++ trunk/Source/WTF/wtf/DateMath.cpp	2022-05-10 02:52:56 UTC (rev 293996)
@@ -487,8 +487,11 @@
     // This is a bit more lenient on the year string than ES5 specifies:
     // instead of restricting to 4 digits (or 6 digits with mandatory +/-),
     // it accepts any integer value. Consider this an implementation fallback.
+    bool hasNegativeYear = *currentPosition == '-';
     if (!parseInt(currentPosition, &postParsePosition, 10, &year))
         return nullptr;
+    if (!year && hasNegativeYear)
+        return nullptr;
 
     // Check for presence of -MM portion.
     if (*postParsePosition != '-')
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to