⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 201586 in webkit


Ignore:
Timestamp:
Jun 1, 2016, 8:34:31 PM (10 years ago)
Author:
benjamin@webkit.org
Message:

[JSC] Some setters for components of Date do not timeClip() their result
https://bugs.webkit.org/show_bug.cgi?id=158278
Source/JavaScriptCore:

rdar://problem/25131426

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-06-01
Reviewed by Geoffrey Garen.

Many of the setters where not doing timeClip() on the computed UTC
time since Epoch.

See http://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setdate
and the following sections for the definition.

  • runtime/DatePrototype.cpp:

(JSC::setNewValueFromTimeArgs):
(JSC::setNewValueFromDateArgs):

Source/WTF:

Unreviewed.

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-06-01

  • wtf/DateMath.cpp:

(WTF::equivalentYearForDST): Deleted.
The assertion is bogus.
As the comments above explains, the function is completely wrong for years
outside [1900-2100].
The tests passing large values for years are failing (year <= maxYear).
The weird NaN test is a mystery. The old changelog does not explain it.

LayoutTests:

rdar://problem/25131426

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-06-01
Reviewed by Geoffrey Garen.

New test coverage for large values.

Note that some of those tests are still failing with this patch.

The reason is our code handling month and years is unable to deal
with values outside int32.
Changing that is a bit more complicated due to the number of users
of DateMath. I leave that for the future.

  • js/date-timeClip-large-values-expected.txt: Added.
  • js/date-timeClip-large-values.html: Added.
  • js/script-tests/date-timeClip-large-values.js: Added.
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r201568 r201586  
     12016-06-01  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Some setters for components of Date do not timeClip() their result
     4        https://bugs.webkit.org/show_bug.cgi?id=158278
     5        rdar://problem/25131426
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        New test coverage for large values.
     10
     11        Note that some of those tests are still failing with this patch.
     12
     13        The reason is our code handling month and years is unable to deal
     14        with values outside int32.
     15        Changing that is a bit more complicated due to the number of users
     16        of DateMath. I leave that for the future.
     17
     18        * js/date-timeClip-large-values-expected.txt: Added.
     19        * js/date-timeClip-large-values.html: Added.
     20        * js/script-tests/date-timeClip-large-values.js: Added.
     21
    1222016-06-01  Chris Fleizach  <cfleizach@apple.com>
    223
  • trunk/Source/JavaScriptCore/ChangeLog

    r201584 r201586  
     12016-06-01  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Some setters for components of Date do not timeClip() their result
     4        https://bugs.webkit.org/show_bug.cgi?id=158278
     5        rdar://problem/25131426
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Many of the setters where not doing timeClip() on the computed UTC
     10        time since Epoch.
     11
     12        See http://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setdate
     13        and the following sections for the definition.
     14
     15        * runtime/DatePrototype.cpp:
     16        (JSC::setNewValueFromTimeArgs):
     17        (JSC::setNewValueFromDateArgs):
     18
    1192016-06-01  Keith Miller  <keith_miller@apple.com>
    220
  • trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp

    r201448 r201586  
    919919        return JSValue::encode(result);
    920920    }
    921    
    922     JSValue result = jsNumber(gregorianDateTimeToMS(vm, gregorianDateTime, ms, inputTimeType));
     921
     922    double newUTCDate = gregorianDateTimeToMS(vm, gregorianDateTime, ms, inputTimeType);
     923    JSValue result = jsNumber(timeClip(newUTCDate));
    923924    thisDateObj->setInternalValue(vm, result);
    924925    return JSValue::encode(result);
     
    960961        return JSValue::encode(result);
    961962    }
    962            
    963     JSValue result = jsNumber(gregorianDateTimeToMS(vm, gregorianDateTime, ms, inputTimeType));
     963
     964    double newUTCDate = gregorianDateTimeToMS(vm, gregorianDateTime, ms, inputTimeType);
     965    JSValue result = jsNumber(timeClip(newUTCDate));
    964966    thisDateObj->setInternalValue(vm, result);
    965967    return JSValue::encode(result);
  • trunk/Source/WTF/ChangeLog

    r201532 r201586  
     12016-06-01  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Some setters for components of Date do not timeClip() their result
     4        https://bugs.webkit.org/show_bug.cgi?id=158278
     5
     6        Unreviewed.
     7
     8        * wtf/DateMath.cpp:
     9        (WTF::equivalentYearForDST): Deleted.
     10        The assertion is bogus.
     11        As the comments above explains, the function is completely wrong for years
     12        outside [1900-2100].
     13        The tests passing large values for years are failing (year <= maxYear).
     14        The weird NaN test is a mystery. The old changelog does not explain it.
     15
    1162016-05-31  Commit Queue  <commit-queue@webkit.org>
    217
  • trunk/Source/WTF/wtf/DateMath.cpp

    r181360 r201586  
    358358
    359359    year += product;
    360     ASSERT((year >= minYear && year <= maxYear) || (product - year == static_cast<int>(std::numeric_limits<double>::quiet_NaN())));
    361360    return year;
    362361}
Note: See TracChangeset for help on using the changeset viewer.