| <!doctype html> |
| <html> |
| <head> |
| <title>Mouse Event Dispatching to Disabled Form Controls</title> |
| <meta name="viewport" content="width=device-width"> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <button id="target0" disabled>Disabled button</button> |
| <script> |
| var eventList = ['mouseout', 'mouseover', 'mouseenter', 'mousemove', 'mousedown', 'mouseup', 'mouseleave']; |
| var target = document.getElementById("target0"); |
| |
| test((t) => { |
| target.onclick = t.unreached_func("click should not fire on disabled element"); |
| document.body.onclick = t.unreached_func("click should not fire on event path"); |
| target.click(); |
| target.dispatchEvent(new MouseEvent('click', {capture: true, bubbles: true})); |
| }, 'Click should not fire'); |
| |
| for (let eventName of eventList) { |
| test((t) => { |
| let fired = false; |
| on_event(target, eventName, () => fired = true); |
| target.dispatchEvent(new MouseEvent(eventName, {capture: true, bubbles: true})); |
| assert_true(fired, eventName + ' should be fired'); |
| }, eventName + ' should be fired'); |
| } |
| </script> |
| </body> |
| </html> |