test_bug606817.html (1433B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=606817 5 --> 6 <head> 7 <title>Test for Bug 606817</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=606817">Mozilla Bug 606817</a> 13 <p id="display"></p> 14 <pre id="test"> 15 <script type="application/javascript"> 16 17 /** Test for Bug 606817 */ 18 19 var messageMaxLength = 256; 20 21 function checkMessage(aInput, aMsg, aWithTerminalPeriod) 22 { 23 ok(aInput.validationMessage != aMsg, 24 "Original content-defined message should have been truncate"); 25 is(aInput.validationMessage.length - aInput.validationMessage.indexOf("_42_"), 26 aWithTerminalPeriod ? messageMaxLength+1 : messageMaxLength, 27 "validation message should be 256 characters length"); 28 } 29 30 var input = document.createElement("input"); 31 32 var msg = ""; 33 for (var i=0; i<75; ++i) { 34 msg += "_42_"; 35 } 36 // msg is now 300 chars long 37 38 // Testing with setCustomValidity(). 39 input.setCustomValidity(msg); 40 checkMessage(input, msg, false); 41 42 // Cleaning. 43 input.setCustomValidity(""); 44 45 // Testing with pattern and titl. 46 input.pattern = "[0-9]*"; 47 input.value = "foo"; 48 input.title = msg; 49 checkMessage(input, msg, true); 50 51 // Cleaning. 52 input.removeAttribute("pattern"); 53 input.removeAttribute("title"); 54 input.value = ""; 55 56 </script> 57 </pre> 58 </body> 59 </html>