helper_hittest_iframe_perspective.html (1898B)
1 <head> 2 <meta name="viewport" content="width=device-width; initial-scale=1.0"> 3 <title>Test that events are delivered with correct coordinates to an iframe inide a perspective transform</title> 4 <script src="apz_test_native_event_utils.js"></script> 5 <script src="apz_test_utils.js"></script> 6 <script src="/tests/SimpleTest/paint_listener.js"></script> 7 <style> 8 #container { 9 transform: translate3d(0px, 0px, -1000px) perspective(496.281px); 10 width: min-content; 11 } 12 iframe { 13 border: 0; 14 } 15 </style> 16 </head> 17 <body> 18 <div id="container"> 19 <iframe id="iframe" src="https://example.com/tests/gfx/layers/apz/test/mochitest/helper_hittest_iframe_perspective_child.html"></iframe> 20 </div> 21 <script type="application/javascript"> 22 async function test() { 23 // Wait for iframe to receive content transforms. 24 await SpecialPowers.spawn(iframe, [], async () => { 25 await SpecialPowers.contentTransformsReceived(content.window); 26 }); 27 28 let clickCoordsInChild = { 29 offsetX: 0, 30 offsetY: 0 31 }; 32 let childMessagePromise = new Promise(resolve => { 33 window.addEventListener("message", event => { 34 let data = JSON.parse(event.data); 35 if ("type" in data && data.type == "got-mouse-down") { 36 clickCoordsInChild = data.coords; 37 resolve(); 38 } 39 }) 40 }); 41 await synthesizeNativeMouseEventWithAPZ({ 42 type: "click", 43 target: container, 44 offsetX: 100, 45 offsetY: 100 46 }); 47 await childMessagePromise; 48 // Need to use fuzzy comparisons because the combination of floating-point 49 // matrix multiplication and rounding to integer coordinates can result in 50 // small discrepancies. 51 isfuzzy(clickCoordsInChild.offsetX, 100, 1, "x coordinate is correct"); 52 isfuzzy(clickCoordsInChild.offsetY, 100, 1, "y coordinate is correct"); 53 } 54 55 waitUntilApzStable() 56 .then(test) 57 .then(subtestDone, subtestFailed); 58 59 </script> 60 </body>