Bug 649575 - Date.prototype.toISOString must throw a RangeError for non-finite dates. r=jwalden

This commit is contained in:
Tom Schuster
2011-04-22 22:46:59 -04:00
parent ddfad4a7db
commit 12cae3c23a
5 changed files with 56 additions and 16 deletions

View File

@@ -2047,10 +2047,16 @@ date_utc_format(JSContext *cx, Value *vp,
return false;
char buf[100];
if (!JSDOUBLE_IS_FINITE(utctime))
if (!JSDOUBLE_IS_FINITE(utctime)) {
if (printFunc == print_iso_string) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INVALID_DATE);
return false;
}
JS_snprintf(buf, sizeof buf, js_NaN_date_str);
else
} else {
(*printFunc)(buf, sizeof buf, utctime);
}
JSString *str = JS_NewStringCopyZ(cx, buf);
if (!str)