test_bug424698.html (3440B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=424698 5 --> 6 <head> 7 <title>Test for Bug 424698</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script 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=424698">Mozilla Bug 424698</a> 14 <p id="display"> 15 <input id="i1"> 16 <input id="target"> 17 <textarea id="i2"></textarea> 18 <textarea id="target2"></textarea> 19 </p> 20 <div id="content" style="display: none"> 21 22 </div> 23 <pre id="test"> 24 <script class="testbody" type="text/javascript"> 25 26 /** Test for Bug 424698 */ 27 var i = $("i1"); 28 is(i.value, "", "Value should be empty string"); 29 i.defaultValue = "test"; 30 is(i.value, "test", "Setting defaultValue should work"); 31 i.defaultValue = "test2"; 32 is(i.value, "test2", "Setting defaultValue multiple times should work"); 33 34 // Now let's hide and reshow things 35 i.style.display = "none"; 36 is(i.offsetWidth, 0, "Input didn't hide?"); 37 i.style.display = ""; 38 isnot(i.offsetWidth, 0, "Input didn't show?"); 39 is(i.value, "test2", "Hiding/showing should not affect value"); 40 i.defaultValue = "test3"; 41 is(i.value, "test3", "Setting defaultValue after hide/show should work"); 42 43 // Make sure typing works ok 44 i = $("target"); 45 i.focus(); // Otherwise editor gets confused when we send the key events 46 is(i.value, "", "Value should be empty string in second control"); 47 sendString("2test2"); 48 is(i.value, "2test2", 'We just typed the string "2test2"'); 49 i.defaultValue = "2test3"; 50 is(i.value, "2test2", "Setting defaultValue after typing should not work"); 51 i.style.display = "none"; 52 is(i.offsetWidth, 0, "Second input didn't hide?"); 53 i.style.display = ""; 54 isnot(i.offsetWidth, 0, "Second input didn't show?"); 55 is(i.value, "2test2", "Hiding/showing second input should not affect value"); 56 i.defaultValue = "2test4"; 57 is(i.value, "2test2", "Setting defaultValue after hide/show should not work if we typed"); 58 59 i = $("i2"); 60 is(i.value, "", "Textarea value should be empty string"); 61 i.defaultValue = "test"; 62 is(i.value, "test", "Setting textarea defaultValue should work"); 63 i.defaultValue = "test2"; 64 is(i.value, "test2", "Setting textarea defaultValue multiple times should work"); 65 66 // Now let's hide and reshow things 67 i.style.display = "none"; 68 is(i.offsetWidth, 0, "Textarea didn't hide?"); 69 i.style.display = ""; 70 isnot(i.offsetWidth, 0, "Textarea didn't show?"); 71 is(i.value, "test2", "Hiding/showing textarea should not affect value"); 72 i.defaultValue = "test3"; 73 is(i.value, "test3", "Setting textarea defaultValue after hide/show should work"); 74 75 // Make sure typing works ok 76 i = $("target2"); 77 i.focus(); // Otherwise editor gets confused when we send the key events 78 is(i.value, "", "Textarea value should be empty string in second control"); 79 sendString("2test2"); 80 is(i.value, "2test2", 'We just typed the string "2test2"'); 81 i.defaultValue = "2test3"; 82 is(i.value, "2test2", "Setting textarea defaultValue after typing should not work"); 83 i.style.display = "none"; 84 is(i.offsetWidth, 0, "Second textarea didn't hide?"); 85 i.style.display = ""; 86 isnot(i.offsetWidth, 0, "Second textarea didn't show?"); 87 is(i.value, "2test2", "Hiding/showing second textarea should not affect value"); 88 i.defaultValue = "2test4"; 89 is(i.value, "2test2", "Setting textarea defaultValue after hide/show should not work if we typed"); 90 </script> 91 </pre> 92 </body> 93 </html>