Title: [187016] trunk
- Revision
- 187016
- Author
- [email protected]
- Date
- 2015-07-19 16:10:07 -0700 (Sun, 19 Jul 2015)
Log Message
new Date(NaN).toJSON() must return null instead of throwing a TypeError
https://bugs.webkit.org/show_bug.cgi?id=141115
Patch by Jordan Harband <[email protected]> on 2015-07-19
Reviewed by Yusuke Suzuki.
Source/_javascript_Core:
* runtime/DatePrototype.cpp:
(JSC::dateProtoFuncToJSON):
LayoutTests:
* js/dom/JSON-stringify-expected.txt:
* js/resources/JSON-stringify.js:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (187015 => 187016)
--- trunk/LayoutTests/ChangeLog 2015-07-19 22:27:00 UTC (rev 187015)
+++ trunk/LayoutTests/ChangeLog 2015-07-19 23:10:07 UTC (rev 187016)
@@ -1,3 +1,13 @@
+2015-07-19 Jordan Harband <[email protected]>
+
+ 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 <[email protected]>
Parser::parseFunctionInfo hits RELEASE_ASSERT for Arrow Functions
Modified: trunk/LayoutTests/js/dom/JSON-stringify-expected.txt (187015 => 187016)
--- trunk/LayoutTests/js/dom/JSON-stringify-expected.txt 2015-07-19 22:27:00 UTC (rev 187015)
+++ trunk/LayoutTests/js/dom/JSON-stringify-expected.txt 2015-07-19 23:10:07 UTC (rev 187016)
@@ -97,6 +97,10 @@
}
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);
Modified: trunk/LayoutTests/js/resources/JSON-stringify.js (187015 => 187016)
--- trunk/LayoutTests/js/resources/JSON-stringify.js 2015-07-19 22:27:00 UTC (rev 187015)
+++ trunk/LayoutTests/js/resources/JSON-stringify.js 2015-07-19 23:10:07 UTC (rev 187016)
@@ -101,6 +101,10 @@
});
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);
Modified: trunk/Source/_javascript_Core/ChangeLog (187015 => 187016)
--- trunk/Source/_javascript_Core/ChangeLog 2015-07-19 22:27:00 UTC (rev 187015)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-07-19 23:10:07 UTC (rev 187016)
@@ -1,3 +1,13 @@
+2015-07-19 Jordan Harband <[email protected]>
+
+ 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 <[email protected]>
Parser::parseFunctionInfo hits RELEASE_ASSERT for Arrow Functions
Modified: trunk/Source/_javascript_Core/runtime/DatePrototype.cpp (187015 => 187016)
--- trunk/Source/_javascript_Core/runtime/DatePrototype.cpp 2015-07-19 22:27:00 UTC (rev 187015)
+++ trunk/Source/_javascript_Core/runtime/DatePrototype.cpp 2015-07-19 23:10:07 UTC (rev 187016)
@@ -1072,7 +1072,13 @@
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());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes