3 <script src="../js/resources/js-test-pre.js"></script>
6 if (window.layoutTestController)
7 layoutTestController.waitUntilDone()
9 var LeftMouseButton = 0;
10 var MiddleMouseButton = 1;
13 var didClickLink1 = false;
15 window.onload = function()
17 testContainer = document.getElementById("test-container");
18 if (window.layoutTestController)
19 document.body.removeChild(document.getElementById("manual-instructions"));
23 function checkIfClickedLink1AndFinish()
26 testFailed("Link 1 was clicked, but shouldn't have been.");
28 testPassed("Link 1 wasn't clicked.");
34 if (!window.eventSender)
37 eventSender.mouseMoveTo(testContainer.offsetLeft + 10, testContainer.offsetTop + 10);
38 eventSender.mouseDown(MiddleMouseButton);
39 eventSender.mouseUp(MiddleMouseButton);
40 eventSender.mouseMoveTo(testContainer.offsetLeft + 10, testContainer.offsetTop + testContainer.offsetHeight);
41 setTimeout(clickHyperlinksIfScrolledToBottomOtherwiseFail, 500); // 500ms should be reasonable to scroll to the bottom of the <div>.
46 debug('<br /><span class="pass">TEST COMPLETE</span>');
47 document.body.removeChild(document.getElementById("test-container"));
48 if (window.layoutTestController)
49 layoutTestController.notifyDone();
52 function clickHyperlinksIfScrolledToBottomOtherwiseFail()
54 var didScrollToBottom = testContainer.scrollTop === testContainer.scrollHeight - testContainer.clientHeight;
55 if (!didScrollToBottom) {
56 testFailed("either pan scrolling is disabled or this platform doesn't support pan scrolling.");
61 if (!window.eventSender)
64 var firstLinkBoundingBox = document.getElementById("firstLink").getBoundingClientRect();
65 var secondLinkBoundingBox = document.getElementById("secondLink").getBoundingClientRect();
66 eventSender.mouseMoveTo(firstLinkBoundingBox.left + 10, firstLinkBoundingBox.top);
67 eventSender.mouseDown(LeftMouseButton);
68 eventSender.mouseUp(LeftMouseButton);
69 eventSender.leapForward(100);
70 eventSender.mouseMoveTo(secondLinkBoundingBox.left + 10, secondLinkBoundingBox.top);
71 eventSender.mouseDown(LeftMouseButton);
72 eventSender.mouseUp(LeftMouseButton);
77 <p id="description"></p>
78 <ol id="manual-instructions">
79 <li>Middle-click inside the <div> with the red border below.</li>
80 <li>Move the mouse such that you scroll the <div> until you see the hyperlinks "Link 1" and "Link 2".</li>
81 <li>Left-click the hyperlink "Link 1".</li>
82 <li>Left-click the hyperlink "Link 2".</li>
84 <div id="test-container" style="width:500px; height:100px; overflow:auto; border:2px solid red; padding:0px">
85 <div id="dummy" style="height:200px"><!-- dummy element to overflow test-container --></div>
86 <a id="firstLink" href="#" onclick="didClickLink1=true">Link 1</a> <a id="secondLink" href="#" onclick="checkIfClickedLink1AndFinish()">Link 2</a>
88 <div id="console"></div>
90 description("This test can be used to verify that clicking on a hyperlink is ignored when in pan scroll mode. <br/>" +
91 "Note, this test is expected to fail on the Apple Mac and Chromium Mac port since they don't support pan scrolling.");