1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/test/test_bug791616.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test bug 791616</title> 1.8 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.10 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.11 + <style> 1.12 +#t { 1.13 + overflow: auto; 1.14 + position: absolute; 1.15 + left: 200px; 1.16 + top: 100px; 1.17 + font: 14px/1.1em "Consolas","Bitstream Vera Sans Mono","Courier New",Courier,monospace; 1.18 +} 1.19 + </style> 1.20 +</head> 1.21 +<body> 1.22 +<p id="display"></p> 1.23 +<div id="t" contenteditable> 1.24 + <div>66666666666666</div> 1.25 + <div id="target">777777777777777777777777777777777777777</div> 1.26 +</div> 1.27 +</div> 1.28 +<pre id="test"> 1.29 +<script class="testbody"> 1.30 +var t = document.getElementById("t"); 1.31 +var target = document.getElementById("target"); 1.32 +var sel = window.getSelection(); 1.33 +var smoothScrollPref = "general.smoothScroll"; 1.34 + 1.35 +SimpleTest.waitForExplicitFinish(); 1.36 +SpecialPowers.setBoolPref(smoothScrollPref, false); 1.37 +t.scrollTop = 0; 1.38 +var targetY = target.getBoundingClientRect().top; 1.39 + 1.40 +SimpleTest.waitForFocus(function() { 1.41 + is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled due to waitForFocus"); 1.42 + t.focus(); 1.43 + is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled due to focus change"); 1.44 + 1.45 + // Move the caret to scroll it into view 1.46 + sel.collapse(target.firstChild, 2); 1.47 + synthesizeKey("VK_LEFT", {}); 1.48 + 1.49 + // Delay until next repaint in case stuff is asynchronous. Also 1.50 + // take a trip through the event loop. 1.51 + setTimeout(function() { 1.52 + window.mozRequestAnimationFrame(function() { 1.53 + is(sel.anchorNode, target.firstChild, "Should have selected 'target' text node"); 1.54 + is(sel.anchorOffset, 1, "Selection should have moved left one character"); 1.55 + // We should not have needed to scroll the caret into view 1.56 + is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled"); 1.57 + SpecialPowers.clearUserPref(smoothScrollPref); 1.58 + SimpleTest.finish(); 1.59 + }); 1.60 + // Make sure repainting actually happens. 1.61 + target.style.background = "yellow"; 1.62 + }); 1.63 +}); 1.64 + 1.65 +</script> 1.66 +</pre> 1.67 +</body> 1.68 +</html>