gecko/toolkit/components/prompts/test/test_bug619644.html

55 lines
1.9 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=619644
-->
<head>
<title>Test for Bug 619644</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.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=619644">Mozilla Bug 619644</a>
<pre id="test">
<script class="testbody" type="text/javascript">
function hasTabModalPrompts() {
var prefName = "prompts.tab_modal.enabled";
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
Components.utils.import("resource://gre/modules/Services.jsm");
return Services.prefs.getPrefType(prefName) == Services.prefs.PREF_BOOL &&
Services.prefs.getBoolPref(prefName);
}
if (!hasTabModalPrompts()) {
todo(false, "Test disabled when tab modal prompts are not enabled.");
} else {
SimpleTest.waitForExplicitFinish();
// This is a little yucky, but it works
// The contents of bug619644_inner.html
const expectedFinalDoc =
"<head><\/head><body><p>Original content<\/p>\n<script>\n window.opener.postMessage(\"\", \"*\");\n confirm (\"Message\");\n document.write (\"Extra content\");\n window.opener.postMessage(document.documentElement.innerHTML, \"*\");\n<\/script>Extra content<\/body>";
function runtest(e)
{
window.removeEventListener("message", runtest, false);
window.addEventListener("message", checktest, false);
synthesizeKey("VK_ESCAPE", {}, e.source);
}
function checktest(e) {
is(e.data, expectedFinalDoc, "ESC press should not abort document load");
e.source.close();
SimpleTest.finish();
}
window.addEventListener("message", runtest, false);
window.open("bug619644_inner.html", "619644");
}
</script>
</pre>
</body>
</html>