blob: 99f009ea9e01ccde695f5a62d5d84f63daf1be70 [file] [log] [blame]
<html>
<head>
<script src="../../../../resources/js-test-pre.js"></script>
<script>
if (window.testRunner)
testRunner.waitUntilDone()
var LeftMouseButton = 0;
var MiddleMouseButton = 1;
var testContainer;
var didClickLink1 = false;
window.onload = function()
{
testContainer = document.getElementById("test-container");
if (window.testRunner)
document.body.removeChild(document.getElementById("manual-instructions"));
runTest();
}
function checkIfClickedLink1AndFinish()
{
if (didClickLink1)
testFailed("Link 1 was clicked, but shouldn't have been.");
else
testPassed("Link 1 wasn't clicked.");
finished();
}
function runTest()
{
if (!window.eventSender)
return;
eventSender.mouseMoveTo(testContainer.offsetLeft + 10, testContainer.offsetTop + 10);
eventSender.mouseDown(MiddleMouseButton);
eventSender.mouseUp(MiddleMouseButton);
eventSender.mouseMoveTo(testContainer.offsetLeft + 10, testContainer.offsetTop + testContainer.offsetHeight);
setTimeout(clickHyperlinksIfScrolledToBottomOtherwiseFail, 500); // 500ms should be reasonable to scroll to the bottom of the <div>.
}
function finished()
{
debug('<br /><span class="pass">TEST COMPLETE</span>');
document.body.removeChild(document.getElementById("test-container"));
if (window.testRunner)
testRunner.notifyDone();
}
function clickHyperlinksIfScrolledToBottomOtherwiseFail()
{
var didScrollToBottom = testContainer.scrollTop === testContainer.scrollHeight - testContainer.clientHeight;
if (!didScrollToBottom) {
testFailed("either pan scrolling is disabled or this platform doesn't support pan scrolling.");
finished();
return;
}
if (!window.eventSender)
return;
var firstLinkBoundingBox = document.getElementById("firstLink").getBoundingClientRect();
var secondLinkBoundingBox = document.getElementById("secondLink").getBoundingClientRect();
eventSender.mouseMoveTo(firstLinkBoundingBox.left + 10, firstLinkBoundingBox.top);
eventSender.mouseDown(LeftMouseButton);
eventSender.mouseUp(LeftMouseButton);
eventSender.leapForward(100);
eventSender.mouseMoveTo(secondLinkBoundingBox.left + 10, secondLinkBoundingBox.top);
eventSender.mouseDown(LeftMouseButton);
eventSender.mouseUp(LeftMouseButton);
}
</script>
</head>
<body>
<p id="description"></p>
<ol id="manual-instructions">
<li>Middle-click inside the &lt;div&gt; with the red border below.</li>
<li>Move the mouse such that you scroll the &lt;div&gt; until you see the hyperlinks &quot;Link 1&quot; and &quot;Link 2&quot;.</li>
<li>Left-click the hyperlink &quot;Link 1&quot;.</li>
<li>Left-click the hyperlink &quot;Link 2&quot;.</li>
</ol>
<div id="test-container" style="width:500px; height:100px; overflow:auto; border:2px solid red; padding:0px">
<div id="dummy" style="height:200px"><!-- dummy element to overflow test-container --></div>
<a id="firstLink" href="#" onclick="didClickLink1=true">Link 1</a> <a id="secondLink" href="#" onclick="checkIfClickedLink1AndFinish()">Link 2</a>
</div>
<div id="console"></div>
<script>
description("This test can be used to verify that clicking on a hyperlink is ignored when in pan scroll mode. <br/>" +
"Note, this test is expected to fail on the Apple Mac and Chromium Mac port since they don't support pan scrolling.");
</script>
</body>
</html>