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}
This commit is contained in:
parent
fe728e52b4
commit
02503b080f
@ -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; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user