layout/forms/test/test_bug345267.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=345267
     5 -->
     6 <head>
     7   <title>Test for Bug 345267</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=345267">Mozilla Bug 345267</a>
    14 <p id="display">
    15  <input id="d1" maxlength="3" value="abcde">
    16  <input id="d2" maxlength="3">
    17  <input id="d3" maxlength="3">
    18  <input id="d4" value="abcdefghijk">
    19  <input id="target" value="abcdefghijklm" maxlength="3">
    20 </p>
    21 <div id="content" style="display: none">
    22  <input id="u1" maxlength="3" value="abcdef">
    23  <input id="u2" maxlength="3">
    24  <input id="u3" maxlength="3">
    25  <input id="u4" value="abcdefghijkl">
    26 </div>
    27 <pre id="test">
    28 <script class="testbody" type="text/javascript">
    30 /** Test for Bug 345267 **/
    32 // Turn off Spatial Navigation to stop if from hijacking "left" keypress event.
    33 SpecialPowers.setBoolPref('snav.enabled', false);
    35 is($("d1").value, "abcde",
    36    "Displayed initial value should not be truncated by maxlength");
    37 is($("u1").value, "abcdef",
    38    "Undisplayed initial value should not be truncated by maxlength");
    40 $("d2").value = "abcdefg";
    41 is($("d2").value, "abcdefg",
    42    "Displayed set value should not be truncated by maxlength");
    44 $("u2").value = "abcdefgh";
    45 is($("u2").value, "abcdefgh",
    46    "Undisplayed set value should not be truncated by maxlength");
    48 $("d3").defaultValue = "abcdefghi";
    49 is($("d3").value, "abcdefghi",
    50    "Displayed set defaultValue should not be truncated by maxlength");
    52 $("u3").defaultValue = "abcdefghij";
    53 is($("u3").value, "abcdefghij",
    54    "Undisplayed set defaultValue should not be truncated by maxlength");
    56 $("d4").maxLength = "3";
    57 is($("d4").value, "abcdefghijk",
    58    "Displayed: setting maxLength should not truncate existing value");
    60 $("u4").maxLength = "3";
    61 is($("u4").value, "abcdefghijkl",
    62    "Undisplayed: setting maxLength should not truncate existing value");
    64 // Now start the editing tests
    65 is($("target").value, "abcdefghijklm", "Test starting state incorrect");
    66 $("target").focus();
    67 $("target").selectionStart = $("target").selectionEnd = 13;
    68 sendKey("back_space");
    69 is($("target").value, "abcdefghijkl", "Should only delete one char");
    70 sendKey("back_space");
    71 is($("target").value, "abcdefghijk", "Should only delete one char again");
    72 (function () {
    73   SpecialPowers.wrap($("target")).controllers.getControllerForCommand('cmd_undo')
    74                          .doCommand('cmd_undo');
    75 })();
    76 is($("target").value, "abcdefghijklm",
    77    "Should be able to undo deletion in the face of maxlength");
    78 sendString("nopq");
    79 is($("target").value, "abcdefghijklm",
    80    "Typing should have no effect when already past maxlength");
    82 $("target").value = "";
    83 sendString("abcde");
    84 is($("target").value, "abc", "Typing should be limited by maxlength");
    86 $("target").value = "";
    87 sendString("ad");
    88 sendKey("left");
    89 sendString("bc");
    90 is($("target").value, "abd", "Typing should be limited by maxlength again");
    92 </script>
    93 </pre>
    94 </body>
    95 </html>

mercurial