helper_bug1889017_fullscreen.html (2145B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1889017 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <!-- 9 No meta viewport tag. We want the page to load with a desktop viewport, 10 which is set to a width of 600px in test_group_touchevents-4.html. 11 --> 12 <title>Test for Bug 1889017</title> 13 <script src="/tests/SimpleTest/paint_listener.js"></script> 14 <script src="/tests/SimpleTest/EventUtils.js"></script> 15 <script type="application/javascript" src="apz_test_native_event_utils.js"></script> 16 <script type="application/javascript" src="apz_test_utils.js"></script> 17 <style> 18 #fullscreen { 19 position: absolute; 20 width: 800px; 21 height: 800px; 22 background: yellow; 23 } 24 /* The target element is beyond the 600px viewport width. */ 25 #target { 26 margin-top: 50px; 27 margin-left: 650px; 28 width: 100px; 29 height: 100px; 30 background: green; 31 } 32 </style> 33 </head> 34 <body> 35 <div id="fullscreen"> 36 <div id="target"> 37 </div> 38 <script type="application/javascript"> 39 40 async function test() { 41 // Enter fullscreen mode. 42 await fullscreen.requestFullscreen(); 43 44 // In fullscreen mode, try to tap the target element. 45 let mouseDownEvent = null; 46 let mouseDownPromise = new Promise(resolve => { 47 // Set the event listener on `window`, not `target`. 48 // This way, even if the event is incorrectly targeted, 49 // the test will not time out (instead, the assertion 50 // about `event.target` will fail). 51 window.addEventListener("mousedown", function(e) { 52 mouseDownEvent = e; 53 resolve(); 54 }); 55 }); 56 await synthesizeNativeTap(target, 10, 10); 57 await mouseDownPromise; 58 is(mouseDownEvent.target, target, "mousedown event targeted the correct element"); 59 } 60 61 if (getPlatform() == "android") { 62 waitUntilApzStable() 63 .then(test) 64 .then(subtestDone, subtestFailed); 65 } else { 66 // The test is only run on Android because on desktop, the display 67 // size changes when entering fullscreen mode, which prevents the 68 // bug from reproducing. 69 ok(true, "This subtest is only run on Android"); 70 subtestDone(); 71 } 72 73 </script> 74 </body> 75 </html>