window_bug659071.html (2226B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test for Bug 659071</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <script src="/tests/SimpleTest/EventUtils.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 8 </head> 9 <body> 10 <video id="v" controls></video> 11 <script type="application/javascript"> 12 13 SimpleTest.waitForFocus(runTests, window); 14 15 function ok() { 16 window.opener.ok.apply(window.opener, arguments); 17 } 18 19 function info() { 20 window.opener.info.apply(window.opener, arguments); 21 } 22 23 async function waitForCondition(aFunc) { 24 for (let i = 0; i < 30; i++) { 25 await (new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))); 26 if (aFunc(SpecialPowers.getFullZoom(window))) { 27 return true; 28 } 29 } 30 return false; 31 } 32 33 async function runTests() { 34 await SpecialPowers.pushPrefEnv( 35 { 36 "set": [ 37 ["mousewheel.with_control.action", 3], 38 ["test.events.async.enabled", true], 39 ] 40 } 41 ); 42 43 const video = document.getElementById("v"); 44 45 for (let i = 0; i < 3; i++) { 46 synthesizeWheel(video, 10, 10, 47 { deltaMode: WheelEvent.DOM_DELTA_LINE, ctrlKey: true, 48 deltaX: 0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 }); 49 if (await waitForCondition(aZoomLevel => aZoomLevel < 1.0)) { 50 break; 51 } 52 info("Retrying zoom out..."); 53 } 54 let zoomLevel = SpecialPowers.getFullZoom(window); 55 ok( 56 zoomLevel < 1.0, 57 `Failed to zoom out with turning wheel to bottom, got: ${zoomLevel}` 58 ); 59 60 for (let i = 0; i < 4; i++) { 61 synthesizeWheel(video, 10, 10, 62 { deltaMode: WheelEvent.DOM_DELTA_LINE, ctrlKey: true, 63 deltaX: 0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 }); 64 if (await waitForCondition(aZoomLevel => aZoomLevel > 1.0)) { 65 break; 66 } 67 info("Retrying zoom in..."); 68 } 69 zoomLevel = SpecialPowers.getFullZoom(window); 70 ok( 71 zoomLevel > 1.0, 72 `Failed to zoom in with turning wheel to top, got: ${zoomLevel}` 73 ); 74 75 synthesizeKey("0", { accelKey: true }); 76 ok( 77 await waitForCondition(aZoomLevel => aZoomLevel == 1.0), 78 "Failed to reset zoom at finish the test" 79 ); 80 opener.finish(); 81 } 82 83 </script> 84 </body> 85 </html>