Debugger tests: Difference between revisions
Jump to navigation
Jump to search
(Created page with "Here is a simple Debugger test: var g = newGlobal('new-compartment'); var dbg = new Debugger(g); var c; dbg.onDebuggerStatement = function (frame) { c = frame.eval(...") |
No edit summary |
||
| Line 11: | Line 11: | ||
Let’s step through this example line by line and see how it works. | Let’s step through this example line by line and see how it works. | ||
First, we need something to debug. The <code>Debugger</code> object won’t let you debug yourself. You must debug a global object in another compartment. So the first step is to make such an object: | |||
var g = newGlobal('new-compartment'); | |||
Now we can create a <code>Debugger</code> to debug it. | |||
var dbg = new Debugger(g); | |||
... | |||
var c; | |||
dbg.onDebuggerStatement = function (frame) { | |||
c = frame.eval("2 + 2"); | |||
}; | |||
g.eval("debugger;"); | |||
assertEq(c.return, 4); | |||
Revision as of 16:39, 8 August 2011
Here is a simple Debugger test:
var g = newGlobal('new-compartment');
var dbg = new Debugger(g);
var c;
dbg.onDebuggerStatement = function (frame) {
c = frame.eval("2 + 2");
};
g.eval("debugger;");
assertEq(c.return, 4);
Let’s step through this example line by line and see how it works.
First, we need something to debug. The Debugger object won’t let you debug yourself. You must debug a global object in another compartment. So the first step is to make such an object:
var g = newGlobal('new-compartment');
Now we can create a Debugger to debug it.
var dbg = new Debugger(g);
...
var c;
dbg.onDebuggerStatement = function (frame) {
c = frame.eval("2 + 2");
};
g.eval("debugger;");
assertEq(c.return, 4);