v8/test/mjsunit/stack-traces-custom.js
adamk 045fa997b7 Handle ES2015 Function.name in CallSite::GetMethodName
CallSite depends on using the function name to get ahold of the property
name from which an exception was thrown. This fix properly handles the
ES2015 names for getters and setters. The new tests pass both with
--harmony-function-name off and on.

BUG=v8:3699
LOG=n

Review URL: https://codereview.chromium.org/1751403004

Cr-Commit-Position: refs/heads/master@{#34469}
2016-03-03 20:19:41 +00:00

27 lines
789 B
JavaScript

// Copyright 2015 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.
var o = {
f: function() { throw new Error(); },
get j() { o.h(); },
set k(_) { o.j; },
};
o.g1 = function() { o.f() }
o.g2 = o.g1;
o.h = function() { o.g1() }
try {
o.k = 42;
} catch (e) {
Error.prepareStackTrace = function(e, frames) { return frames; };
var frames = e.stack;
Error.prepareStackTrace = undefined;
assertEquals("f", frames[0].getMethodName());
assertEquals(null, frames[1].getMethodName());
assertEquals("h", frames[2].getMethodName());
assertEquals("j", frames[3].getMethodName());
assertEquals("k", frames[4].getMethodName());
assertEquals(null, frames[5].getMethodName());
}