Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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> |