Bug 1304551 - Properly handle bound functions in getBacktrace. r?efaust
getBacktrace, when invoked with `{locals:true}`, prints the `this` value for each frame, where applicable. When constructing bound functions, the `this` value is magic, which FormatFrame doesn't handle. Since printing that `this` value isn't useful, we just skip it.
MozReview-Commit-ID: 8axhOqyrA2B
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/self-hosting/get-backtrace-in-constructing-bound-function.js
@@ -0,0 +1,6 @@
+function t() {
+ getBacktrace({ locals: true });
+}
+var f = t.bind();
+new f();
+f();
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -792,17 +792,18 @@ FormatFrame(JSContext* cx, const FrameIt
RootedFunction fun(cx, iter.maybeCallee(cx));
RootedString funname(cx);
if (fun)
funname = fun->displayAtom();
RootedValue thisVal(cx);
if (iter.hasUsableAbstractFramePtr() &&
iter.isFunctionFrame() &&
- fun && !fun->isArrow() && !fun->isDerivedClassConstructor())
+ fun && !fun->isArrow() && !fun->isDerivedClassConstructor() &&
+ !(fun->isBoundFunction() && iter.isConstructing()))
{
if (!GetFunctionThis(cx, iter.abstractFramePtr(), &thisVal))
return nullptr;
}
// print the frame number and function name
if (funname) {
JSAutoByteString funbytes;