d766d6d5a3
An error object's 'stack' property is lazily formatted once the property is first read. It is thus possible that lazy formatting happens in a different realm than where the error object was constructed. In this case, we should use the origin-realm's prepareStackTrace function to format the stack trace. This CL implements that behavior by fetching prepareStackTrace from the given error object's context's error function. Bug: v8:7848 Change-Id: Ibc383cf24f2c0dab2fd8bb7bc740f1488d9954a5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1113438 Commit-Queue: Simon Zünd <szuend@chromium.org> Auto-Submit: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#62090}
27 lines
867 B
JavaScript
27 lines
867 B
JavaScript
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Should never be called in this test.
|
|
Error.prepareStackTrace = () => 299792458;
|
|
|
|
{
|
|
const that_realm = Realm.create();
|
|
const result = Realm.eval(that_realm,
|
|
"() => { Error.prepareStackTrace = () => 42; return new Error(); }")();
|
|
assertEquals(42, result.stack);
|
|
}
|
|
{
|
|
const that_realm = Realm.create();
|
|
const result = Realm.eval(that_realm,
|
|
"() => { Error.prepareStackTrace = () => 42; " +
|
|
"class MyError extends Error {}; return new MyError(); }")();
|
|
assertEquals(42, result.stack);
|
|
}
|
|
{
|
|
const that_realm = Realm.create();
|
|
const result = Realm.eval(that_realm,
|
|
"() => { Error.prepareStackTrace = () => 42; return {}; }")();
|
|
assertFalse("stack" in result);
|
|
}
|