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 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=902847
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 902847</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() {
14 const de = SpecialPowers.Ci.nsIDocumentEncoder;
15 const Cc = SpecialPowers.Cc;
17 // Create a plaintext encoder.
18 var encoder = Cc["@mozilla.org/layout/documentEncoder;1?type=text/plain"]
19 .createInstance(de);
20 var flags = de.OutputRaw |
21 de.OutputLFLineBreak |
22 de.OutputDontRemoveLineEndingSpaces;
23 encoder.init(document, "text/plain", flags);
25 function toPlaintext(id) {
26 var element = document.getElementById(id);
27 var range = document.createRange();
28 range.selectNodeContents(element);
29 encoder.setRange(range);
30 return encoder.encodeToString().replace('\n', '\\n', 'g')
31 .replace('\r', '\\r', 'g');
32 }
34 // Test cases.
35 is(toPlaintext("case1"), "Hello \\nboy!", "Case 1 failed.");
36 is(toPlaintext("case2"), "Hello \\nboy!", "Case 2 failed.");
37 is(toPlaintext("case3"), "Hello \\nboy!", "Case 3 failed.");
38 is(toPlaintext("case4"), "Hello \\nboy!", "Case 4 failed.");
39 SimpleTest.finish();
40 }
42 addLoadEvent(testPaintextSerializerWithPlaceHolder);
43 SimpleTest.waitForExplicitFinish();
44 </script>
45 </head>
46 <body>
47 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=902847">Mozilla Bug 902847</a>
48 <p id="display"></p>
49 <div id="content">
50 <p id="case1">Hello <br>boy!</p>
51 <p id="case2">Hello <br>boy!</p>
52 <p id="case3">Hello <br>boy!</p>
53 <p id="case4">Hello <br>boy!</p>
54 </div>
55 <pre id="test">
56 </pre>
57 </body>
58 </html>