content/base/test/test_bug890580.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=890580
     5 -->
     6 <head>
     7   <meta charset="utf-8">
     8   <title>Test for Bug 883129</title>
     9   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11   <script type="application/javascript">
    12   function testPaintextSerializerWithPlaceHolder() {
    13     const de = SpecialPowers.Ci.nsIDocumentEncoder;
    14     const Cc = SpecialPowers.Cc;
    16     // Create a plaintext encoder with the flag OutputNonTextContentAsPlaceholder.
    17     var encoder = Cc["@mozilla.org/layout/documentEncoder;1?type=text/plain"]
    18                   .createInstance(de);
    19     var flags = de.OutputRaw |
    20                 de.OutputNonTextContentAsPlaceholder;
    21     encoder.init(document, "text/plain", flags);
    23     function toPlaintext(id) {
    24       var element = document.getElementById(id);
    25       var range = document.createRange();
    26       range.selectNodeContents(element);
    27       encoder.setRange(range);
    28       return encoder.encodeToString();
    29     }
    31     // The follows are test cases.
    32     is(toPlaintext("case1"), "This is a button. Hello!", "test with <button>");
    33     is(toPlaintext("case2"), "There is an\uFFFCimage.", "test with <img>");
    34     is(toPlaintext("case3"), "\uFFFC with text.", "test with <input>");
    35     is(toPlaintext("case4"), "There is an\uFFFCimage and a \uFFFC.",
    36        "test with <img> and <input>");
    38     SimpleTest.finish();
    39   }
    41   addLoadEvent(testPaintextSerializerWithPlaceHolder);
    42   SimpleTest.waitForExplicitFinish();
    43   </script>
    44 </head>
    45 <body>
    46 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=890580">Mozilla Bug 890580</a>
    47 <p id="display"></p>
    48 <div id="content" style="display: none">
    49   <span id="case1"><button id="b">This is a button.</button> Hello!</span>
    50   <span id="case2">There is an<img>image.</span>
    51   <span id="case3"><input type="button" value="Input button"> with text.</span>
    52   <span id="case4" contenteditable="true">There is an<img>image and
    53   a <input type="button" value="button">.</span>
    54 </div>
    55 <pre id="test">
    56 </pre>
    57 </body>
    58 </html>

mercurial