8 <script src=
"../../resources/js-test.js"></script>
11 <span id=
"select">This text is selected.
</span>
14 <script type=
"text/javascript">
18 description("This is a test for http://crbug.com/516245. It ensures that pinch-zooming and selecting doesn't autoscroll the page. To manually test, on Mac, pinch-zoom in and select text below. The page should not autoscroll.");
20 function finishTest() {
21 eventSender
.mouseUp();
23 if (document
.scrollingElement
.scrollTop
== scrollTopBefore
) {
24 testPassed("Scroll offset did not change when text selected.");
26 testFailed("Scroll offset changed when text selected.");
28 document
.getElementById('content').style
.display
= 'none';
32 function MouseWheelHandler(e
) {
36 window
.onload = function () {
37 var element
= document
.getElementById('select');
38 // The autoscroll bug happens when there is a mousewheel event listener on
40 element
.addEventListener("mousewheel", MouseWheelHandler
, false);
42 if (window
.internals
&& internals
.magnifyScaleAroundAnchor(2.5, 0, 30.2)) {
43 element
.scrollIntoView();
44 scrollTopBefore
= document
.scrollingElement
.scrollTop
;
46 var y
= element
.offsetHeight
/ 2;
47 var endX
= element
.offsetWidth
+ 100;
48 eventSender
.dragMode
= false;
49 eventSender
.mouseMoveTo(element
.offsetLeft
, y
);
50 eventSender
.mouseDown();
51 eventSender
.mouseMoveTo(endX
- 30, y
);
52 eventSender
.mouseMoveTo(endX
, y
);
53 // Wait for the autoscroll timer to fire.
54 window
.requestAnimationFrame(finishTest
);