// Multiple debuggers get their job queues drained after each hook. // This covers: // - onDebuggerStatement // - onStep // - onEnterFrame // - onPop // - onExceptionUnwind // - breakpoint handlers // - uncaughtExceptionHook
const g = newGlobal({ newCompartment: true });
g.parent = this;
var log = '';
let expected_throws = 0;
function setup(global, label) { const dbg = new Debugger;
dbg.gDO = dbg.addDebuggee(global);
dbg.log = '';
dbg.onDebuggerStatement = function (frame) { // Exercise the promise machinery: resolve a promise and perform a microtask // checkpoint. When called from a debugger hook, the debuggee's microtasks // should not run. function exercise(name) {
dbg.log += name + ',';
log += `${label}-${name}-handler\n`;
Promise.resolve(42).then(v => {
assertEq(v, 42);
log += `${label}-${name}-tail\n`;
});
}
exercise('debugger');
frame.onStep = function () { this.onStep = undefined;
exercise('step');
};
// Set a breakpoint on entry to g.breakpoint_here. const script = dbg.gDO.getOwnPropertyDescriptor('breakpoint_here').value.script; const handler = {
hit(frame) {
script.clearAllBreakpoints();
exercise('bp');
}
};
script.setBreakpoint(0, handler);
dbg.uncaughtExceptionHook = function (ex) {
assertEq(ex, 'turncoat');
exercise('uncaught');
};
// Throw an uncaught exception from the Debugger handler. This should reach // uncaughtExceptionHook, but shouldn't affect the debuggee. throw'turncoat';
};
g.eval(` function breakpoint_here() { throw'myrmidon';
}
parent.log += 'eval-start\\n';
// DebuggeeWouldRun detection may prevent this callback from running at all if // bug 1145201 is present. SpiderMonkey will try to run the promise reaction // job from the Debugger hook's microtask checkpoint, triggering // DebuggeeWouldRun. This is a little difficult to observe, since the callback // never even begins execution. But it should cause the 'then' promise to be // rejected, which the shell will report (if the assertEq(log, ...) doesn't // kill the test first).
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.