toolkit/components/prompts/test/test_bug619644.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/prompts/test/test_bug619644.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=619644
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 619644</title>
    1.11 +  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.14 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.15 +</head>
    1.16 +<body>
    1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=619644">Mozilla Bug 619644</a>
    1.18 +<pre id="test">
    1.19 +<script class="testbody" type="text/javascript">
    1.20 +function hasTabModalPrompts() {
    1.21 +  var prefName = "prompts.tab_modal.enabled";
    1.22 +  Services = SpecialPowers.Services;
    1.23 +  return Services.prefs.getPrefType(prefName) == Services.prefs.PREF_BOOL &&
    1.24 +         Services.prefs.getBoolPref(prefName);
    1.25 +}
    1.26 +
    1.27 +if (!hasTabModalPrompts()) {
    1.28 +  todo(false, "Test disabled when tab modal prompts are not enabled.");
    1.29 +} else {
    1.30 +SimpleTest.waitForExplicitFinish();
    1.31 +
    1.32 +// This is a little yucky, but it works
    1.33 +// The contents of bug619644_inner.html
    1.34 +const expectedFinalDoc = 
    1.35 +"<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>";
    1.36 +
    1.37 +function runtest(e)
    1.38 +{
    1.39 +  window.removeEventListener("message", runtest, false);
    1.40 +  window.addEventListener("message", checktest, false);
    1.41 +  synthesizeKey("VK_ESCAPE", {}, e.source);
    1.42 +}
    1.43 +
    1.44 +function checktest(e) {
    1.45 +  is(e.data, expectedFinalDoc, "ESC press should not abort document load");
    1.46 +  e.source.close();
    1.47 +  SimpleTest.finish();
    1.48 +}
    1.49 +
    1.50 +window.addEventListener("message", runtest, false);
    1.51 +window.open("bug619644_inner.html", "619644");
    1.52 +}
    1.53 +</script>
    1.54 +</pre>
    1.55 +</body>
    1.56 +</html>

mercurial