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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 g = { 'global noneval': 1 };
     3 eval("g['global eval'] = 1");
     5 // Function to step through and set breakpoints on
     6 function f1() {
     7   g['function noneval'] = 1;
     8   eval("g['function eval'] = 1");
    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 }
    20 var f2 = new Function("g['function noneval'] = 2; eval(\"g['function eval'] = 2\")");
    22 function testJSD(jsd) {
    23     ok(jsd.isOn, "JSD needs to be running for this test.");
    25     var numBreakpoints = 0;
    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");
    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);
    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     }
    47     SimpleTest.finish();
    48 }
    50 testJSD(jsd);

mercurial