layout/forms/test/test_bug446663.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/forms/test/test_bug446663.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=446663
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 446663</title>
    1.11 +  <script type="text/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=446663">Mozilla Bug 446663</a>
    1.17 +<p id="display">
    1.18 +<style>#bug446663_a:focus{overflow:hidden}</style>
    1.19 +<input id="bug446663_a"><input id="bug446663_b"></p>
    1.20 +<div id="content" style="display: none">
    1.21 +  
    1.22 +</div>
    1.23 +<pre id="test">
    1.24 +<script class="testbody" type="text/javascript">
    1.25 +
    1.26 +/** Test for Bug 446663 **/
    1.27 +
    1.28 +function test_edit_cmds(id) {
    1.29 +
    1.30 +  var elm = document.getElementById(id);
    1.31 +  elm.focus();
    1.32 +  elm.select();
    1.33 +  SpecialPowers.wrap(elm).controllers.getControllerForCommand('cmd_cut')
    1.34 +                         .doCommand('cmd_cut');
    1.35 +  is(elm.value, '', id + " cut");
    1.36 +
    1.37 +  SpecialPowers.wrap(elm).controllers.getControllerForCommand('cmd_undo')
    1.38 +                         .doCommand('cmd_undo');
    1.39 +  is(elm.value, '123', id + " undo");
    1.40 +}
    1.41 +
    1.42 +var inputHappened = false;
    1.43 +function inputListener() {
    1.44 +  inputHappened = true;
    1.45 +  $(id).removeEventListener("input", inputListener, false);
    1.46 +}
    1.47 +
    1.48 +var id = 'bug446663_a'
    1.49 +var elm = document.getElementById(id);
    1.50 +elm.focus();
    1.51 +var x = document.body.offsetHeight;
    1.52 +$(id).addEventListener("input", inputListener, false);
    1.53 +sendChar('1');
    1.54 +is(inputHappened, true, "How come no input?");
    1.55 +sendChar('3');
    1.56 +sendKey('LEFT')
    1.57 +sendChar('2');
    1.58 +elm.blur();
    1.59 +x = document.body.offsetHeight;
    1.60 +is(elm.value, '123', id + " edit");
    1.61 +test_edit_cmds(id)
    1.62 +
    1.63 +id = 'bug446663_b'
    1.64 +elm = document.getElementById(id);
    1.65 +elm.focus();
    1.66 +sendChar('1');
    1.67 +elm.style.display = 'none'
    1.68 +var x = document.body.offsetHeight;
    1.69 +elm.style.display = 'inline'
    1.70 +x = document.body.offsetHeight;
    1.71 +sendChar('3');
    1.72 +sendKey('LEFT')
    1.73 +sendChar('2');
    1.74 +elm.blur();
    1.75 +x = document.body.offsetHeight;
    1.76 +is(elm.value, '123', id + " edit");
    1.77 +test_edit_cmds(id)
    1.78 +
    1.79 +</script>
    1.80 +</pre>
    1.81 +</body>
    1.82 +</html>
    1.83 +

mercurial