Fix getYoungestFrame to get the newest frame even if it is in another cx.
☠☠ backed out by 215d305502a7 ☠ ☠
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 02 Jun 2011 22:21:13 -0500
changeset 74463 720b3fe3c84efd6336c37451d7cc8e357a5931db
parent 74462 d02083014f57890a0e9977094ff51625e9ead9a6
child 74464 215d305502a77fcb2bd9772d692745bea7eeb71c
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone6.0a1
Fix getYoungestFrame to get the newest frame even if it is in another cx.
js/src/jsdbg.cpp
--- a/js/src/jsdbg.cpp
+++ b/js/src/jsdbg.cpp
@@ -853,24 +853,25 @@ Debug::getDebuggees(JSContext *cx, uintN
     vp->setObject(*arrobj);
     return true;
 }
 
 JSBool
 Debug::getYoungestFrame(JSContext *cx, uintN argc, Value *vp)
 {
     THISOBJ(cx, vp, Debug, "getYoungestFrame", thisobj, dbg);
-    StackFrame *fp = cx->fp();
-    while (fp && !dbg->observesFrame(fp))
-        fp = fp->prev();
-    if (!fp) {
-        vp->setNull();
-        return true;
+
+    // cx->fp() would return the topmost frame in the current context.
+    // Since there may be multiple contexts, use AllFramesIter instead.
+    for (AllFramesIter i(cx); !i.done(); ++i) {
+        if (dbg->observesFrame(i.fp()))
+            return dbg->getScriptFrame(cx, i.fp(), vp);
     }
-    return dbg->getScriptFrame(cx, fp, vp);
+    vp->setNull();
+    return true;
 }
 
 JSBool
 Debug::construct(JSContext *cx, uintN argc, Value *vp)
 {
     // Check that the arguments, if any, are cross-compartment wrappers.
     Value *argv = vp + 2, *argvEnd = argv + argc;
     for (Value *p = argv; p != argvEnd; p++) {