Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / scroll-behavior / no-erroneous-auto-scroll-pinch-zoom.html
blobc273230ac85d48c51b2f987b286b29df08f033be
1 <!DOCTYPE html>
2 <style>
3 #content {
4 width: 1000px;
5 height: 1000px;
7 </style>
8 <script src="../../resources/js-test.js"></script>
10 <div id="content">
11 <span id="select">This text is selected.</span>
12 </div>
14 <script type="text/javascript">
15 var scrollTopBefore;
17 jsTestIsAsync = true;
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.");
25 } else {
26 testFailed("Scroll offset changed when text selected.");
28 document.getElementById('content').style.display = 'none';
29 finishJSTest();
32 function MouseWheelHandler(e) {
33 return false;
36 window.onload = function () {
37 var element = document.getElementById('select');
38 // The autoscroll bug happens when there is a mousewheel event listener on
39 // the page.
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);
57 </script>