js/jsd/test/test_bug617870-callhooks.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/jsd/test/test_bug617870-callhooks.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <!-- The bug number is pulled from the test URL -->
     1.8 +  <title>JSD Test for Bug AUTOFILLED</title>
     1.9 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.10 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.11 +  <script type="application/javascript" src="jsd-test.js"></script>
    1.12 +  <script type="application/javascript">
    1.13 +var BUG = 617870;
    1.14 +var TEST_SCRIPT = "test-bug617870-callhooks.js";
    1.15 +document.getElementsByTagName("title")[0].innerHTML = "JSD Test for Bug " + BUG;
    1.16 +
    1.17 +SimpleTest.waitForExplicitFinish();
    1.18 +
    1.19 +var hits = { gn: [], ge: [], fn: [], fe: [] };
    1.20 +var numGlobalNonevals = 0;
    1.21 +var numFunctionNonevals = 0;
    1.22 +var numGlobalEvals = 0;
    1.23 +var numFunctionEvals = 0;
    1.24 +function runTest() {
    1.25 +    jsd.topLevelHook = {
    1.26 +        onCall: function(frame,type) {
    1.27 +            if (frame.script.fileName.indexOf(TEST_SCRIPT) != -1) {
    1.28 +                var desc = frame.script.fileName + ":" + frame.line + " (" + frame.functionName + ")";
    1.29 +                if (type == Ci.jsdICallHook.TYPE_TOPLEVEL_START) {
    1.30 +                    if (frame.callingFrame === null) {
    1.31 +                        numGlobalNonevals++;
    1.32 +                        hits.gn.push(desc);
    1.33 +                    } else if (frame.callee === null) {
    1.34 +                        numGlobalEvals++;
    1.35 +                        hits.ge.push(desc);
    1.36 +                    } else {
    1.37 +                        numFunctionEvals++;
    1.38 +                        hits.fe.push(desc);
    1.39 +                    }
    1.40 +                }
    1.41 +                dumpStack(frame, "TOPLEVEL(" + type + ")");
    1.42 +           }
    1.43 +        }
    1.44 +    };
    1.45 +    jsd.functionHook = {
    1.46 +        onCall: function(frame,type) {
    1.47 +            if (frame.script.fileName.indexOf(TEST_SCRIPT) != -1) {
    1.48 +                if (type == Ci.jsdICallHook.TYPE_FUNCTION_CALL) {
    1.49 +                    var desc = frame.script.fileName + ":" + frame.line + " (" + frame.functionName + ")";
    1.50 +                    numFunctionNonevals++;
    1.51 +                    hits.fn.push(desc);
    1.52 +                }
    1.53 +                dumpStack(frame, "FUNCTION(" + type + ")");
    1.54 +            }
    1.55 +        }
    1.56 +    };
    1.57 +    loadScript(TEST_SCRIPT, document.getElementById("test"));
    1.58 +}
    1.59 +
    1.60 +function setupTest() {
    1.61 +  var buglink = document.getElementById("buglink");
    1.62 +  buglink.href = "https://bugzilla.mozilla.org/show_bug.cgi?id=" + BUG;
    1.63 +  buglink.innerHTML = "Mozilla Bug " + BUG;
    1.64 +}
    1.65 +  </script>
    1.66 +</head>
    1.67 +<body onLoad='setupTest(); setupJSD();'>
    1.68 +
    1.69 +<a id="buglink" target="_blank"></a>
    1.70 +<p id="display"></p>
    1.71 +
    1.72 +<div id="content" style="display: none">
    1.73 +  <pre id='test'>
    1.74 +  </pre>
    1.75 +</div>
    1.76 +
    1.77 +<div id='test-output'>
    1.78 +</div>
    1.79 +
    1.80 +</body>
    1.81 +</html>

mercurial