gecko/js/jsd/test/test_bug617870-callhooks.html

84 lines
2.9 KiB
HTML

<!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="/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>