content/base/test/test_bug270145.xhtml

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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

mercurial