js/jsd/test/test_bug617870-callhooks.html
author Mike Hommey <mh+mozilla@glandium.org>
Thu, 28 Jul 2011 18:55:38 +0200
changeset 73492 ac0fe0533586e0470dce181d2f3fd5d9ace50170
parent 60152 5b7ecdabfe49e74a28e5d1d9c8418f05b77eef45
child 74315 1188456710819d4606e74396be333ead9fe63261
permissions -rw-r--r--
Bug 674910 - Statically link against libstdc++ on Android. r=blassey

<!DOCTYPE HTML>
<html>
<head>
  <!-- The bug number is pulled from the test URL -->
  <title>JSD Test for Bug AUTOFILLED</title>
  <script type="application/javascript" src="/MochiKit/packed.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript" src="jsd-test.js"></script>
  <script type="application/javascript">
var BUG = 617870;
var TEST_SCRIPT = "test-bug617870-callhooks.js";
document.getElementsByTagName("title")[0].innerHTML = "JSD Test for Bug " + BUG;

netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

SimpleTest.waitForExplicitFinish();

var hits = { gn: [], ge: [], fn: [], fe: [] };
var numGlobalNonevals = 0;
var numFunctionNonevals = 0;
var numGlobalEvals = 0;
var numFunctionEvals = 0;
function runTest() {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    jsd.topLevelHook = {
        onCall: function(frame,type) {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            if (frame.script.fileName.indexOf(TEST_SCRIPT) != -1) {
                var desc = frame.script.fileName + ":" + frame.line + " (" + frame.functionName + ")";
                if (type == Ci.jsdICallHook.TYPE_TOPLEVEL_START) {
                    if (frame.callingFrame === null) {
                        numGlobalNonevals++;
                        hits.gn.push(desc);
                    } else if (frame.callee === null) {
                        numGlobalEvals++;
                        hits.ge.push(desc);
                    } else {
                        numFunctionEvals++;
                        hits.fe.push(desc);
                    }
                }
                dumpStack(frame, "TOPLEVEL(" + type + ")");
           }
        }
    };
    jsd.functionHook = {
        onCall: function(frame,type) {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            if (frame.script.fileName.indexOf(TEST_SCRIPT) != -1) {
                if (type == Ci.jsdICallHook.TYPE_FUNCTION_CALL) {
                    var desc = frame.script.fileName + ":" + frame.line + " (" + frame.functionName + ")";
                    numFunctionNonevals++;
                    hits.fn.push(desc);
                }
                dumpStack(frame, "FUNCTION(" + type + ")");
            }
        }
    };
    loadScript(TEST_SCRIPT, document.getElementById("test"));
}

function setupTest() {
  var buglink = document.getElementById("buglink");
  buglink.href = "https://bugzilla.mozilla.org/show_bug.cgi?id=" + BUG;
  buglink.innerHTML = "Mozilla Bug " + BUG;
}
  </script>
</head>
<body onLoad='setupTest(); setupJSD();'>

<a id="buglink" target="_blank"></a>
<p id="display"></p>

<div id="content" style="display: none">
  <pre id='test'>
  </pre>
</div>

<div id='test-output'>
</div>

</body>
</html>