commit-queue@webkit.org | 7866149 | 2011-11-22 02:59:03 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta charset="utf-8" /> |
| 5 | <title>Dispatching to a Function Object Implementing handleEvent()</title> |
| 6 | </head> |
| 7 | <body> |
| 8 | |
| 9 | <p> |
| 10 | When the listener passed to <code>addEventListener()</code> is a function, it should be called when the event occurs. |
| 11 | The listener function should <em>not</em> be tested for adherence to the <code>EventListener</code> interface |
| 12 | and have its <code>handleEvent()</code> method called if present. |
| 13 | </p> |
| 14 | |
| 15 | <p id="console"></p> |
| 16 | |
mark.lam@apple.com | 436bf82 | 2013-09-07 23:07:25 +0000 | [diff] [blame] | 17 | <script src="../../resources/js-test-pre.js"></script> |
commit-queue@webkit.org | 7866149 | 2011-11-22 02:59:03 +0000 | [diff] [blame] | 18 | <script type="text/javascript" charset="utf-8"> |
| 19 | // This function should be called. |
| 20 | var listener = function(event) { |
| 21 | testPassed("The listener function should have been called to handle the event."); |
| 22 | }; |
| 23 | // This function should not be called. |
| 24 | listener.handleEvent = function(event) { |
| 25 | testFailed("The listener function should have been called to handle the event."); |
| 26 | }; |
| 27 | |
| 28 | // Send the test event |
| 29 | window.addEventListener("testevent", listener, false); |
| 30 | var event = document.createEvent("Event"); |
| 31 | event.initEvent("testevent", true, true); |
| 32 | window.dispatchEvent(event); |
| 33 | </script> |
| 34 | |
| 35 | </body> |
| 36 | </html> |