editor/libeditor/text/tests/test_bug527935.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/text/tests/test_bug527935.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=527935
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 527935</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=527935">Mozilla Bug 527935</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content">
    1.19 +  <iframe id="formTarget" name="formTarget"></iframe>
    1.20 +  <form action="data:text/html," target="formTarget">
    1.21 +    <input name="test" id="initValue"><input type="submit">
    1.22 +  </form>
    1.23 +</div>
    1.24 +<pre id="test">
    1.25 +<script type="application/javascript">
    1.26 +
    1.27 +/** Test for Bug 527935 **/
    1.28 +SimpleTest.waitForExplicitFinish();
    1.29 +SimpleTest.waitForFocus(function() {
    1.30 +  var formTarget = document.getElementById("formTarget");
    1.31 +  var initValue = document.getElementById("initValue");
    1.32 +
    1.33 +  formTarget.addEventListener("load", function() {
    1.34 +    var newInput = document.createElement("input");
    1.35 +    newInput.setAttribute("name", "test");
    1.36 +    document.body.appendChild(newInput);
    1.37 +
    1.38 +    setTimeout(function() {
    1.39 +      var popupShown = false;
    1.40 +      function listener() {
    1.41 +        popupShown = true;
    1.42 +      }
    1.43 +      SpecialPowers.addAutoCompletePopupEventListener(window, "popupshowing", listener);
    1.44 +
    1.45 +      var event = document.createEvent("KeyboardEvent");
    1.46 +
    1.47 +      event.initKeyEvent("keypress", true, true, null, false, false,
    1.48 +                         false, false, 0, "f".charCodeAt(0));
    1.49 +      newInput.value = "";
    1.50 +      newInput.focus();
    1.51 +      newInput.dispatchEvent(event);
    1.52 +
    1.53 +      hitEventLoop(function() {
    1.54 +        ok(!popupShown, "Popup must not be opened");
    1.55 +        SpecialPowers.removeAutoCompletePopupEventListener(window, "popupshowing", listener);
    1.56 +        SimpleTest.finish();
    1.57 +      }, 100);
    1.58 +    }, 0);
    1.59 +  }, false);
    1.60 +
    1.61 +  initValue.focus();
    1.62 +  initValue.value = "foo";
    1.63 +  synthesizeKey("VK_RETURN", {});
    1.64 +});
    1.65 +
    1.66 +function hitEventLoop(func, times) {
    1.67 +  if (times > 0) {
    1.68 +    setTimeout(hitEventLoop, 0, func, times - 1);
    1.69 +  } else {
    1.70 +    setTimeout(func, 0);
    1.71 +  }
    1.72 +}
    1.73 +
    1.74 +</script>
    1.75 +</pre>
    1.76 +</body>
    1.77 +</html>

mercurial