layout/generic/test/test_bug791616.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 <head>
michael@0 4 <title>Test bug 791616</title>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 8 <style>
michael@0 9 #t {
michael@0 10 overflow: auto;
michael@0 11 position: absolute;
michael@0 12 left: 200px;
michael@0 13 top: 100px;
michael@0 14 font: 14px/1.1em "Consolas","Bitstream Vera Sans Mono","Courier New",Courier,monospace;
michael@0 15 }
michael@0 16 </style>
michael@0 17 </head>
michael@0 18 <body>
michael@0 19 <p id="display"></p>
michael@0 20 <div id="t" contenteditable>
michael@0 21 <div>66666666666666</div>
michael@0 22 <div id="target">777777777777777777777777777777777777777</div>
michael@0 23 </div>
michael@0 24 </div>
michael@0 25 <pre id="test">
michael@0 26 <script class="testbody">
michael@0 27 var t = document.getElementById("t");
michael@0 28 var target = document.getElementById("target");
michael@0 29 var sel = window.getSelection();
michael@0 30 var smoothScrollPref = "general.smoothScroll";
michael@0 31
michael@0 32 SimpleTest.waitForExplicitFinish();
michael@0 33 SpecialPowers.setBoolPref(smoothScrollPref, false);
michael@0 34 t.scrollTop = 0;
michael@0 35 var targetY = target.getBoundingClientRect().top;
michael@0 36
michael@0 37 SimpleTest.waitForFocus(function() {
michael@0 38 is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled due to waitForFocus");
michael@0 39 t.focus();
michael@0 40 is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled due to focus change");
michael@0 41
michael@0 42 // Move the caret to scroll it into view
michael@0 43 sel.collapse(target.firstChild, 2);
michael@0 44 synthesizeKey("VK_LEFT", {});
michael@0 45
michael@0 46 // Delay until next repaint in case stuff is asynchronous. Also
michael@0 47 // take a trip through the event loop.
michael@0 48 setTimeout(function() {
michael@0 49 window.mozRequestAnimationFrame(function() {
michael@0 50 is(sel.anchorNode, target.firstChild, "Should have selected 'target' text node");
michael@0 51 is(sel.anchorOffset, 1, "Selection should have moved left one character");
michael@0 52 // We should not have needed to scroll the caret into view
michael@0 53 is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled");
michael@0 54 SpecialPowers.clearUserPref(smoothScrollPref);
michael@0 55 SimpleTest.finish();
michael@0 56 });
michael@0 57 // Make sure repainting actually happens.
michael@0 58 target.style.background = "yellow";
michael@0 59 });
michael@0 60 });
michael@0 61
michael@0 62 </script>
michael@0 63 </pre>
michael@0 64 </body>
michael@0 65 </html>

mercurial