editor/libeditor/text/tests/test_bug629172.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial