Commit 584386a2 authored by verwaest's avatar verwaest Committed by Commit bot

Make sure only toStringTag is used for Object.prototype.toString with JSON / Math

BUG=

Review-Url: https://codereview.chromium.org/1992153002
Cr-Commit-Position: refs/heads/master@{#36393}
parent e17c68c4
...@@ -1587,7 +1587,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1587,7 +1587,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> cons = factory->NewFunction(name); Handle<JSFunction> cons = factory->NewFunction(name);
JSFunction::SetInstancePrototype(cons, JSFunction::SetInstancePrototype(cons,
Handle<Object>(native_context()->initial_object_prototype(), isolate)); Handle<Object>(native_context()->initial_object_prototype(), isolate));
cons->shared()->set_instance_class_name(*name);
Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
DCHECK(json_object->IsJSObject()); DCHECK(json_object->IsJSObject());
JSObject::AddProperty(global, name, json_object, DONT_ENUM); JSObject::AddProperty(global, name, json_object, DONT_ENUM);
...@@ -1599,7 +1598,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1599,7 +1598,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
JSFunction::SetInstancePrototype( JSFunction::SetInstancePrototype(
cons, cons,
Handle<Object>(native_context()->initial_object_prototype(), isolate)); Handle<Object>(native_context()->initial_object_prototype(), isolate));
cons->shared()->set_instance_class_name(*name);
Handle<JSObject> math = factory->NewJSObject(cons, TENURED); Handle<JSObject> math = factory->NewJSObject(cons, TENURED);
DCHECK(math->IsJSObject()); DCHECK(math->IsJSObject());
JSObject::AddProperty(global, name, math, DONT_ENUM); JSObject::AddProperty(global, name, math, DONT_ENUM);
......
...@@ -9,5 +9,7 @@ function testJSONToString() { ...@@ -9,5 +9,7 @@ function testJSONToString() {
assertTrue(desc.configurable); assertTrue(desc.configurable);
assertFalse(desc.writable); assertFalse(desc.writable);
assertEquals("JSON", desc.value); assertEquals("JSON", desc.value);
delete JSON[Symbol.toStringTag];
assertEquals('[object Object]', "" + JSON);
} }
testJSONToString(); testJSONToString();
...@@ -9,5 +9,7 @@ function testMathToString() { ...@@ -9,5 +9,7 @@ function testMathToString() {
assertTrue(desc.configurable); assertTrue(desc.configurable);
assertFalse(desc.writable); assertFalse(desc.writable);
assertEquals("Math", desc.value); assertEquals("Math", desc.value);
delete Math[Symbol.toStringTag];
assertEquals('[object Object]', "" + Math);
} }
testMathToString(); testMathToString();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment