Bug 630001, part2 - fix nsAccUtils::TextLength to not use nsIFrame::GetRenderedText...
[mozilla-central.git] / editor / libeditor / text / tests / test_bug629172.html
blob91aafed9d6ebec601a1f594c7d7ee938ce9e8aef
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=629172
5 -->
6 <head>
7 <title>Test for Bug 629172</title>
8 <script type="application/javascript" src="/MochiKit/packed.js"></script>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
11 <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
12 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
13 </head>
14 <body>
15 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=629172">Mozilla Bug 629172</a>
16 <p id="display"></p>
17 <div id="content">
18 <textarea id="ltr-ref" style="display: none">test.</textarea>
19 <textarea id="rtl-ref" style="display: none; direction: rtl">test.</textarea>
20 </div>
21 <pre id="test">
22 <script type="application/javascript">
24 /** Test for Bug 629172 **/
25 SimpleTest.waitForExplicitFinish();
26 SimpleTest.waitForFocus(function() {
27 var LTRRef = document.getElementById("ltr-ref");
28 var RTLRef = document.getElementById("rtl-ref");
29 var Screenshots = {};
31 // generate the reference screenshots
32 LTRRef.style.display = "";
33 document.body.clientWidth;
34 Screenshots.ltr = snapshotWindow(window);
35 LTRRef.parentNode.removeChild(LTRRef);
36 RTLRef.style.display = "";
37 document.body.clientWidth;
38 Screenshots.rtl = snapshotWindow(window);
39 RTLRef.parentNode.removeChild(RTLRef);
40 Screenshots.get = function(dir, flip) {
41 if (flip) {
42 return this[dir == "rtl" ? "ltr" : "rtl"];
43 } else {
44 return this[dir];
48 function testDirection(initialDir) {
49 var t = document.createElement("textarea");
50 t.setAttribute("dir", initialDir);
51 t.value = "test.";
52 document.getElementById("content").appendChild(t);
53 document.body.clientWidth;
54 var s1 = snapshotWindow(window);
55 ok(compareSnapshots(s1, Screenshots.get(initialDir, false), true)[0],
56 "Textarea should appear correctly before switching the direction (" + initialDir + ")");
57 t.focus();
58 synthesizeKey("x", {accelKey: true, shiftKey: true});
59 t.blur();
60 var s2 = snapshotWindow(window);
61 ok(compareSnapshots(s2, Screenshots.get(initialDir, true), true)[0],
62 "Textarea should appear correctly after switching the direction (" + initialDir + ")");
63 t.focus();
64 synthesizeKey("x", {accelKey: true, shiftKey: true});
65 t.blur();
66 var s3 = snapshotWindow(window);
67 ok(compareSnapshots(s3, Screenshots.get(initialDir, false), true)[0],
68 "Textarea should appear correctly after switching back the direction (" + initialDir + ")");
69 t.parentNode.removeChild(t);
72 testDirection("ltr");
73 testDirection("rtl");
75 SimpleTest.finish();
76 });
78 </script>
79 </pre>
80 </body>
81 </html>