js/jsd/test/test_bug617870-callhooks.html

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:aca04b9ffd40
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <!-- The bug number is pulled from the test URL -->
5 <title>JSD Test for Bug AUTOFILLED</title>
6 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
8 <script type="application/javascript" src="jsd-test.js"></script>
9 <script type="application/javascript">
10 var BUG = 617870;
11 var TEST_SCRIPT = "test-bug617870-callhooks.js";
12 document.getElementsByTagName("title")[0].innerHTML = "JSD Test for Bug " + BUG;
13
14 SimpleTest.waitForExplicitFinish();
15
16 var hits = { gn: [], ge: [], fn: [], fe: [] };
17 var numGlobalNonevals = 0;
18 var numFunctionNonevals = 0;
19 var numGlobalEvals = 0;
20 var numFunctionEvals = 0;
21 function runTest() {
22 jsd.topLevelHook = {
23 onCall: function(frame,type) {
24 if (frame.script.fileName.indexOf(TEST_SCRIPT) != -1) {
25 var desc = frame.script.fileName + ":" + frame.line + " (" + frame.functionName + ")";
26 if (type == Ci.jsdICallHook.TYPE_TOPLEVEL_START) {
27 if (frame.callingFrame === null) {
28 numGlobalNonevals++;
29 hits.gn.push(desc);
30 } else if (frame.callee === null) {
31 numGlobalEvals++;
32 hits.ge.push(desc);
33 } else {
34 numFunctionEvals++;
35 hits.fe.push(desc);
36 }
37 }
38 dumpStack(frame, "TOPLEVEL(" + type + ")");
39 }
40 }
41 };
42 jsd.functionHook = {
43 onCall: function(frame,type) {
44 if (frame.script.fileName.indexOf(TEST_SCRIPT) != -1) {
45 if (type == Ci.jsdICallHook.TYPE_FUNCTION_CALL) {
46 var desc = frame.script.fileName + ":" + frame.line + " (" + frame.functionName + ")";
47 numFunctionNonevals++;
48 hits.fn.push(desc);
49 }
50 dumpStack(frame, "FUNCTION(" + type + ")");
51 }
52 }
53 };
54 loadScript(TEST_SCRIPT, document.getElementById("test"));
55 }
56
57 function setupTest() {
58 var buglink = document.getElementById("buglink");
59 buglink.href = "https://bugzilla.mozilla.org/show_bug.cgi?id=" + BUG;
60 buglink.innerHTML = "Mozilla Bug " + BUG;
61 }
62 </script>
63 </head>
64 <body onLoad='setupTest(); setupJSD();'>
65
66 <a id="buglink" target="_blank"></a>
67 <p id="display"></p>
68
69 <div id="content" style="display: none">
70 <pre id='test'>
71 </pre>
72 </div>
73
74 <div id='test-output'>
75 </div>
76
77 </body>
78 </html>

mercurial