summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/markup/test/doc_markup_events2.html
blob: ddc17537d59f4e45fbd17b337d9bf2ac171f0c88 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <style>
    #fatarrow,
    #bound,
    #boundhe,
    #comment-inline,
    #comment-streaming,
    #anon-object-method,
    #object-method {
      border: 1px solid #000;
      width: 200px;
      min-height: 1em;
      cursor: pointer;
    }
    </style>
    <script type="application/javascript;version=1.8">
      function init() {
        let fatarrow = document.getElementById("fatarrow");

        let he = new handleEventClick();
        let anonObjectMethod = document.getElementById("anon-object-method");
        anonObjectMethod.addEventListener("click", he.anonObjectMethod);

        let objectMethod = document.getElementById("object-method");
        objectMethod.addEventListener("click", he.objectMethod);

        let bhe = new boundHandleEventClick();
        let boundheNode = document.getElementById("boundhe");
        bhe.handleEvent = bhe.handleEvent.bind(bhe);
        boundheNode.addEventListener("click", bhe);

        let boundNode = document.getElementById("bound");
        boundClickHandler = boundClickHandler.bind(this);
        boundNode.addEventListener("click", boundClickHandler);

        fatarrow.addEventListener("click", () => {
          alert("Fat arrow without params!");
        });

        fatarrow.addEventListener("click", event => {
          alert("Fat arrow with 1 param!");
        });

        fatarrow.addEventListener("click", (event, foo, bar) => {
          alert("Fat arrow with 3 params!");
        });

        fatarrow.addEventListener("click", b => b);

        let inlineCommentNode = document.getElementById("comment-inline");
        inlineCommentNode
          .addEventListener("click", functionProceededByInlineComment);

        let streamingCommentNode = document.getElementById("comment-streaming");
        streamingCommentNode
          .addEventListener("click", functionProceededByStreamingComment);
      }

      function boundClickHandler(event) {
        alert("Bound event");
      }

      function handleEventClick(hehe) {

      }

      handleEventClick.prototype = {
        anonObjectMethod: function() {
          alert("obj.anonObjectMethod");
        },

        objectMethod: function kay() {
          alert("obj.objectMethod");
        },
      };

      function boundHandleEventClick() {

      }

      boundHandleEventClick.prototype = {
        handleEvent: function() {
          alert("boundHandleEvent");
        }
      };

      // A function proceeded with an inline comment
      function functionProceededByInlineComment() {
        alert("comment-inline");
      }

      /* A function proceeded with a streaming comment */
      function functionProceededByStreamingComment() {
        alert("comment-streaming");
      }
    </script>
  </head>
  <body onload="init();">
    <h1>Events test 2</h1>
    <div id="fatarrow">Fat arrows</div>
    <div id="boundhe">Bound handleEvent</div>
    <div id="bound">Bound event</div>
    <div id="comment-inline">Event proceeded by an inline comment</div>
    <div id="comment-streaming">Event proceeded by a streaming comment</div>
    <div id="anon-object-method">Anonymous object method</div>
    <div id="object-method">Object method</div>
  </body>
</html>