WheelEvent.ctrlKey.zoom.html (3168B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title id='desc'> WheelEvent: wheel - MouseEvent.ctrlKey and Zooming </title> 5 <script type="text/javascript"> 6 var PassTest = function() 7 { 8 document.getElementById("testresult").firstChild.data = "PASS"; 9 } 10 11 var FailTest = function() 12 { 13 document.getElementById("testresult").firstChild.data = "FAIL"; 14 } 15 16 function DisableZooming() 17 { 18 BEFORE = HELPER.getBoundingClientRect().width; 19 DisableZoom = true; 20 } 21 22 function VerifyResult() 23 { 24 AFTER = HELPER.getBoundingClientRect().width; 25 26 if ((true == DisableZoom) && (true == TestResult) && (BEFORE == AFTER)) 27 { 28 PassTest(); 29 } 30 else 31 { 32 FailTest(); 33 } 34 } 35 36 function TestEvent(evt) 37 { 38 if ((true == DisableZoom) && (true == evt.ctrlKey) && (EVENT == evt.type)) 39 { 40 evt.preventDefault(); 41 TestResult = evt.defaultPrevented; 42 } 43 } 44 45 var EVENT = "wheel"; 46 var TARGET; 47 var HELPER; 48 var BEFORE; 49 var AFTER; 50 var DisableZoom = false; 51 var TestResult = false; 52 53 window.onload = function() 54 { 55 try 56 { 57 TARGET = document; 58 HELPER = document.getElementById("helper"); 59 TARGET.addEventListener(EVENT, TestEvent, true); 60 } 61 catch(ex) 62 { 63 FailTest(); 64 } 65 } 66 </script> 67 </head> 68 <body> 69 <h3>DOM Events</h3> 70 <h4> 71 Test Description: The typical default action of the wheel event type, in some cases, is to 72 zoom the document. If this event is canceled, the implementation must not zoom the document. 73 </h4> 74 75 <div id="helper" style="width:100%"></div> 76 77 <p id="manualsteps"> 78 Steps: 79 <ol> 80 <li> Note: an input device with scroll wheel support (e.g., mouse wheel) is required 81 <li> Make sure the page can be zoomed in/out by holding down '{CTRL}' key + scrolling the mouse wheel on the page 82 <li> Now, click the button: <button id="verify" onclick="DisableZooming()">Disable Zooming</button> 83 <li> Press and hold down '{CTRL}' key on the keyboard 84 <li> Move the mouse pointer to the center of the page 85 <li> Scroll down/up the mouse wheel some units 86 <li> Click the button: <button id="verify" onclick="VerifyResult()">VerifyResult</button> 87 </ol> 88 </p> 89 <p>Test passes if the word "PASS" appears below after following the above steps.</p> 90 <div>Test result: </div> 91 <div id='testresult'>FAIL</div> 92 </body> 93 </html>