summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Script-mainOffset-01.js
blob: ae958a523b5709ec6e7670ad2304221d0af11a5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* -*- indent-tabs-mode: nil; js-indent-level: 2; js-indent-level: 2 -*- */
// The main offset of a script should be hit before it performs any actions.

var g = newGlobal({newCompartment: true});
g.eval("var n = 0; function foo() { n = 1; }");
var dbg = Debugger(g);

var hits = 0;
function breakpointHit(frame) {
  hits++;
  assertEq(frame.eval("n").return, 0);
}

dbg.onDebuggerStatement = function (frame) {
  var script = frame.eval("foo").return.script;
  script.setBreakpoint(script.mainOffset, { hit: breakpointHit });
};
g.eval("debugger; foo()");
assertEq(g.eval("n"), 1);
assertEq(hits, 1);