blob: 8799470cb62506cea73004ad2d3e59eadaa0bf8e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<style>
#container {
position: absolute;
top: 100px;
left: 10px;
width: 400px;
outline: 1px solid black;
font-family: monospace;
}
</style>
<script src="../../resources/js-test-pre.js"></script>
<script>
window.jsTestIsAsync = true;
const headerHeight = 32;
const pageScale = 1.8;
var mouseXStart;
var mouseXEnd;
var mouseY;
var currMouseX;
var firstRange;
if (window.internals)
internals.setHeaderHeight(headerHeight);
function testComplete()
{
eventSender.mouseMoveTo(mouseXEnd, mouseY);
eventSender.mouseUp();
firstRange = window.getSelection().getRangeAt(0);
shouldBe('firstRange.startOffset', '79');
shouldBe('firstRange.endOffset', '103');
finishJSTest();
}
function doOneMouseMove()
{
if (currMouseX >= mouseXEnd) {
testComplete();
return;
}
eventSender.mouseMoveTo(currMouseX, mouseY);
currMouseX += 2;
window.setTimeout(doOneMouseMove, 2);
}
function doTest()
{
if (!window.testRunner || !window.eventSender) {
debug('This test requires testRunner and eventSender');
return;
}
window.internals.setPageScaleFactor(pageScale, 0, 0);
var containerRect = document.getElementById('container').getBoundingClientRect();
var lineHeight = containerRect.height / 3;
mouseXStart = pageScale * (containerRect.left + containerRect.width / 2);
mouseY = headerHeight + pageScale * (containerRect.top + lineHeight / 2);
mouseXEnd = pageScale * (containerRect.right - 10);
currMouseX = mouseXStart;
eventSender.mouseMoveTo(currMouseX, mouseY);
eventSender.mouseDown();
doOneMouseMove();
}
window.addEventListener('load', doTest, false);
</script>
</head>
<body>
<p>This test ensures that drag-selecting works correctly in scaled pages.</p>
<div id="container">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div id="console"></div>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>