content/base/test/test_bug270145.xhtml

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <html xmlns="http://www.w3.org/1999/xhtml">
     2 <!--
     3 https://bugzilla.mozilla.org/show_bug.cgi?id=270145
     4 -->
     5 <head>
     6   <title>Test the html copy encoder with XHTML </title>
     7   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     8   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     9 </head>
    10 <body>
    11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=270145">Mozilla Bug 270145</a>
    12 <p id="display"></p>
    13 <div id="content" >
    14 <p id="foo"><![CDATA[a text to copy]]></p>
    15 </div>
    16 <pre id="test">
    17 <script class="testbody" type="text/javascript">
    18 //<![CDATA[
    19 function testHtmlCopyEncoder () {
    20   const de = SpecialPowers.Ci.nsIDocumentEncoder;
    21   var encoder = SpecialPowers.Cc["@mozilla.org/layout/htmlCopyEncoder;1"]
    22                    .createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
    23   var out, expected;
    25   var node = document.getElementById('draggable');
    27   var select = window.getSelection();
    28   select.removeAllRanges();
    30   node = document.getElementById("foo").firstChild;
    31   var range = document.createRange();
    32   range.setStart(node, 0);
    33   range.setEnd(node, "a text to copy".length);
    34   select.addRange(range);
    35   encoder.init(document, "text/html", 0);
    36   encoder.setSelection(select);
    37   out = encoder.encodeToString();
    38   expected = "a text to copy";
    39   is(out, expected, "test xhtml copy");
    41   SimpleTest.finish();
    42 }
    45 SimpleTest.waitForExplicitFinish();
    47 addLoadEvent(testHtmlCopyEncoder);
    48 //]]>
    49 </script>
    50 </pre>
    52 </body>
    53 </html>

mercurial