blob: 62a91100ae66c313ecbe12ea68d24e3801003029 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>Touch Adjustment : Correct for frame positions - bug 82043</title>
<script src="../resources/js-test.js"></script>
<style>
#myframe { position: absolute; left: 200px; top: 100px; width: 400px; height: 300px;}
</style>
</head>
<body onload="runTests()">
<iframe id=myframe src="resources/inner-frame.html"></iframe>
<p id='description'></p>
<div id='console'></div>
<script>
function testRoundTouch(x, y, radius)
{
var x = x - radius;
var y = y - radius;
var width = radius * 2;
var height = radius * 2;
var adjustedNode = internals.touchNodeAdjustedToBestClickableNode(x, y, width, height, document);
if (adjustedNode.nodeType == 3) // TEXT node
adjustedNode = adjustedNode.parentNode;
return adjustedNode;
}
function testDirectTouches()
{
debug('Test fat direct touches.');
adjustedNode = testRoundTouch(260, 200, 200);
shouldBeEqualToString('adjustedNode.id', 'a1');
adjustedNode = testRoundTouch(340, 200, 200);
shouldBeEqualToString('adjustedNode.id', 'a2');
}
function runTests()
{
if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) {
description('Test touch-adjustment on links in an iframe. Making sure we iframe position is correctly adjusted for.');
testDirectTouches();
finishJSTest();
}
}
jsTestIsAsync = true;
</script>
</body>
</html>