v8/test/mjsunit/regress/regress-4640.js
littledan a9c791009b Fix 'illegal access' in Date constructor edge case
In a rare edge case, a difference in checks between C++ and
JavaScript lead to an 'illegal access' being thrown by the Date
constructor. This patch harmonizes the checks from both sides.
It's possible that slightly larger dates could be permitted,
as the ECMAScript 2015 specification indicates that +287396-10-12
would be a permissible date in the note in
http://tc39.github.io/ecma262/#sec-extended-years
This patch does not revisit the limit, only clears up the
inconsistency.

BUG=v8:4640
R=cbruni
LOG=Y

Review URL: https://codereview.chromium.org/1545883003

Cr-Commit-Position: refs/heads/master@{#33068}
2015-12-30 23:54:59 +00:00

20 lines
900 B
JavaScript

// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Some surrounding cases which already worked, for good measure
assertTrue(new Date('275760-10-14') == 'Invalid Date');
assertTrue(new Date('275760-09-23') == 'Invalid Date');
assertTrue(new Date('+275760-09-24') == 'Invalid Date');
assertTrue(new Date('+275760-10-13') == 'Invalid Date');
// The following cases used to throw "illegal access"
assertTrue(new Date('275760-09-24') == 'Invalid Date');
assertTrue(new Date('275760-10-13') == 'Invalid Date');
assertTrue(new Date('+275760-10-13 ') == 'Invalid Date');
// However, dates within the range or valid
assertTrue(new Date('100000-10-13') != 'Invalid Date');
assertTrue(new Date('+100000-10-13') != 'Invalid Date');
assertTrue(new Date('+100000-10-13 ') != 'Invalid Date');