Skip to content

Instantly share code, notes, and snippets.

@fflorent
Created December 30, 2013 16:48
Show Gist options
  • Save fflorent/8184572 to your computer and use it in GitHub Desktop.
Save fflorent/8184572 to your computer and use it in GitHub Desktop.
Failing test case of Debugger.Frame.onPop when the execution of a frame is about to end (i.e. when the return value is displayed in the DevTools or in Firebug + JSD2)
/*
Failing test case:
1. Open this page: https://getfirebug.com/tests/head/script/4213/issue4213.html
2. With the DevTools, set a breakpoint at line 4 of issue4213-1.js (in myFunc1)
3. Click on the "Execute Test" button of the webpage
|=> the breakpoint is hit
4. Step over
|=> the return value is displayed
5. Run this in Scratchpad (environment = browser)
6. Resume the execution
Working test case: same as above without step 4.
*/
var dbgMap = new WeakMap();
var getDebugger = function(wrappedWin = gBrowser.selectedBrowser.contentWindow)
{
try
{
var jsDebugger = {};
Cu.import("resource://gre/modules/jsdebugger.jsm", jsDebugger);
var global = Cu.getGlobalForObject({});
jsDebugger.addDebuggerToGlobal(global);
var dbg = new global.Debugger();
var win = XPCNativeWrapper.unwrap(wrappedWin);
dbg.addDebuggee(win);
if (dbgMap.has(win))
return dbgMap.get(win);
// Register 'onNewGlobalObject' hook to append dynamically created iframes
// into the debugger as debuggees.
dbg.onNewGlobalObject = function(global)
{
// xxxHonza: use timeout to avoid crash, see:
// https://bugzilla.mozilla.org/show_bug.cgi?id=885301
setTimeout(addNewDebuggee.bind(this, dbg, win, global));
}
dbgMap.set(win, dbg);
return dbg;
}
catch (err)
{
alert(err);
}
};
var dbg = getDebugger();
var frame = dbg.getNewestFrame();
frame.onPop = frame.onResume = frame.onStep = function()
{
return frame.eval("42");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment