gecko/dom/tests/mochitest/bugs/test_bug397571.html
Bobby Holley 7f912ddc79 Bug 792036 - Fix up tests to avoid relying on the existence of window.Components (MANUAL). r=mccr8
These are the manual fixes that the ensuing auto-generation can't deal with. Some of them
just fix up formatting (such as Components.\nFoo, so that subsequent auto-generation can
work better).
2012-09-24 14:46:28 +02:00

138 lines
2.4 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="/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(SpecialPowers.Ci.nsIInterfaceRequestor).
getInterface(SpecialPowers.Ci.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
utils = SpecialPowers.wrap(utils);
// 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>