<!DOCTYPE HTML>
<script src="../../../../resources/js-test.js"></script>
<style>
#container {
position: absolute;
right: 0;
top: 0;
padding: 50px;
}
#frame {
width: 75px;
height: 75px;
border: 1px solid black;
}
</style>
<div id=container>
<iframe id=frame></iframe>
</div>
<script>
description("Verify that in the absence of any reason to adjust into an iframe, taps are handle in the frame matching the center point of the tap. bug 401504");
var sawClick = false;
function nodeName(node) {
var name = node.nodeName;
if (node.id)
name += '#' + node.id;
return name;
}
document.addEventListener('click', function(e) {
sawClick = true;
debug("Received click on " + nodeName(e.target));
});
function doTap(name, x, y, expectFrame) {
// Sanity check
var e = document.elementFromPoint(x, y);
var onFrame = e == frame;
if (onFrame != expectFrame)
testFailed("Point-based hit-test returned unexpected element: " + nodeName(e));
eventSender.gestureTapDown(x, y);
eventSender.gestureShowPress(x, y);
debug("Sending GestureTap " + name);
sawClick = false;
eventSender.gestureTap(x, y);
shouldBe('sawClick', onFrame ? 'false' : 'true');
debug("");
}
var rect = frame.getBoundingClientRect();
var midx = rect.left + rect.width / 2;
var midy = rect.top + rect.height / 2;
doTap("on top of iframe", midx, midy, true);
doTap("above iframe", midx, rect.top - 1, false);
doTap("to the left of iframe", rect.left - 1, midy, false);
doTap("to the right of iframe", rect.right + 1, midy, false);
doTap("below iframe", midx, rect.bottom + 1, false);
</script>