helper_hittest_iframe_opacity_zero.html (1966B)
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 remote iframe inside opacity zero</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 iframe { 9 width: 300px; 10 height: 300px; 11 border: 0; 12 } 13 14 #container { 15 width: 300px; 16 height: 300px; 17 background-color: green; 18 } 19 </style> 20 </head> 21 <body> 22 <div id="container"> 23 <div style="opacity: 0; z-index: 1;"> 24 <iframe id="iframe" src="https://example.com/tests/gfx/layers/apz/test/mochitest/helper_hittest_iframe_perspective_child.html"></iframe> 25 </div> 26 </div> 27 <script type="application/javascript"> 28 async function test() { 29 // Wait for iframe to receive content transforms. 30 await SpecialPowers.spawn(iframe, [], async () => { 31 await SpecialPowers.contentTransformsReceived(content.window); 32 }); 33 34 let clickCoordsInChild = { 35 offsetX: 0, 36 offsetY: 0 37 }; 38 let childMessagePromise = new Promise(resolve => { 39 window.addEventListener("message", event => { 40 let data = JSON.parse(event.data); 41 if ("type" in data && data.type == "got-mouse-down") { 42 clickCoordsInChild = data.coords; 43 resolve(); 44 } 45 }) 46 }); 47 await synthesizeNativeMouseEventWithAPZ({ 48 type: "click", 49 target: container, 50 offsetX: 100, 51 offsetY: 100 52 }); 53 await childMessagePromise; 54 // Need to use fuzzy comparisons because the combination of floating-point 55 // matrix multiplication and rounding to integer coordinates can result in 56 // small discrepancies. 57 isfuzzy(clickCoordsInChild.offsetX, 100, 1, "x coordinate is correct"); 58 isfuzzy(clickCoordsInChild.offsetY, 100, 1, "y coordinate is correct"); 59 } 60 61 waitUntilApzStable() 62 .then(test) 63 .then(subtestDone, subtestFailed); 64 65 </script> 66 </body>