haikuwebkit/LayoutTests/js/date-timeClip-large-values-...

112 lines
6.6 KiB
Plaintext
Raw Permalink Normal View History

[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. Canonical link: https://commits.webkit.org/176373@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201586 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-02 03:34:31 +00:00
Verify that changing a date with a delta that is too large for a date produces an invalid date/NaN
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Testing date creating at the max boundary
PASS new Date(0).valueOf() is 0
PASS new Date(8.64e15) instanceof Date is true
PASS new Date(8.64e15).valueOf() is 8.64e15
PASS new Date(8640000000000001) instanceof Date is true
PASS new Date(8640000000000001).valueOf() is NaN
PASS new Date(Infinity) instanceof Date is true
PASS new Date(Infinity).valueOf() is NaN
PASS new Date(-Infinity) instanceof Date is true
PASS new Date(-Infinity).valueOf() is NaN
Testing setMilliseconds()
PASS new Date(0).setMilliseconds(Infinity).valueOf() is NaN
PASS new Date(0).setMilliseconds(1.79769e+308).valueOf() is NaN
PASS new Date(0).setMilliseconds(-1.79769e+308).valueOf() is NaN
PASS new Date(8.64e15).setMilliseconds(new Date(8.64e15).getMilliseconds()).valueOf() is 8.64e15
PASS new Date(8.64e15).setMilliseconds(new Date(8.64e15).getMilliseconds() + 1).valueOf() is NaN
Testing setSeconds()
PASS new Date(0).setSeconds(Infinity).valueOf() is NaN
PASS new Date(0).setSeconds(1.79769e+308).valueOf() is NaN
PASS new Date(0).setSeconds(-1.79769e+308).valueOf() is NaN
PASS new Date(8.64e15).setSeconds(new Date(8.64e15).getSeconds()).valueOf() is 8.64e15
PASS new Date(8.64e15).setSeconds(new Date(8.64e15).getSeconds() + 1).valueOf() is NaN
Testing setMinutes()
PASS new Date(0).setMinutes(Infinity).valueOf() is NaN
PASS new Date(0).setMinutes(1.79769e+308).valueOf() is NaN
PASS new Date(0).setMinutes(-1.79769e+308).valueOf() is NaN
PASS new Date(8.64e15).setMinutes(new Date(8.64e15).getMinutes()).valueOf() is 8.64e15
PASS new Date(8.64e15).setMinutes(new Date(8.64e15).getMinutes() + 1).valueOf() is NaN
Testing setHours()
PASS new Date(0).setHours(Infinity).valueOf() is NaN
PASS new Date(0).setHours(1.79769e+308).valueOf() is NaN
PASS new Date(0).setHours(-1.79769e+308).valueOf() is NaN
PASS new Date(8.64e15).setHours(new Date(8.64e15).getHours()).valueOf() is 8.64e15
PASS new Date(8.64e15).setHours(new Date(8.64e15).getHours() + 1).valueOf() is NaN
Testing setDate()
PASS new Date(0).setDate(Infinity).valueOf() is NaN
PASS new Date(0).setDate(1.79769e+308).valueOf() is NaN
PASS new Date(0).setDate(-1.79769e+308).valueOf() is NaN
PASS new Date(0).setDate(9e15 / (24 * 60 * 60 * 1000)).valueOf() is NaN
PASS new Date(8.64e15).setDate(new Date(8.64e15).getDate()).valueOf() is 8.64e15
PASS new Date(8.64e15).setDate(new Date(8.64e15).getDate() + 1).valueOf() is NaN
Testing setMonth()
PASS new Date(0).setMonth(Infinity).valueOf() is NaN
FAIL new Date(0).setMonth(1.79769e+308).valueOf() should be NaN. Was -28857600000.
FAIL new Date(0).setMonth(-1.79769e+308).valueOf() should be NaN. Was -28857600000.
PASS new Date(8.64e15).setMonth(new Date(8.64e15).getMonth()).valueOf() is 8.64e15
PASS new Date(8.64e15).setMonth(new Date(8.64e15).getMonth() + 1).valueOf() is NaN
Testing setYear()
PASS new Date(0).setYear(Infinity).valueOf() is NaN
FAIL new Date(0).setYear(1.79769e+308).valueOf() should be NaN. Was -62135597222000.
FAIL new Date(0).setYear(-1.79769e+308).valueOf() should be NaN. Was -62135597222000.
PASS new Date(8.64e15).setYear(new Date(8.64e15).getFullYear()).valueOf() is 8.64e15
PASS new Date(8.64e15).setYear(new Date(8.64e15).getFullYear() + 1).valueOf() is NaN
[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. Canonical link: https://commits.webkit.org/176373@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201586 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-02 03:34:31 +00:00
Testing setFullYear()
PASS new Date(0).setFullYear(Infinity).valueOf() is NaN
FAIL new Date(0).setFullYear(1.79769e+308).valueOf() should be NaN. Was -62135597222000.
FAIL new Date(0).setFullYear(-1.79769e+308).valueOf() should be NaN. Was -62135597222000.
[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. Canonical link: https://commits.webkit.org/176373@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201586 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-02 03:34:31 +00:00
PASS new Date(8.64e15).setFullYear(new Date(8.64e15).getFullYear()).valueOf() is 8.64e15
PASS new Date(8.64e15).setFullYear(new Date(8.64e15).getFullYear() + 1).valueOf() is NaN
Testing setUTCMilliseconds()
PASS new Date(0).setUTCMilliseconds(Infinity).valueOf() is NaN
PASS new Date(0).setUTCMilliseconds(1.79769e+308).valueOf() is NaN
PASS new Date(0).setUTCMilliseconds(-1.79769e+308).valueOf() is NaN
PASS new Date(8.64e15).setUTCMilliseconds(new Date(8.64e15).getUTCMilliseconds()).valueOf() is 8.64e15
PASS new Date(8.64e15).setUTCMilliseconds(new Date(8.64e15).getUTCMilliseconds() + 1).valueOf() is NaN
Testing setUTCSeconds()
PASS new Date(0).setUTCSeconds(Infinity).valueOf() is NaN
PASS new Date(0).setUTCSeconds(1.79769e+308).valueOf() is NaN
PASS new Date(0).setUTCSeconds(-1.79769e+308).valueOf() is NaN
PASS new Date(8.64e15).setUTCSeconds(new Date(8.64e15).getUTCSeconds()).valueOf() is 8.64e15
PASS new Date(8.64e15).setUTCSeconds(new Date(8.64e15).getUTCSeconds() + 1).valueOf() is NaN
Testing setUTCMinutes()
PASS new Date(0).setUTCMinutes(Infinity).valueOf() is NaN
PASS new Date(0).setUTCMinutes(1.79769e+308).valueOf() is NaN
PASS new Date(0).setUTCMinutes(-1.79769e+308).valueOf() is NaN
PASS new Date(8.64e15).setUTCMinutes(new Date(8.64e15).getUTCMinutes()).valueOf() is 8.64e15
PASS new Date(8.64e15).setUTCMinutes(new Date(8.64e15).getUTCMinutes() + 1).valueOf() is NaN
Testing setUTCHours()
PASS new Date(0).setUTCHours(Infinity).valueOf() is NaN
PASS new Date(0).setUTCHours(1.79769e+308).valueOf() is NaN
PASS new Date(0).setUTCHours(-1.79769e+308).valueOf() is NaN
PASS new Date(8.64e15).setUTCHours(new Date(8.64e15).getUTCHours()).valueOf() is 8.64e15
PASS new Date(8.64e15).setUTCHours(new Date(8.64e15).getUTCHours() + 1).valueOf() is NaN
Testing setUTCDate()
PASS new Date(0).setUTCDate(Infinity).valueOf() is NaN
PASS new Date(0).setUTCDate(1.79769e+308).valueOf() is NaN
PASS new Date(0).setUTCDate(-1.79769e+308).valueOf() is NaN
PASS new Date(0).setUTCDate(9e15 / (24 * 60 * 60 * 1000)).valueOf() is NaN
PASS new Date(8.64e15).setUTCDate(new Date(8.64e15).getUTCDate()).valueOf() is 8.64e15
PASS new Date(8.64e15).setUTCDate(new Date(8.64e15).getUTCDate() + 1).valueOf() is NaN
Testing setUTCMonth()
PASS new Date(0).setUTCMonth(Infinity).valueOf() is NaN
FAIL new Date(0).setUTCMonth(1.79769e+308).valueOf() should be NaN. Was 0.
FAIL new Date(0).setUTCMonth(-1.79769e+308).valueOf() should be NaN. Was 0.
PASS new Date(8.64e15).setUTCMonth(new Date(8.64e15).getUTCMonth()).valueOf() is 8.64e15
PASS new Date(8.64e15).setUTCMonth(new Date(8.64e15).getUTCMonth() + 1).valueOf() is NaN
Testing setUTCFullYear()
PASS new Date(0).setUTCFullYear(Infinity).valueOf() is NaN
FAIL new Date(0).setUTCFullYear(1.79769e+308).valueOf() should be NaN. Was -62167219200000.
FAIL new Date(0).setUTCFullYear(-1.79769e+308).valueOf() should be NaN. Was -62167219200000.
PASS new Date(8.64e15).setUTCFullYear(new Date(8.64e15).getUTCFullYear()).valueOf() is 8.64e15
PASS new Date(8.64e15).setUTCFullYear(new Date(8.64e15).getUTCFullYear() + 1).valueOf() is NaN
PASS successfullyParsed is true
TEST COMPLETE