Changeset 202683 in webkit


Ignore:
Timestamp:
Jun 30, 2016 10:16:39 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC] Date.setYear() misses timeClip()
https://bugs.webkit.org/show_bug.cgi?id=159289

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

Source/JavaScriptCore:

  • runtime/DatePrototype.cpp:

(JSC::dateProtoFuncSetYear):

LayoutTests:

  • js/date-timeClip-large-values-expected.txt:
  • js/script-tests/date-timeClip-large-values.js:

The failures are caused by bugs related to GregorianDateTime.
The last test case is the one covering this patch.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202682 r202683  
     12016-06-30  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Date.setYear() misses timeClip()
     4        https://bugs.webkit.org/show_bug.cgi?id=159289
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * js/date-timeClip-large-values-expected.txt:
     9        * js/script-tests/date-timeClip-large-values.js:
     10        The failures are caused by bugs related to GregorianDateTime.
     11        The last test case is the one covering this patch.
     12
    1132016-06-30  Commit Queue  <commit-queue@webkit.org>
    214
  • trunk/LayoutTests/js/date-timeClip-large-values-expected.txt

    r201586 r202683  
    5151PASS new Date(8.64e15).setMonth(new Date(8.64e15).getMonth()).valueOf() is 8.64e15
    5252PASS new Date(8.64e15).setMonth(new Date(8.64e15).getMonth() + 1).valueOf() is NaN
     53Testing setYear()
     54PASS new Date(0).setYear(Infinity).valueOf() is NaN
     55FAIL new Date(0).setYear(1.79769e+308).valueOf() should be NaN. Was -62135596800000.
     56FAIL new Date(0).setYear(-1.79769e+308).valueOf() should be NaN. Was -62135596800000.
     57PASS new Date(8.64e15).setYear(new Date(8.64e15).getFullYear()).valueOf() is 8.64e15
     58PASS new Date(8.64e15).setYear(new Date(8.64e15).getFullYear() + 1).valueOf() is NaN
    5359Testing setFullYear()
    5460PASS new Date(0).setFullYear(Infinity).valueOf() is NaN
  • trunk/LayoutTests/js/script-tests/date-timeClip-large-values.js

    r201586 r202683  
    5454shouldBe("new Date(8.64e15).setMonth(new Date(8.64e15).getMonth()).valueOf()", "8.64e15");
    5555shouldBe("new Date(8.64e15).setMonth(new Date(8.64e15).getMonth() + 1).valueOf()", "NaN");
     56
     57debug("Testing setYear()");
     58shouldBe("new Date(0).setYear(Infinity).valueOf()", "NaN");
     59shouldBe("new Date(0).setYear(1.79769e+308).valueOf()", "NaN");
     60shouldBe("new Date(0).setYear(-1.79769e+308).valueOf()", "NaN");
     61shouldBe("new Date(8.64e15).setYear(new Date(8.64e15).getFullYear()).valueOf()", "8.64e15");
     62shouldBe("new Date(8.64e15).setYear(new Date(8.64e15).getFullYear() + 1).valueOf()", "NaN");
    5663
    5764debug("Testing setFullYear()");
  • trunk/Source/JavaScriptCore/ChangeLog

    r202680 r202683  
     12016-06-30  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Date.setYear() misses timeClip()
     4        https://bugs.webkit.org/show_bug.cgi?id=159289
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * runtime/DatePrototype.cpp:
     9        (JSC::dateProtoFuncSetYear):
     10
    1112016-06-30  Joseph Pecoraro  <pecoraro@apple.com> and Yusuke Suzuki  <utatane.tea@gmail.com>
    212
  • trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp

    r201586 r202683  
    10751075
    10761076    gregorianDateTime.setYear(toInt32((year >= 0 && year <= 99) ? (year + 1900) : year));
    1077     JSValue result = jsNumber(gregorianDateTimeToMS(vm, gregorianDateTime, ms, WTF::LocalTime));
     1077    double timeInMilliseconds = gregorianDateTimeToMS(vm, gregorianDateTime, ms, WTF::LocalTime);
     1078    JSValue result = jsNumber(timeClip(timeInMilliseconds));
    10781079    thisDateObj->setInternalValue(vm, result);
    10791080    return JSValue::encode(result);
Note: See TracChangeset for help on using the changeset viewer.