pjs/js/jsd/test/test_bug507448.html

113 строки
3.3 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=507448
-->
<head>
<title>Test for Bug 507448</title>
<script type="application/javascript" src="/MochiKit/Base.js"></script>
<script type="application/javascript" src="/MochiKit/Async.js"></script>
<script type="application/javascript" src="/MochiKit/DOM.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=507448">Mozilla Bug 507448</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
function f() {}
function g(a,b) {}
function h(me, too, here) { var x = 1; }
function annoying(a, b, a, b, b, a) {}
function manyLocals(a, b, c, d, e, f, g, h, i, j, k, l, m) {
var n, o, p, q, r, s, t, u, v, w, x, y, z;
}
</script>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
function loadScript(url) {
var d = new MochiKit.Async.Deferred();
var head = document.getElementsByTagName("head")[0];
var script = MochiKit.DOM.createDOM("script", { type: "text/javascript", src: url });
script.onload = function() {
script.onload = null;
script.onerror = null;
script.onreadystatechange = null;
d.callback();
};
script.onerror = function(msg) {
script.onload = null;
script.onerror = null;
script.onreadystatechange = null;
msg = "Failed to load script at " + url + ": " + msg;
d.errback(new URIError(msg, url));
}
script.onreadystatechange = function() {
if (script.readyState == "loaded" || script.readyState == "complete") {
script.onload();
} else {
// IE doesn't bother to report errors...
MochiKit.Async.callLater(10, script.onerror, "Script loading timed out")
}
};
head.appendChild(script);
return d;
}
/** Test for Bug 507448 **/
function assertArraysEqual(arr1, arr2) {
is(arr1.length, arr2.length, "Lengths not equal");
for (var i = 0 ; i < arr1.length; ++i) {
is(arr1[i], arr2[i], "Element " + i + " not equal");
}
}
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var jsdIDebuggerService = Components.interfaces.jsdIDebuggerService;
var jsd = Components.classes['@mozilla.org/js/jsd/debugger-service;1']
.getService(jsdIDebuggerService);
var jsdOnAtStart = false;
function setupJSD() {
// This is somewhat unfortunate: jsd only deals with scripts that have a
// nonzero line number, so we can't just createElement a script here.
// So break the test up into three <script>s, of which the middle one has our test functions.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
jsdOnAtStart = jsd.isOn;
if (jsdOnAtStart) {
testJSD();
} else {
jsd.asyncOn(
{
onDebuggerActivated: function() {
testJSD();
}
}
);
}
}
addLoadEvent(setupJSD);
</script>
<script>
function testJSD() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
ok(jsd.isOn, "JSD needs to be running for this test.");
var deferred = loadScript("bug507448.js");
}
</script>
</pre>
</body>
</html>