1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/text/tests/test_bug597331.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,81 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=597331 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 597331</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.13 + <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> 1.14 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.15 +</head> 1.16 +<body> 1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=597331">Mozilla Bug 597331</a> 1.18 +<p id="display"></p> 1.19 +<div id="content"> 1.20 +<textarea>line1 1.21 +line2 1.22 +line3 1.23 +</textarea> 1.24 +</div> 1.25 +<pre id="test"> 1.26 +<script type="application/javascript"> 1.27 + 1.28 +/** Test for Bug 597331 **/ 1.29 + 1.30 +// Bug 718316: This test fails on Windows 7 and 8 1.31 +if (navigator.userAgent.indexOf("Windows NT 6.1") == -1 && 1.32 + navigator.userAgent.indexOf("Windows NT 6.2") == -1) { 1.33 + 1.34 +SimpleTest.waitForExplicitFinish(); 1.35 +addLoadEvent(function() { 1.36 + SimpleTest.executeSoon(function() { 1.37 + var t = document.querySelector("textarea"); 1.38 + t.focus(); 1.39 + t.selectionStart = 4; 1.40 + t.selectionEnd = 4; 1.41 + SimpleTest.executeSoon(function() { 1.42 + t.getBoundingClientRect(); // flush layout 1.43 + var before = snapshotWindow(window, true); 1.44 + t.selectionStart = 5; 1.45 + t.selectionEnd = 5; 1.46 + t.addEventListener("keydown", function() { 1.47 + t.removeEventListener("keydown", arguments.callee, false); 1.48 + 1.49 + SimpleTest.executeSoon(function() { 1.50 + t.style.display = 'block'; 1.51 + document.body.offsetWidth; 1.52 + t.style.display = ''; 1.53 + document.body.offsetWidth; 1.54 + 1.55 + is(t.selectionStart, 4, "Cursor should be moved correctly"); 1.56 + is(t.selectionEnd, 4, "Cursor should be moved correctly"); 1.57 + 1.58 + var after = snapshotWindow(window, true); 1.59 + 1.60 + var result = compareSnapshots(before, after, true); 1.61 + var msg = "The caret should be displayed correctly after reframing"; 1.62 + if (!result[0]) { 1.63 + msg += "\nRESULT:\n" + result[2]; 1.64 + msg += "\nREFERENCE:\n" + result[1]; 1.65 + } 1.66 + ok(result[0], msg); 1.67 + 1.68 + SimpleTest.finish(); 1.69 + }); 1.70 + }, false); 1.71 + synthesizeKey("VK_LEFT", {}); 1.72 + }); 1.73 + }); 1.74 +}); 1.75 + 1.76 +} 1.77 +else { 1.78 + ok(true, "Somebody thought it was a great idea to make me type this."); 1.79 +} 1.80 + 1.81 +</script> 1.82 +</pre> 1.83 +</body> 1.84 +</html>