summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/callback-function-with-handle-event.html
blob: 50d17c56c63f7c44c8e06c3008af9ea03b7b19be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Callback Function Objects Implementing handleEvent()</title>
  </head>
  <body>
    
    <p>
      When a JS callback is a function, it should be called. If the function has another function as 
      its <code>handleEvent</code> property, that function should <em>not</em> be called.
    </p>

    <p id="console"></p>
    
    <script src="../../resources/js-test.js"></script>
    <script type="text/javascript" charset="utf-8">
      window.jsTestIsAsync = true;
      
      // This function should be called.
      var callback = function(event) {
        testPassed("The callback function was called directly.");
        finishJSTest();
      };
      // This function should not be called.
      callback.handleEvent = function(event) {
        testFailed("The callback function's handleEvent property was called instead of the function itself.");
        finishJSTest();
      };
      
      // Database is one of several uses of JS Callbacks
      var db = openDatabase("callback-function-with-handle-event-test", "", "Test for callback functions that implement a handleEvent() method.", 1);
      db.changeVersion(db.version, "1.0", callback);
    </script>
  
  </body>
</html>