<!-- webkit-test-runner [ ScrollAnimatorEnabled=false ] --> | |
<html><body> | |
This test does the following:</br> | |
1. Navigate to an anchor link. WebKit will ensure that the anchor remains visible as other objects load around it and scripts execute.</br> | |
2. The div containing the anchor link will be scrolled via PageDown. This simulated user action should stop us locking the screen to where the anchor is.</br> | |
3. Force a repaint. If the lock to the anchor was properly released, the scroll caused by the PageDown will not be reverted and parentDiv.scrollTop will be greater than 600px (the offset of the anchor). If we return to the anchor, the test has failed.</br> | |
<a id="startLink" href="#anchor">Go to anchor</a> | |
<div id="console"></div> | |
<div id="parentDiv" style="width:500; height:300; overflow:auto"> | |
<div style="height: 600px"></div> | |
<a id="anchor"></a> | |
<div style="height: 800px"></div> | |
</div> | |
<script> | |
if (window.testRunner) { | |
testRunner.dumpAsText(); | |
testRunner.waitUntilDone(); | |
} | |
if (window.eventSender) { | |
// Lock to the anchor inside the div | |
var target = document.getElementById("startLink"); | |
eventSender.mouseMoveTo(target.offsetLeft + 2, target.offsetTop + 2); | |
eventSender.mouseDown(); | |
eventSender.mouseUp(); | |
// Perform a page down to be handled by div, should release anchor lock | |
var divInfo = document.getElementById("parentDiv"); | |
eventSender.mouseMoveTo(divInfo.offsetLeft + 2, divInfo.offsetTop + 2); | |
eventSender.mouseDown(); | |
eventSender.keyDown("pageDown"); | |
} | |
// Force layout. If the scrollbar gets reset during layout, the test has failed | |
document.getElementById("startLink").offsetHeight += 1; | |
var scrollTop = document.getElementById("parentDiv").scrollTop; | |
var line = document.createElement('div'); | |
if (scrollTop > 600) | |
line.appendChild(document.createTextNode("PASS: scrollTop is greater than 600px")); | |
else | |
line.appendChild(document.createTextNode("FAIL: scrollTop is " + scrollTop+ "px, but should be more than 600px")); | |
document.getElementById('console').appendChild(line); | |
if (window.testRunner) | |
testRunner.notifyDone(); | |
</script></body></html> |