https://bugs.webkit.org/show_bug.cgi?id=141115
Patch by Jordan Harband <ljharb@gmail.com> on 2015-07-19
Reviewed by Yusuke Suzuki.
Source/JavaScriptCore:
* runtime/DatePrototype.cpp:
(JSC::dateProtoFuncToJSON):
LayoutTests:
* js/dom/JSON-stringify-expected.txt:
* js/resources/JSON-stringify.js:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187016
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-07-19 Jordan Harband <ljharb@gmail.com>
+
+ new Date(NaN).toJSON() must return null instead of throwing a TypeError
+ https://bugs.webkit.org/show_bug.cgi?id=141115
+
+ Reviewed by Yusuke Suzuki.
+
+ * js/dom/JSON-stringify-expected.txt:
+ * js/resources/JSON-stringify.js:
+
2015-07-19 Saam barati <saambarati1@gmail.com>
Parser::parseFunctionInfo hits RELEASE_ASSERT for Arrow Functions
}
PASS tests[i](nativeJSON) threw exception An exception.
function (jsonObject){
+ return jsonObject.stringify(new Date(NaN));
+ }
+PASS tests[i](nativeJSON) is tests[i].expected
+function (jsonObject){
var d = new Date(0);
d.toISOString = null;
return jsonObject.stringify(d);
});
result[result.length - 1].throws = true;
result.push(function(jsonObject){
+ return jsonObject.stringify(new Date(NaN));
+ });
+ result[result.length - 1].expected = 'null';;
+ result.push(function(jsonObject){
var d = new Date(0);
d.toISOString = null;
return jsonObject.stringify(d);
+2015-07-19 Jordan Harband <ljharb@gmail.com>
+
+ new Date(NaN).toJSON() must return null instead of throwing a TypeError
+ https://bugs.webkit.org/show_bug.cgi?id=141115
+
+ Reviewed by Yusuke Suzuki.
+
+ * runtime/DatePrototype.cpp:
+ (JSC::dateProtoFuncToJSON):
+
2015-07-19 Saam barati <saambarati1@gmail.com>
Parser::parseFunctionInfo hits RELEASE_ASSERT for Arrow Functions
JSObject* object = jsCast<JSObject*>(thisValue.toThis(exec, NotStrictMode));
if (exec->hadException())
return JSValue::encode(jsNull());
-
+
+ JSValue timeValue = object->toPrimitive(exec, PreferNumber);
+ if (exec->hadException())
+ return JSValue::encode(jsNull());
+ if (timeValue.isNumber() && !(timeValue.isInt32() || std::isfinite(timeValue.asDouble())))
+ return JSValue::encode(jsNull());
+
JSValue toISOValue = object->get(exec, exec->vm().propertyNames->toISOString);
if (exec->hadException())
return JSValue::encode(jsNull());