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.

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

mercurial