<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Dispatching to a Function Object Implementing handleEvent()</title>
  </head>
  <body>
    
    <p>
      When the listener passed to <code>addEventListener()</code> is a function, it should be called when the event occurs.
      The listener function should <em>not</em> be tested for adherence to the <code>EventListener</code> interface 
      and have its <code>handleEvent()</code> method called if present.
    </p>

    <p id="console"></p>
    
    <script src="../../resources/js-test-pre.js"></script>
    <script type="text/javascript" charset="utf-8">
      // This function should be called.
      var listener = function(event) {
        testPassed("The listener function should have been called to handle the event.");
      };
      // This function should not be called.
      listener.handleEvent = function(event) {
        testFailed("The listener function should have been called to handle the event.");
      };
      
      // Send the test event
      window.addEventListener("testevent", listener, false);
      var event = document.createEvent("Event");
      event.initEvent("testevent", true, true);
      window.dispatchEvent(event);
    </script>
  
  </body>
</html>