summaryrefslogtreecommitdiffstats
path: root/WebCore/manual-tests/DOMContextMenuEvent.html
blob: 5c0fc33a52e9feaefe147b298ff74dbbc8ba6df6 (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
<html>
<script type="text/javascript">

function context_event(event)
{
  if (window.event)
  {
    event = window.event;
  }
  var swallow = document.getElementById("swallow_context").checked;

  var str =
         "EVENT PROPERTIES<br>"                       +
         "cancelable      = "+event.cancelable+"<br>" +
         "ctrlKey         = "+event.ctrlKey+"<br>"    +
         "metaKey         = "+event.metaKey+"<br>"    +
         "shiftKey        = "+event.shiftKey+"<br>"   +
         "<br>"                                       +
         "TEST PROPERTIES<br>"                        +
         "prevent default = "+swallow+"<br>"          +
         "event time      = "+new Date()+"<br>"       +
         "";
  document.getElementById("event_info").innerHTML=str;

  if (swallow)
  {
    if ((typeof event.cancelBubble) != "undefined")
      event.cancelBubble=true;

    if ((typeof event.preventDefault) != "undefined")
      event.preventDefault();

    if ((typeof event.returnValue) != "undefined")
      event.returnValue = false;

    if ((typeof event.stopPropagation) != "undefined")
      event.stopPropagation();

    return false;
  }

  return true;
}

</script>

<body oncontextmenu="return context_event(event)">
<div>To activate context menu, right-click or ctrl-click anywhere on the page.</div>
<div>&nbsp;</div>
<div><input type="checkbox" value="1" name="swallow_context" id="swallow_context"> Prevent default context menu</div>
<div>&nbsp;</div>
<tt id="event_info" style='background-color:#eeeeee'>
 -- No event captured --
</tt>
</body>
</html>