test_bug399284.html (2865B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=399284 5 --> 6 <head> 7 <title>Test for Bug 399284</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=399284">Mozilla Bug 399284</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 </div> 16 <pre id="test"> 17 <script class="testbody" type="text/javascript"> 18 /** Test for Bug 399284 */ 19 const testContent = "<p id='testPara'>The quick brown fox jumps over the lazy dog"; 20 21 var decoders = [ 22 "Big5", 23 "Big5-HKSCS", 24 "EUC-JP", 25 "EUC-KR", 26 "gb18030", 27 "IBM866", 28 "ISO-2022-JP", 29 "ISO-8859-3", 30 "ISO-8859-4", 31 "ISO-8859-5", 32 "ISO-8859-6", 33 "ISO-8859-7", 34 "ISO-8859-8", 35 "ISO-8859-8-I", 36 "ISO-8859-10", 37 "ISO-8859-13", 38 "ISO-8859-14", 39 "ISO-8859-15", 40 "ISO-8859-16", 41 "ISO-8859-2", 42 "KOI8-R", 43 "KOI8-U", 44 "Shift_JIS", 45 "windows-1250", 46 "windows-1251", 47 "windows-1252", 48 "windows-1253", 49 "windows-1254", 50 "windows-1255", 51 "windows-1256", 52 "windows-1257", 53 "windows-1258", 54 "windows-874", 55 "x-mac-cyrillic", 56 "UTF-8", 57 "UTF-16LE", 58 "UTF-16BE" 59 ]; 60 61 var decoder; 62 for (var i = 0; i < decoders.length; i++) { 63 var decoder = decoders[i]; 64 var data; 65 66 // encode the content for non-ASCII compatible encodings 67 if (decoder == "UTF-16BE") 68 data = encodeUTF16BE(testContent); 69 else if (decoder == "UTF-16LE") 70 data = encodeUTF16LE(testContent); 71 else 72 data = encodeURI(testContent); 73 var dataURI = "data:text/html;charset=" + decoder + "," + data; 74 75 var testFrame = document.createElement("iframe"); 76 frameID = decoder; 77 testFrame.setAttribute("id", frameID); 78 var testFrameObj = document.body.appendChild(testFrame); 79 testFrameObj.setAttribute("onload", "testFontSize('" + decoder + "')"); 80 testFrameObj.contentDocument.location.assign(dataURI); 81 } 82 83 function encodeUTF16BE(string) 84 { 85 var encodedString = ""; 86 for (i = 0; i < string.length; ++i) { 87 encodedString += "%00"; 88 encodedString += encodeURI(string.charAt(i)); 89 } 90 return encodedString; 91 } 92 93 function encodeUTF16LE(string) 94 { 95 var encodedString = ""; 96 for (i = 0; i < string.length; ++i) { 97 encodedString += encodeURI(string.charAt(i)); 98 encodedString += "%00"; 99 } 100 return encodedString; 101 } 102 103 function testFontSize(frame) 104 { 105 var iframeDoc = SpecialPowers.wrap($(frame)).contentDocument; 106 var size = parseInt(iframeDoc.defaultView. 107 getComputedStyle(iframeDoc.getElementById("testPara")). 108 getPropertyValue("font-size")); 109 ok(size > 0, "font size assigned for " + frame); 110 } 111 </script> 112 </pre> 113 </body> 114 </html>