layout/base/tests/test_bug399284.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=399284
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 399284</title>
michael@0 8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=399284">Mozilla Bug 399284</a>
michael@0 13 <p id="display"></p>
michael@0 14 <div id="content" style="display: none">
michael@0 15 </div>
michael@0 16 <pre id="test">
michael@0 17 <script class="testbody" type="text/javascript">
michael@0 18 /** Test for Bug 399284 **/
michael@0 19 const testContent = "<p id='testPara'>The quick brown fox jumps over the lazy dog";
michael@0 20
michael@0 21 const Ci = SpecialPowers.Ci;
michael@0 22 const Cc = SpecialPowers.Cc;
michael@0 23 var ccManager = Cc["@mozilla.org/charset-converter-manager;1"].getService(Ci.nsICharsetConverterManager);
michael@0 24
michael@0 25 var decoderList = ccManager.getDecoderList();
michael@0 26 SimpleTest.waitForExplicitFinish();
michael@0 27 while (decoderList.hasMore()) {
michael@0 28 var decoder = decoderList.getNext();
michael@0 29
michael@0 30 // encode the content for non-ASCII compatible encodings
michael@0 31 if (decoder == "UTF-16BE")
michael@0 32 data = encodeUTF16BE(testContent);
michael@0 33 else if (decoder == "UTF-16" || decoder == "UTF-16LE")
michael@0 34 data = encodeUTF16LE(testContent);
michael@0 35 else if (decoder == "replacement" ||
michael@0 36 decoder == "ISO-2022-KR" ||
michael@0 37 decoder == "ISO-2022-CN")
michael@0 38 continue;
michael@0 39 else
michael@0 40 data = encodeURI(testContent);
michael@0 41 var dataURI = "data:text/html;charset=" + decoder + "," + data;
michael@0 42
michael@0 43 var testFrame = document.createElement("iframe");
michael@0 44 frameID = decoder;
michael@0 45 testFrame.setAttribute("id", frameID);
michael@0 46 var testFrameObj = document.body.appendChild(testFrame);
michael@0 47 if (decoderList.hasMore())
michael@0 48 testFrameObj.setAttribute("onload", "testFontSize('" + decoder + "')");
michael@0 49 else
michael@0 50 testFrameObj.setAttribute("onload", "lastTest('" + decoder + "')");
michael@0 51 testFrameObj.contentDocument.location.assign(dataURI);
michael@0 52 }
michael@0 53
michael@0 54 function encodeUTF16BE(string)
michael@0 55 {
michael@0 56 var encodedString = "";
michael@0 57 for (i = 0; i < string.length; ++i) {
michael@0 58 encodedString += "%00";
michael@0 59 encodedString += encodeURI(string.charAt(i));
michael@0 60 }
michael@0 61 return encodedString;
michael@0 62 }
michael@0 63
michael@0 64 function encodeUTF16LE(string)
michael@0 65 {
michael@0 66 var encodedString = "";
michael@0 67 for (i = 0; i < string.length; ++i) {
michael@0 68 encodedString += encodeURI(string.charAt(i));
michael@0 69 encodedString += "%00";
michael@0 70 }
michael@0 71 return encodedString;
michael@0 72 }
michael@0 73
michael@0 74 function lastTest(frame)
michael@0 75 {
michael@0 76 testFontSize(frame);
michael@0 77 SimpleTest.finish();
michael@0 78 }
michael@0 79
michael@0 80 function testFontSize(frame)
michael@0 81 {
michael@0 82 var iframeDoc = $(frame).contentDocument;
michael@0 83 var size = parseInt(iframeDoc.defaultView.
michael@0 84 getComputedStyle(iframeDoc.getElementById("testPara"),
michael@0 85 null).
michael@0 86 getPropertyValue("font-size"));
michael@0 87 ok(size > 0, "font size assigned for " + frame);
michael@0 88 }
michael@0 89 </script>
michael@0 90 </pre>
michael@0 91 </body>
michael@0 92 </html>
michael@0 93

mercurial