blob: bd4b74a2d67cb4d4fd0ae12f8fdce51198ed84e1 [file] [edit]
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0;
}
iframe {
width: 300px;
height: 150px;
margin: 20.33px;
border: none;
outline: 4px solid black;
}
</style>
<script src="../../resources/js-test.js"></script>
<script>
let hitElement;
window.addEventListener('load', () => {
description('Tests that hit-testing takes subpixel iframe offsets into account');
const iframe = document.getElementsByTagName('iframe')[0];
const bounds = iframe.getBoundingClientRect();
debug('top');
hitElement = document.elementFromPoint(bounds.x + 10, bounds.y + 0.1);
shouldBe('hitElement.tagName', '"IFRAME"');
// The 0.6 is because some browsers use a pixel-sized area hit-test.
hitElement = document.elementFromPoint(bounds.x + 10, bounds.y - 0.6);
shouldBe('hitElement.tagName', '"BODY"');
debug('bottom');
hitElement = document.elementFromPoint(bounds.x + 10, bounds.bottom - 0.1);
shouldBe('hitElement.tagName', '"IFRAME"');
hitElement = document.elementFromPoint(bounds.x + 10, bounds.bottom + 0.1);
shouldBe('hitElement.tagName', '"BODY"');
debug('left');
hitElement = document.elementFromPoint(bounds.x + 0.1, bounds.y + 10);
shouldBe('hitElement.tagName', '"IFRAME"');
// The 0.6 is because some browsers use a pixel-sized area hit-test.
hitElement = document.elementFromPoint(bounds.x - 0.6, bounds.y + 10);
shouldBe('hitElement.tagName', '"BODY"');
debug('right');
hitElement = document.elementFromPoint(bounds.right - 0.1, bounds.y + 10);
shouldBe('hitElement.tagName', '"IFRAME"');
hitElement = document.elementFromPoint(bounds.right + 0.1, bounds.y + 10);
shouldBe('hitElement.tagName', '"BODY"');
}, false);
</script>
</head>
<body>
<iframe srcdoc="
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
}
div {
width: 100%;
height: 100%;
background-color: green;
}
</style>
<body>
<div></div>
</body>
"></iframe>
<div id="console"></div>
</body>
</html>