summaryrefslogtreecommitdiffstats
path: root/layout/generic/test/test_plugin_mouse_coords.html
blob: cba915ec6ed8fe69d3e1f811d6b328fbce6f99a1 (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
<!DOCTYPE HTML>
<html>
<head>
  <title>Test delivering mouse events to plugins</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>    
  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <script type="application/javascript" src="plugin-utils.js"></script>
  <script type="application/javascript">
    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
  </script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <style>
  embed { width:200px; height:200px; display:block; }
  iframe { border:none; }
  </style>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: block">
  <embed id="p1" type="application/x-test"
         style="position:absolute; left:300px; top:10px;"></embed>
  <iframe id="f1" style="position:absolute; left:0; top:250px;"
          src="data:text/html,&lt;embed id='p2' type='application/x-test' style='position:absolute; left:10px; top:10px'&gt;"></iframe>
  <embed id="p3" type="application/x-test"
         style="position:absolute; left:320px; top:250px;
                outline:5px solid blue;
                border:solid black; border-width:4px 8px 4px 8px;
                padding:3px 1px;"></embed>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

function doTest() {
  var p1 = document.getElementById("p1");
  synthesizeMouse(p1, 15, 18, { type:"mousedown" });
  is(p1.getLastMouseX(), 15, "p1 mouse down X");
  is(p1.getLastMouseY(), 18, "p1 mouse down Y");
  synthesizeMouse(p1, 15, 38, { type:"mousemove" });
  is(p1.getLastMouseX(), 15, "p1 mouse move X");
  is(p1.getLastMouseY(), 38, "p1 mouse move Y");
  synthesizeMouse(p1, 15, 28, { type:"mouseup" });
  is(p1.getLastMouseX(), 15, "p1 mouse up X");
  is(p1.getLastMouseY(), 28, "p1 mouse up Y");

  var f1 = document.getElementById("f1");
  var p2 = f1.contentDocument.getElementById("p2");
  synthesizeMouse(p2, 15, 18, { type:"mousedown" }, f1.contentWindow);
  is(p2.getLastMouseX(), 15, "p2 mouse down X");
  is(p2.getLastMouseY(), 18, "p2 mouse down Y");
  synthesizeMouse(p2, 15, 38, { type:"mousemove" }, f1.contentWindow);
  is(p2.getLastMouseX(), 15, "p2 mouse move X");
  is(p2.getLastMouseY(), 38, "p2 mouse move Y");
  synthesizeMouse(p2, 15, 28, { type:"mouseup" }, f1.contentWindow);
  is(p2.getLastMouseX(), 15, "p2 mouse up X");
  is(p2.getLastMouseY(), 28, "p2 mouse up Y");

  var p3 = document.getElementById("p3");
  // The synthesized coordinates are relative to the border-box, but the plugin
  // is at offset (9,7) relative to the border-box
  synthesizeMouse(p3, 15, 18, { type:"mousedown" });
  is(p3.getLastMouseX(), 6, "p3 mouse down X");
  is(p3.getLastMouseY(), 11, "p3 mouse down Y");
  synthesizeMouse(p3, 15, 38, { type:"mousemove" });
  is(p3.getLastMouseX(), 6, "p3 mouse move X");
  is(p3.getLastMouseY(), 31, "p3 mouse move Y");
  synthesizeMouse(p3, 15, 28, { type:"mouseup" });
  is(p3.getLastMouseX(), 6, "p3 mouse up X");
  is(p3.getLastMouseY(), 21, "p3 mouse up Y");

  SimpleTest.finish();
}
// Need to run 'doTest' after painting is unsuppressed, or we'll set clip
// regions to empty.
addLoadEvent(function() { setTimeout(doTest, 1000); } );
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");

</script>
</pre>
</body>
</html>