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

     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 type="text/javascript" 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";
    21 const Ci = SpecialPowers.Ci;
    22 const Cc = SpecialPowers.Cc;
    23 var ccManager = Cc["@mozilla.org/charset-converter-manager;1"].getService(Ci.nsICharsetConverterManager);
    25 var decoderList = ccManager.getDecoderList();
    26 SimpleTest.waitForExplicitFinish();
    27 while (decoderList.hasMore()) {
    28     var decoder =  decoderList.getNext();
    30     // encode the content for non-ASCII compatible encodings
    31     if (decoder == "UTF-16BE")
    32         data = encodeUTF16BE(testContent);
    33     else if (decoder == "UTF-16" || decoder == "UTF-16LE")
    34         data = encodeUTF16LE(testContent);
    35     else if (decoder == "replacement" || 
    36              decoder == "ISO-2022-KR" || 
    37              decoder == "ISO-2022-CN")
    38         continue;
    39     else
    40         data = encodeURI(testContent);
    41     var dataURI = "data:text/html;charset=" + decoder + "," + data;
    43     var testFrame = document.createElement("iframe");
    44     frameID = decoder;
    45     testFrame.setAttribute("id", frameID);
    46     var testFrameObj = document.body.appendChild(testFrame);
    47     if (decoderList.hasMore())
    48         testFrameObj.setAttribute("onload", "testFontSize('" + decoder + "')");
    49     else
    50         testFrameObj.setAttribute("onload", "lastTest('" + decoder + "')");
    51     testFrameObj.contentDocument.location.assign(dataURI);
    52 }
    54 function encodeUTF16BE(string)
    55 {
    56     var encodedString = "";
    57     for (i = 0; i < string.length; ++i) {
    58         encodedString += "%00";
    59         encodedString += encodeURI(string.charAt(i));
    60     }
    61     return encodedString;
    62 }
    64 function encodeUTF16LE(string)
    65 {
    66     var encodedString = "";
    67     for (i = 0; i < string.length; ++i) {
    68         encodedString += encodeURI(string.charAt(i));
    69         encodedString += "%00";
    70     }
    71     return encodedString;
    72 }
    74 function lastTest(frame)
    75 {
    76     testFontSize(frame);
    77     SimpleTest.finish();
    78 }
    80 function testFontSize(frame)
    81 {
    82     var iframeDoc = $(frame).contentDocument;
    83     var size = parseInt(iframeDoc.defaultView.
    84                 getComputedStyle(iframeDoc.getElementById("testPara"), 
    85                                  null).
    86                 getPropertyValue("font-size"));
    87     ok(size > 0, "font size assigned for " + frame);
    88 }
    89 </script>
    90 </pre>
    91 </body>
    92 </html>

mercurial