1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/base/tests/test_bug399284.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,93 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=399284 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 399284</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=399284">Mozilla Bug 399284</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 +</div> 1.19 +<pre id="test"> 1.20 +<script class="testbody" type="text/javascript"> 1.21 +/** Test for Bug 399284 **/ 1.22 +const testContent = "<p id='testPara'>The quick brown fox jumps over the lazy dog"; 1.23 + 1.24 +const Ci = SpecialPowers.Ci; 1.25 +const Cc = SpecialPowers.Cc; 1.26 +var ccManager = Cc["@mozilla.org/charset-converter-manager;1"].getService(Ci.nsICharsetConverterManager); 1.27 + 1.28 +var decoderList = ccManager.getDecoderList(); 1.29 +SimpleTest.waitForExplicitFinish(); 1.30 +while (decoderList.hasMore()) { 1.31 + var decoder = decoderList.getNext(); 1.32 + 1.33 + // encode the content for non-ASCII compatible encodings 1.34 + if (decoder == "UTF-16BE") 1.35 + data = encodeUTF16BE(testContent); 1.36 + else if (decoder == "UTF-16" || decoder == "UTF-16LE") 1.37 + data = encodeUTF16LE(testContent); 1.38 + else if (decoder == "replacement" || 1.39 + decoder == "ISO-2022-KR" || 1.40 + decoder == "ISO-2022-CN") 1.41 + continue; 1.42 + else 1.43 + data = encodeURI(testContent); 1.44 + var dataURI = "data:text/html;charset=" + decoder + "," + data; 1.45 + 1.46 + var testFrame = document.createElement("iframe"); 1.47 + frameID = decoder; 1.48 + testFrame.setAttribute("id", frameID); 1.49 + var testFrameObj = document.body.appendChild(testFrame); 1.50 + if (decoderList.hasMore()) 1.51 + testFrameObj.setAttribute("onload", "testFontSize('" + decoder + "')"); 1.52 + else 1.53 + testFrameObj.setAttribute("onload", "lastTest('" + decoder + "')"); 1.54 + testFrameObj.contentDocument.location.assign(dataURI); 1.55 +} 1.56 + 1.57 +function encodeUTF16BE(string) 1.58 +{ 1.59 + var encodedString = ""; 1.60 + for (i = 0; i < string.length; ++i) { 1.61 + encodedString += "%00"; 1.62 + encodedString += encodeURI(string.charAt(i)); 1.63 + } 1.64 + return encodedString; 1.65 +} 1.66 + 1.67 +function encodeUTF16LE(string) 1.68 +{ 1.69 + var encodedString = ""; 1.70 + for (i = 0; i < string.length; ++i) { 1.71 + encodedString += encodeURI(string.charAt(i)); 1.72 + encodedString += "%00"; 1.73 + } 1.74 + return encodedString; 1.75 +} 1.76 + 1.77 +function lastTest(frame) 1.78 +{ 1.79 + testFontSize(frame); 1.80 + SimpleTest.finish(); 1.81 +} 1.82 + 1.83 +function testFontSize(frame) 1.84 +{ 1.85 + var iframeDoc = $(frame).contentDocument; 1.86 + var size = parseInt(iframeDoc.defaultView. 1.87 + getComputedStyle(iframeDoc.getElementById("testPara"), 1.88 + null). 1.89 + getPropertyValue("font-size")); 1.90 + ok(size > 0, "font size assigned for " + frame); 1.91 +} 1.92 +</script> 1.93 +</pre> 1.94 +</body> 1.95 +</html> 1.96 +