summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/lib/debuggerNXHelper.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/lib/debuggerNXHelper.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/lib/debuggerNXHelper.js')
-rw-r--r--js/src/jit-test/lib/debuggerNXHelper.js90
1 files changed, 90 insertions, 0 deletions
diff --git a/js/src/jit-test/lib/debuggerNXHelper.js b/js/src/jit-test/lib/debuggerNXHelper.js
new file mode 100644
index 000000000..61792da84
--- /dev/null
+++ b/js/src/jit-test/lib/debuggerNXHelper.js
@@ -0,0 +1,90 @@
+function testDebuggerHooksNX(dbg, g, testHook) {
+ function testDebuggerHook(hookName, trigger) {
+ var hit = false;
+ dbg[hookName] = () => {
+ hit = true;
+ dbg[hookName] = undefined;
+ testHook(hookName);
+ };
+ trigger();
+ assertEq(hit, true);
+ }
+
+ // Hooks on the Debugger instance itself.
+ testDebuggerHook("onDebuggerStatement",
+ () => { g.eval("debugger;"); });
+
+ testDebuggerHook("onExceptionUnwind",
+ () => {
+ try {
+ g.eval("throw 42;");
+ } catch (e) {
+ assertEq(e, 42);
+ }
+ });
+
+ testDebuggerHook("onNewScript",
+ () => { g.eval("42"); });
+
+ testDebuggerHook("onEnterFrame",
+ () => { g.eval("(() => {})()"); });
+
+ testDebuggerHook("onNewGlobalObject",
+ () => { newGlobal(); });
+
+ if ('Promise' in g) {
+ testDebuggerHook("onNewPromise",
+ () => { new g.Promise(()=>{}); });
+
+ testDebuggerHook("onPromiseSettled",
+ () => {
+ var p = new g.Promise(()=>{});
+ g.settlePromiseNow(p);
+ });
+ }
+
+ // Hooks on frames.
+ var onStepHit = false;
+ var onPopHit = false;
+ dbg.onEnterFrame = (frame) => {
+ dbg.onEnterFrame = undefined;
+
+ frame.onStep = () => {
+ onStepHit = true;
+ frame.onStep = undefined;
+ testHook("onStep");
+ };
+
+ frame.onPop = () => {
+ onPopHit = true;
+ testHook("onPop");
+ };
+ };
+ g.eval("42");
+ assertEq(onStepHit, true);
+
+ // We can't actually assert that onPop executed because there's one test
+ // that tests NX works across a removeDebuggee/addDebuggee toggle. The
+ // removeDebuggee purges D.F instances, so the onPop won't be called even
+ // when the global is re-added.
+ //assertEq(onPopHit, true);
+
+ // Breakpoints
+ var breakpointHits = 0;
+ dbg.onDebuggerStatement = (frame) => {
+ dbg.onDebuggerStatement = undefined;
+ var line0 = frame.script.getOffsetLocation(frame.offset).lineNumber;
+ var offs = frame.script.getLineOffsets(line0 + 1);
+ for (let i = 0; i < offs.length; i++) {
+ frame.script.setBreakpoint(offs[i], {
+ hit: () => {
+ breakpointHits++;
+ testHook("breakpoint");
+ }
+ });
+ }
+ };
+ g.eval(`debugger;
+ s = 'a'`);
+ assertEq(breakpointHits >= 1, true);
+}