Thu, 15 Jan 2015 21:03:48 +0100
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.)
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>