|
1 g = { 'global noneval': 1 }; |
|
2 |
|
3 eval("g['global eval'] = 1"); |
|
4 |
|
5 // Function to step through and set breakpoints on |
|
6 function f1() { |
|
7 g['function noneval'] = 1; |
|
8 eval("g['function eval'] = 1"); |
|
9 |
|
10 x = 1; |
|
11 for (y = 0; y < 10; y++) { |
|
12 x++; |
|
13 } |
|
14 for (y = 0; y < 3; y++) { |
|
15 x++; |
|
16 } |
|
17 z = 3; |
|
18 } |
|
19 |
|
20 var f2 = new Function("g['function noneval'] = 2; eval(\"g['function eval'] = 2\")"); |
|
21 |
|
22 function testJSD(jsd) { |
|
23 ok(jsd.isOn, "JSD needs to be running for this test."); |
|
24 |
|
25 var numBreakpoints = 0; |
|
26 |
|
27 f1(); |
|
28 f2(); |
|
29 jsd.topLevelHook = null; |
|
30 jsd.functionHook = null; |
|
31 dump("numGlobalNonevals="+numGlobalNonevals+"\n"); |
|
32 dump("numFunctionNonevals="+numFunctionNonevals+"\n"); |
|
33 dump("numGlobalEvals="+numGlobalEvals+"\n"); |
|
34 dump("numFunctionEvals="+numFunctionEvals+"\n"); |
|
35 |
|
36 ok(numFunctionNonevals == 3, "(fn) Should have hit f1(), testJSD(), and f2(); hit " + hits.fn); |
|
37 ok(numGlobalNonevals == 1, "(gn) Overall script, hit " + hits.gn); |
|
38 ok(numGlobalEvals == 1, "(ge) Eval in global area, hit " + hits.ge); |
|
39 ok(numFunctionEvals == 2, "(fe) Evals within f1() and f2(), hit " + hits.fe); |
|
40 |
|
41 if (!jsdOnAtStart) { |
|
42 // turn JSD off if it wasn't on when this test started |
|
43 jsd.off(); |
|
44 ok(!jsd.isOn, "JSD shouldn't be running at the end of this test."); |
|
45 } |
|
46 |
|
47 SimpleTest.finish(); |
|
48 } |
|
49 |
|
50 testJSD(jsd); |