Bug 70998
Summary: | Date constructor handles infinite values incorrectly. | ||
---|---|---|---|
Product: | WebKit | Reporter: | mstarzinger |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | ap, barraclough, oliver, sam |
Priority: | P2 | Keywords: | EasyFix |
Version: | 528+ (Nightly build) | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Bug Depends on: | 75692 | ||
Bug Blocks: |
mstarzinger
For cases in which the time value of a Date object is not a finite number, Date.prototype.toISOString() should throw a RangeError exception. This can either be reproduced by several Test262 test cases (i.e. 15.9.5.43-0-*) or with the following JavaScript snippet.
function test() {
var date = new Date(Infinity, 1, 70, 0, 0, 0);
try {
date.toISOString();
return false;
} catch (e) {
return e instanceof RangeError;
}
}
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Alexey Proskuryakov
Sounds much like bug 70394, but still happens in ToT.
Sam Weinig
(In reply to comment #1)
> Sounds much like bug 70394, but still happens in ToT.
It is a different code path due to the Data constructor having different defined behavior when passing one argument, and two or more.
Gavin Barraclough
To clarify Sam's comment, the issue re RangeErrors was fixed last week, in bug #70394 - the bug here is different.
The problem is not in toISOString, but rather in the call to new Date. The test case assumes that the newly constructed Date has a NaN internal value; the bug is that it does not. You can demonstrate that toISOString behaved correctly by changing the arguments to new Date to ("") (which does correctly produce a Date with a NaN internal value).
Retitling the bug accordingly.
Gavin Barraclough
Fixed in r104267