| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <title>Context menu event ordering</title> | |
| 4 <style> | |
| 5 #clickTarget { | |
| 6 width: 100%; | |
| 7 height: 50px; | |
| 8 background: red; | |
| 9 text-align: center; | |
| 10 } | |
| 11 </style> | |
| 12 <script> | |
| 13 | |
| 14 function startTest() { | |
| 15 var target = document.getElementById("clickTarget"); | |
| 16 | |
| 17 traceMouseEvent(target, "click"); | |
| 18 traceMouseEvent(target, "mousedown"); | |
| 19 traceMouseEvent(target, "mouseup"); | |
| 20 traceMouseEvent(target, "contextmenu"); | |
| 21 | |
| 22 if (window.layoutTestController) { | |
| 23 window.layoutTestController.dumpAsText(); | |
| 24 | |
| 25 // Right click inside clickTarget | |
| 26 window.eventSender.mouseMoveTo(20,20); | |
| 27 window.eventSender.mouseDown(2 /*right button*/); | |
| 28 window.eventSender.mouseUp(2 /*right button*/); | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 function traceMouseEvent(target, eventName) { | |
| 33 | |
| 34 var callback = function(e) { | |
| 35 log ("Dispatched event " + e.type + " (button=" + e.button + ")"); | |
| 36 | |
| 37 if (eventName == "contextmenu") { | |
| 38 // Prevent the context menu from being displayed. | |
| 39 e.returnValue = false; | |
| 40 if (e.stopPropagation) { | |
| 41 e.stopPropagation(); | |
| 42 } | |
| 43 } | |
| 44 }; | |
| 45 | |
| 46 if (target.addEventListener) { | |
| 47 target.addEventListener(eventName, callback, false); | |
| 48 } else if (target.attachEvent) /*Internet Explorer*/ { | |
| 49 target.attachEvent("on" + eventName, callback); | |
| 50 } else { | |
| 51 log ("!!! Failed registering " + eventName); | |
| 52 } | |
| 53 } | |
| 54 | |
| 55 function log(msg) { | |
| 56 var log = document.getElementById("log"); | |
| 57 log.appendChild(document.createTextNode(msg)); | |
| 58 log.appendChild(document.createElement("br")); | |
| 59 } | |
| 60 </script> | |
| 61 </head> | |
| 62 | |
| 63 <body onload="startTest()"> | |
| 64 <div id=clickTarget> | |
| 65 [Click target] | |
| 66 </div> | |
| 67 | |
| 68 <p>Right click in the red box: the event sequence should match (mousedown, m
ouseup, contextmenu)</p> | |
| 69 <pre id=log></pre> | |
| 70 </body> | |
| 71 </html> | |
| OLD | NEW |