I found some way that might be useful. It uses the idea of callbacks.
Define the following simple function in each frame:
function getCaller() { return arguments.callee.caller; }
and the following functions for the top frame only:
function populateStack(fn) { var perFrames = []; for (var i = 0; i < windows.length; i++) { var win = windows[i]; var func = (win == this) ? fn : win.getCaller(); var localStack = []; while (func) { localStack.push(getFuncName(func)); func = func.caller; } perFrames.push(getWinName(win) + ": " + localStack.join(", ")); } alert(perFrames.join("\n")); } function getWinName(win) { var m = win.location.toString().match(/^.*\/(.*)$/); return m[1]; } function getFuncName(func) { var m = func.toString().match(/^function\s*(\w*)\(/); return m[1] || "anonymous"; }
windows should be an array in the top frame containing all window objects (i.e. frames). Using:
window.top.populateStack.call(window, arguments.callee);
I spent a couple of hours trying to restore the exact order in which the functions were called, but could not find a solution. Only partial order is available in this code (functions are correctly sorted within frames).
If you have several servers with different versions of the code, you can add code that will analyze the function bodies and through this get additional information about the call order.
Hope this helps :-)
kirilloid
source share