Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | |
michael@0 | 2 | var jsdIScript = SpecialPowers.Ci.jsdIScript; |
michael@0 | 3 | |
michael@0 | 4 | function f1() { |
michael@0 | 5 | var x; |
michael@0 | 6 | } |
michael@0 | 7 | |
michael@0 | 8 | function f2() { |
michael@0 | 9 | |
michael@0 | 10 | |
michael@0 | 11 | var x; var y; x = 1; |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | function f3() { |
michael@0 | 15 | |
michael@0 | 16 | |
michael@0 | 17 | var x; |
michael@0 | 18 | |
michael@0 | 19 | var y; var y2; y = 1; |
michael@0 | 20 | var z; |
michael@0 | 21 | |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | var jsdIFilter = SpecialPowers.Ci.jsdIFilter; |
michael@0 | 25 | |
michael@0 | 26 | function testJSD(jsd) { |
michael@0 | 27 | ok(jsd.isOn, "JSD needs to be running for this test."); |
michael@0 | 28 | |
michael@0 | 29 | jsd.functionHook = ({ |
michael@0 | 30 | onCall: function(frame, type) { |
michael@0 | 31 | //console.log("Got " + type); |
michael@0 | 32 | console.log("Got " + frame.script.fileName); |
michael@0 | 33 | } |
michael@0 | 34 | }); |
michael@0 | 35 | |
michael@0 | 36 | console.log("Triggering functions"); |
michael@0 | 37 | f1(); |
michael@0 | 38 | f2(); |
michael@0 | 39 | f3(); |
michael@0 | 40 | console.log("Done with functions"); |
michael@0 | 41 | |
michael@0 | 42 | var linemap = {}; |
michael@0 | 43 | var firsts = {}; |
michael@0 | 44 | var rests = {}; |
michael@0 | 45 | var startlines = {}; |
michael@0 | 46 | jsd.enumerateScripts({ |
michael@0 | 47 | enumerateScript: function(script) { |
michael@0 | 48 | if (/execlines\.js$/.test(script.fileName)) { |
michael@0 | 49 | console.log("script: " + script.fileName + " " + script.functionName); |
michael@0 | 50 | var execLines = script.getExecutableLines(jsdIScript.PCMAP_SOURCETEXT, 0, 10000); |
michael@0 | 51 | console.log(execLines.toSource()); |
michael@0 | 52 | linemap[script.functionName] = execLines; |
michael@0 | 53 | startlines[script.functionName] = script.baseLineNumber; |
michael@0 | 54 | |
michael@0 | 55 | execLines = script.getExecutableLines(jsdIScript.PCMAP_SOURCETEXT, 0, 1); |
michael@0 | 56 | firsts[script.functionName] = execLines; |
michael@0 | 57 | execLines = script.getExecutableLines(jsdIScript.PCMAP_SOURCETEXT, execLines[0]+1, 10000); |
michael@0 | 58 | rests[script.functionName] = execLines; |
michael@0 | 59 | } |
michael@0 | 60 | } |
michael@0 | 61 | }); |
michael@0 | 62 | |
michael@0 | 63 | var checklines = function (funcname, linemap, rellines) { |
michael@0 | 64 | var base = startlines[funcname]; |
michael@0 | 65 | var b = []; |
michael@0 | 66 | for (var i = 0; i < rellines.length; ++i) { |
michael@0 | 67 | b[i] = rellines[i] + base; |
michael@0 | 68 | } |
michael@0 | 69 | is(linemap[funcname].toSource(), b.toSource(), funcname + " lines"); |
michael@0 | 70 | }; |
michael@0 | 71 | |
michael@0 | 72 | checklines('f1', linemap, [ 1 ]); |
michael@0 | 73 | checklines('f2', linemap, [ 3 ]); |
michael@0 | 74 | checklines('f3', linemap, [ 3, 5, 6 ]); |
michael@0 | 75 | |
michael@0 | 76 | checklines('f1', firsts, [ 1 ]); |
michael@0 | 77 | checklines('f1', rests, []); |
michael@0 | 78 | checklines('f3', firsts, [ 3 ]); |
michael@0 | 79 | checklines('f3', rests, [ 5, 6 ]); |
michael@0 | 80 | |
michael@0 | 81 | jsd.functionHook = null; |
michael@0 | 82 | |
michael@0 | 83 | if (!jsdOnAtStart) { |
michael@0 | 84 | // turn JSD off if it wasn't on when this test started |
michael@0 | 85 | jsd.off(); |
michael@0 | 86 | ok(!jsd.isOn, "JSD shouldn't be running at the end of this test."); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | SimpleTest.finish(); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | testJSD(jsd); |