blob: 1f289ff41cef74d6a229cee27c30629c91e29a4e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../../resources/basic-gestures.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
async function runTest()
{
if (!testRunner.runUIScript)
return;
var output = '';
var firstTargetRect = document.getElementById('firstSelection').getBoundingClientRect();
var secondTargetRect = document.getElementById('secondSelection').getBoundingClientRect();
var thirdTargetRect = document.getElementById('thirdSelection').getBoundingClientRect();
var pressPointX = firstTargetRect.x+firstTargetRect.width / 2;
var pressPointY = firstTargetRect.y+firstTargetRect.height / 2;
var dragY = firstTargetRect.y;
var dragX = firstTargetRect.x;
var dragY2 = secondTargetRect.y;
var dragY3 = thirdTargetRect.y;
var dragY4 = firstTargetRect.y + firstTargetRect.height;
await longPressAtPoint(pressPointX, pressPointY);
if (document.getSelection().toString() == "ut")
output += 'PASS: Correct Selection';
else
output += 'FAIL: failed to select a word as a result of a long press. Incorrect Selection: ' + document.getSelection().toString();
output += '<br>';
await touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY2);
if (document.getSelection().toString() == "o eiusmod tempor incididunt ut")
output += 'PASS: Correct Selection';
else
output += 'FAIL: failed to select additional line after a drag. Incorrect Selection: ' + document.getSelection().toString();
output += '<br>';
await touchAndDragFromPointToPoint(dragX, dragY2, dragX, dragY3);
if (document.getSelection().toString() == " adipiscing elit, sed do eiusmod tempor incididunt ut")
output += 'PASS: Correct Selection';
else
output += 'FAIL: failed to select additional line after a drag. Incorrect Selection: ' + document.getSelection().toString();
output += '<br>';
await touchAndDragFromPointToPoint(dragX, dragY3, dragX, dragY2);
if (document.getSelection().toString() == "o eiusmod tempor incididunt ut")
output += 'PASS: Correct Selection';
else
output += 'FAIL: failed to deselect line after a drag. Incorrect Selection: ' + document.getSelection().toString();
output += '<br>';
await touchAndDragFromPointToPoint(dragX, dragY2, dragX, dragY);
if (document.getSelection().toString() == "ut")
output += 'PASS: Correct Selection';
else
output += 'FAIL: failed to deselect line after a drag. Incorrect Selection: ' + document.getSelection().toString();
output += '<br>';
var result = await touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY4);
if (document.getSelection().toString() == "ut")
output += 'PASS: Correct Selection';
else
output += 'FAIL: failed to reduce selection to a single character by dragging down. Incorrect Selection: ' + document.getSelection().toString();
output += '<br>';
output += result;
document.getElementById('target').innerHTML = output;
testRunner.notifyDone();
}
window.addEventListener('load', runTest, false);
</script>
<style>
#target {
height: 400px;
width: 300px;
background-color: silver;
font-family: monospace;
font-size: 18px;
}
</style>
<meta name="viewport" content="initial-scale=1">
</head>
<body>
<div id="target">
<p>Lorem ipsum dolor sit amet, consectetur<span id="thirdSelection"></span> adipiscing elit, sed d<span id="secondSelection"></span>o eiusmod tempor incididunt <span id="firstSelection">ut</span> 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.</p>
This test requires UIScriptController to run.
</div>
</body>
</html>