Changeset 291603 in webkit


Ignore:
Timestamp:
Mar 21, 2022 9:26:31 PM (4 months ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Change Date.parse to stop returning numbers with fractional part
https://bugs.webkit.org/show_bug.cgi?id=238050

Reviewed by Saam Barati.

JSTests:

  • stress/date-parse-timeclip.js: Added.

(shouldBe):

Source/JavaScriptCore:

Date.parse should return NaN or integer numbers[1,2]. This patch applies timeClip
to the result of Date.parse to ensure that the returned value is time value.

[1]: https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.parse
[2]: https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-time-values-and-time-range

  • runtime/DateConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r291577 r291603  
     12022-03-21  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Change Date.parse to stop returning numbers with fractional part
     4        https://bugs.webkit.org/show_bug.cgi?id=238050
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/date-parse-timeclip.js: Added.
     9        (shouldBe):
     10
    1112022-03-21  Yusuke Suzuki  <ysuzuki@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r291602 r291603  
     12022-03-21  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Change Date.parse to stop returning numbers with fractional part
     4        https://bugs.webkit.org/show_bug.cgi?id=238050
     5
     6        Reviewed by Saam Barati.
     7
     8        Date.parse should return NaN or integer numbers[1,2]. This patch applies timeClip
     9        to the result of Date.parse to ensure that the returned value is time value.
     10
     11        [1]: https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.parse
     12        [2]: https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-time-values-and-time-range
     13
     14        * runtime/DateConstructor.cpp:
     15        (JSC::JSC_DEFINE_HOST_FUNCTION):
     16
    1172022-03-21  Saam Barati  <sbarati@apple.com>
    218
  • trunk/Source/JavaScriptCore/runtime/DateConstructor.cpp

    r273661 r291603  
    160160    String dateStr = callFrame->argument(0).toWTFString(globalObject);
    161161    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    162     RELEASE_AND_RETURN(scope, JSValue::encode(jsNumber(vm.dateCache.parseDate(globalObject, vm, dateStr))));
     162    RELEASE_AND_RETURN(scope, JSValue::encode(jsNumber(timeClip(vm.dateCache.parseDate(globalObject, vm, dateStr)))));
    163163}
    164164
Note: See TracChangeset for help on using the changeset viewer.