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.

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

mercurial