Source code

Revision control

Copy as Markdown

Other Tools

<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Test that events are delivered with correct coordinates to an iframe inide a perspective transform</title>
<script src="apz_test_native_event_utils.js"></script>
<script src="apz_test_utils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
#container {
transform: translate3d(0px, 0px, -1000px) perspective(496.281px);
width: min-content;
}
iframe {
border: 0;
}
</style>
</head>
<body>
<div id="container">
</div>
<script type="application/javascript">
async function test() {
// Wait for iframe to receive content transforms.
await SpecialPowers.spawn(iframe, [], async () => {
await SpecialPowers.contentTransformsReceived(content.window);
});
let clickCoordsInChild = {
offsetX: 0,
offsetY: 0
};
let childMessagePromise = new Promise(resolve => {
window.addEventListener("message", event => {
let data = JSON.parse(event.data);
if ("type" in data && data.type == "got-mouse-down") {
clickCoordsInChild = data.coords;
resolve();
}
})
});
await synthesizeNativeMouseEventWithAPZ({
type: "click",
target: container,
offsetX: 100,
offsetY: 100
});
await childMessagePromise;
// Need to use fuzzy comparisons because the combination of floating-point
// matrix multiplication and rounding to integer coordinates can result in
// small discrepancies.
isfuzzy(clickCoordsInChild.offsetX, 100, 1, "x coordinate is correct");
isfuzzy(clickCoordsInChild.offsetY, 100, 1, "y coordinate is correct");
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</body>