Commit 02503b08 authored by yangguo's avatar yangguo Committed by Commit bot

Make stack property collected by captureStackTrace non-enumerable and -writable.

TBR=jgruber@chromium.org

Review-Url: https://codereview.chromium.org/2177183002
Cr-Commit-Position: refs/heads/master@{#38005}
parent fe728e52
......@@ -50,11 +50,15 @@ BUILTIN(ErrorCaptureStackTrace) {
isolate, formatted_stack_trace,
FormatStackTrace(isolate, object, stack_trace));
RETURN_FAILURE_ON_EXCEPTION(
isolate, JSObject::SetProperty(object, isolate->factory()->stack_string(),
formatted_stack_trace, STRICT));
return *isolate->factory()->undefined_value();
PropertyDescriptor desc;
desc.set_configurable(true);
desc.set_value(formatted_stack_trace);
Maybe<bool> status = JSReceiver::DefineOwnProperty(
isolate, object, isolate->factory()->stack_string(), &desc,
Object::THROW_ON_ERROR);
if (!status.IsJust()) return isolate->heap()->exception();
CHECK(status.FromJust());
return isolate->heap()->undefined_value();
}
namespace {
......
......@@ -381,6 +381,15 @@ assertEquals(undefined, error.stack);
error = new Error();
Error.captureStackTrace(error);
// Check property descriptor.
var o = {};
Error.captureStackTrace(o);
assertEquals([], Object.keys(o));
var desc = Object.getOwnPropertyDescriptor(o, "stack");
assertFalse(desc.writable);
assertFalse(desc.enumerable);
assertTrue(desc.configurable);
// Check that exceptions thrown within prepareStackTrace throws an exception.
Error.prepareStackTrace = function(e, frames) { throw 42; }
......
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