WheelEvent.Capture.Bubble.html (3245B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title id='desc'> WheelEvent: wheel Event capturing/bubbling </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 TestBubble(evt) 17 { 18 if (EVENT == evt.type) 19 { 20 ActualResult.push(evt.currentTarget); 21 } 22 23 if ((3 == evt.eventPhase) && (window === evt.currentTarget)) 24 { 25 if (ExpectResult.toString() == ActualResult.toString()) 26 { 27 PassTest(); 28 } 29 else 30 { 31 FailTest(); 32 } 33 34 for (var i=0; i < CURRENTTARGETS.length; i++) 35 { 36 CURRENTTARGETS[i].removeEventListener(EVENT, TestBubble, true); 37 CURRENTTARGETS[i].removeEventListener(EVENT, TestBubble, false); 38 } 39 } 40 } 41 42 var EVENT = "wheel"; 43 var TARGET, PARENT, CURRENTTARGETS; 44 var ExpectResult = []; 45 var ActualResult = []; 46 47 window.onload = function() 48 { 49 try 50 { 51 TARGET = document.getElementById("target"); 52 PARENT = document.getElementById("parent"); 53 CURRENTTARGETS = [window, document, document.body, PARENT, TARGET]; 54 ExpectResult = CURRENTTARGETS + "," + CURRENTTARGETS.reverse(); 55 56 for (var i=0; i < CURRENTTARGETS.length; i++) 57 { 58 CURRENTTARGETS[i].addEventListener(EVENT, TestBubble, true); 59 CURRENTTARGETS[i].addEventListener(EVENT, TestBubble, false); 60 } 61 } 62 catch(ex) 63 { 64 FailTest(); 65 } 66 } 67 </script> 68 </head> 69 <body> 70 <h3>DOM Events</h3> 71 <h4> 72 Test Description: WheelEvent - wheel event bubbles. 73 </h4> 74 75 <span id="parent"> 76 <textarea id="target" rows="5" cols="30">TOP TOP TOP TOP TOP TOP TOP Scroll mouse wheel over here Scroll mouse wheel over here Scroll mouse wheel over here Scroll mouse wheel over here Scroll mouse wheel over here END END END END END END END </textarea> 77 </span> 78 <p id="manualsteps"> 79 Steps: 80 <ol> 81 <li> Note: an input device with scroll wheel support (e.g., mouse wheel) is required 82 <li> Move the mouse pointer over the above textarea 83 <li> Scroll down the mouse wheel 1 or more units 84 </ol> 85 </p> 86 <p>Test passes if the word "PASS" appears below after following the above steps.</p> 87 <div>Test result: </div> 88 <div id='testresult'>FAIL</div> 89 </body> 90 </html>