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.

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

mercurial