gecko/dom/tests/mochitest/bugs/test_bug397571.html

139 lines
2.6 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=397571
-->
<head>
<title>Test for Bug 397571</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/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=397571">
Mozilla Bug 397571</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 397571 **/
// Get the interface
var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
// Try to call functions without privileges
var success = false;
try {
isForced = utils.docCharsetIsForced;
}
catch(e) {
success = true;
}
ok(success == true, "should throw");
success = false;
try {
contentDisposition = utils.getDocumentMetadata("content-disposition");
}
catch(e) {
success = true;
}
ok(success == true, "should throw");
var success = false;
try {
utils.sendMouseEvent("mousedown", 0, 0, 0, 1, 0);
}
catch(e) {
success = true;
}
ok(success, "should throw");
var success = false;
try {
utils.sendKeyEvent("keydown", 0, 0, 0);
}
catch(e) {
success = true;
}
ok(success, "should throw");
var success = false;
try {
utils.focus(null);
}
catch(e) {
success = true;
}
ok(success, "should throw");
// Get privilege
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
// Try again
var success = true;
try {
isForced = utils.docCharsetIsForced;
}
catch(e) {
success = false;
}
ok(success, "shouldn't throw");
var success = true;
try {
contentDisposition = utils.getDocumentMetadata("content-disposition");
}
catch(e) {
success = false;
}
ok(success, "shouldn't throw");
var success = true;
try {
utils.sendMouseEvent("mousedown", 0, 0, 0, 1, 0);
}
catch(e) {
success = false;
}
ok(success, "shouldn't throw");
var success = true;
try {
utils.sendKeyEvent("keydown", 0, 0, 0);
}
catch(e) {
success = false;
}
ok(success, "shouldn't throw");
var success = true;
try {
utils.focus(null);
}
catch(e) {
success = false;
}
ok(success, "shouldn't throw");
// TEMPORARY workaround for leak bug 524037: send a mouseup event as
// well so that we don't leak.
var success = true;
try {
utils.sendMouseEvent("mouseup", 0, 0, 0, 1, 0);
}
catch(e) {
success = false;
}
ok(success, "shouldn't throw");
</script>
</pre>
</body>
</html>