diff --git a/js/src/debugger/Frame.cpp b/js/src/debugger/Frame.cpp index 617a45678e00..e712711bc1b0 100644 --- a/js/src/debugger/Frame.cpp +++ b/js/src/debugger/Frame.cpp @@ -1042,8 +1042,6 @@ OnPopHandler* DebuggerFrame::onPopHandler() const { } void DebuggerFrame::setOnPopHandler(JSContext* cx, OnPopHandler* handler) { - MOZ_ASSERT(isLive()); - OnPopHandler* prior = onPopHandler(); if (handler == prior) { return; @@ -1232,7 +1230,9 @@ bool DebuggerFrame::CallData::ToNative(JSContext* cx, unsigned argc, // These methods do not require liveness. bool checkLive = MyMethod != &CallData::liveGetter && MyMethod != &CallData::onStepGetter && - MyMethod != &CallData::onStepSetter; + MyMethod != &CallData::onStepSetter && + MyMethod != &CallData::onPopGetter && + MyMethod != &CallData::onPopSetter; RootedDebuggerFrame frame(cx, DebuggerFrame::check(cx, args.thisv(), checkLive)); diff --git a/js/src/jit-test/tests/binast/lazy/debug/Frame-onPop-07.binjs b/js/src/jit-test/tests/binast/lazy/debug/Frame-onPop-07.binjs deleted file mode 100644 index 5b8598bc80e1..000000000000 Binary files a/js/src/jit-test/tests/binast/lazy/debug/Frame-onPop-07.binjs and /dev/null differ diff --git a/js/src/jit-test/tests/binast/nonlazy/debug/Frame-onPop-07.binjs b/js/src/jit-test/tests/binast/nonlazy/debug/Frame-onPop-07.binjs deleted file mode 100644 index 7e6b07c1719d..000000000000 Binary files a/js/src/jit-test/tests/binast/nonlazy/debug/Frame-onPop-07.binjs and /dev/null differ diff --git a/js/src/jit-test/tests/debug/Frame-onPop-07.js b/js/src/jit-test/tests/debug/Frame-onPop-07.js deleted file mode 100644 index bae4553e7b36..000000000000 --- a/js/src/jit-test/tests/debug/Frame-onPop-07.js +++ /dev/null @@ -1,30 +0,0 @@ -// Trying to set an onPop handler on a dead frame throws an exception. -var g = newGlobal({newCompartment: true}); -g.eval("function f() { }"); -g.eval("function g() { f(); }"); -g.eval("function h() { g(); }"); -g.eval("function i() { h(); }"); -var dbg = new Debugger(g); -var log; - -var frames = []; -dbg.onEnterFrame = function handleEnter(f) { - log += "("; - assertEq(f.live, true); - frames.push(f); -}; -log = ''; -g.i(); -assertEq(log, "(((("); -assertEq(frames.length, 4); -for (i = 0; i < frames.length; i++) { - assertEq(frames[i].live, false); - var set = false; - try { - frames[i].onPop = function unappreciated() { }; - set = true; // don't assert in a 'try' block - } catch (x) { - assertEq(x instanceof Error, true); - } - assertEq(set, false); -} diff --git a/js/src/jit-test/tests/debug/Frame-onPop-assign-function.js b/js/src/jit-test/tests/debug/Frame-onPop-assign-function.js new file mode 100644 index 000000000000..f68d2a638b92 --- /dev/null +++ b/js/src/jit-test/tests/debug/Frame-onPop-assign-function.js @@ -0,0 +1,48 @@ +// Changing onPop while the function is dead is allowed. + +load(libdir + "asserts.js"); + +const g = newGlobal({ newCompartment: true }); +const dbg = new Debugger(g); + +let steps = new Set(); +dbg.onDebuggerStatement = function(frame) { + // Setting 'onPop' while alive is allowed. + steps.add("debugger 1"); + assertEq(frame.live, true); + frame.onPop = function() { + steps.add("onpop 1"); + }; + + dbg.onDebuggerStatement = function() { + // Clear the 'onPop' while dead. + steps.add("debugger 2"); + assertEq(frame.live, false); + + // Clearing 'onPop' while dead is allowed. + frame.onPop = undefined; + + // Setting 'onPop' while dead is allowed. + frame.onPop = function() { + steps.add("onpop 2"); + }; + }; +}; + +g.eval( + ` + function myGen() { + debugger; + } + + const g = myGen(); + + debugger; + ` +); + +assertDeepEq(Array.from(steps), [ + "debugger 1", + "onpop 1", + "debugger 2", +]); diff --git a/js/src/jit-test/tests/debug/Frame-onPop-assign-generator.js b/js/src/jit-test/tests/debug/Frame-onPop-assign-generator.js new file mode 100644 index 000000000000..411ac8f58331 --- /dev/null +++ b/js/src/jit-test/tests/debug/Frame-onPop-assign-generator.js @@ -0,0 +1,68 @@ +// Changing onPop while the generator is suspended/dead is allowed. + +load(libdir + "asserts.js"); + +const g = newGlobal({ newCompartment: true }); +const dbg = new Debugger(g); + +let steps = new Set(); +dbg.onDebuggerStatement = function(frame) { + // Setting 'onStep' while alive is allowed. + steps.add("debugger 1"); + assertEq(frame.live, true); + frame.onPop = function() { + steps.add("onpop 1"); + }; + + dbg.onDebuggerStatement = function() { + // Clear the 'onPop' while suspended. + steps.add("debugger 2"); + assertEq(frame.live, false); + + // Clearing 'onPop' while suspended is allowed. + frame.onPop = undefined; + + // Setting 'onPop' while suspended is allowed. + frame.onPop = function() { + steps.add("onpop 2"); + }; + + dbg.onDebuggerStatement = function() { + steps.add("debugger 3"); + assertEq(frame.live, false); + + // Clearing 'onPop' while dead is allowed. + frame.onPop = undefined; + + // Setting 'onPop' while dead is allowed. + frame.onPop = function() { + steps.add("onpop 3"); + }; + }; + }; +}; + +g.eval( + ` + function* myGen() { + debugger; + yield; + } + + const g = myGen(); + g.next(); + + debugger; + g.next(); + + debugger; + ` +); + +assertDeepEq(Array.from(steps), [ + "debugger 1", + "onpop 1", + "debugger 2", + "onpop 2", + "debugger 3", +]);