js/jsd/test/test-bug617870-callhooks.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/jsd/test/test-bug617870-callhooks.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +g = { 'global noneval': 1 };
     1.5 +
     1.6 +eval("g['global eval'] = 1");
     1.7 +
     1.8 +// Function to step through and set breakpoints on
     1.9 +function f1() {
    1.10 +  g['function noneval'] = 1;
    1.11 +  eval("g['function eval'] = 1");
    1.12 +
    1.13 +  x = 1;
    1.14 +  for (y = 0; y < 10; y++) {
    1.15 +    x++;
    1.16 +  }
    1.17 +  for (y = 0; y < 3; y++) {
    1.18 +    x++;
    1.19 +  }
    1.20 +  z = 3;
    1.21 +}
    1.22 +
    1.23 +var f2 = new Function("g['function noneval'] = 2; eval(\"g['function eval'] = 2\")");
    1.24 +
    1.25 +function testJSD(jsd) {
    1.26 +    ok(jsd.isOn, "JSD needs to be running for this test.");
    1.27 +
    1.28 +    var numBreakpoints = 0;
    1.29 +
    1.30 +    f1();
    1.31 +    f2();
    1.32 +    jsd.topLevelHook = null;
    1.33 +    jsd.functionHook = null;
    1.34 +    dump("numGlobalNonevals="+numGlobalNonevals+"\n");
    1.35 +    dump("numFunctionNonevals="+numFunctionNonevals+"\n");
    1.36 +    dump("numGlobalEvals="+numGlobalEvals+"\n");
    1.37 +    dump("numFunctionEvals="+numFunctionEvals+"\n");
    1.38 +
    1.39 +    ok(numFunctionNonevals == 3, "(fn) Should have hit f1(), testJSD(), and f2(); hit " + hits.fn);
    1.40 +    ok(numGlobalNonevals == 1, "(gn) Overall script, hit " + hits.gn);
    1.41 +    ok(numGlobalEvals == 1, "(ge) Eval in global area, hit " + hits.ge);
    1.42 +    ok(numFunctionEvals == 2, "(fe) Evals within f1() and f2(), hit " + hits.fe);
    1.43 +
    1.44 +    if (!jsdOnAtStart) {
    1.45 +        // turn JSD off if it wasn't on when this test started
    1.46 +        jsd.off();
    1.47 +        ok(!jsd.isOn, "JSD shouldn't be running at the end of this test.");
    1.48 +    }
    1.49 +
    1.50 +    SimpleTest.finish();
    1.51 +}
    1.52 +
    1.53 +testJSD(jsd);

mercurial