Bug 1073336 part 5 - Add AnimationPlayerCollection::PlayerUpdated; r=dbaron
[gecko.git] / widget / tests / test_panel_mouse_coords.xul
blob60a23d53d5b0ddcffce9fe11164930e3b2e9f9ba
1 <?xml version="1.0"?>
2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
4 <!--
5 https://bugzilla.mozilla.org/show_bug.cgi?id=835044
6 -->
7 <window title="Mozilla Bug 835044"
8 onload="startTest()"
9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
10 <script type="application/javascript"
11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
13 <panel id="thepanel" level="parent"
14 onpopupshown="sendMouseEvent();"
15 onmousemove="checkCoords(event);"
16 width="80" height="80">
17 </panel>
19 <!-- test results are displayed in the html:body -->
20 <body xmlns="http://www.w3.org/1999/xhtml">
21 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=835044"
22 id="anchor"
23 target="_blank">Mozilla Bug 835044</a>
24 </body>
26 <!-- test code goes here -->
27 <script type="application/javascript">
28 <![CDATA[
29 SimpleTest.waitForExplicitFinish();
31 let Cc = Components.classes;
32 let Ci = Components.interfaces;
33 let utils = window.QueryInterface(Ci.nsIInterfaceRequestor).
34 getInterface(Ci.nsIDOMWindowUtils);
35 let panel = document.getElementById('thepanel');
36 let nativeMouseMove;
37 let rect;
39 function startTest() {
40 let widgetToolkit = Cc["@mozilla.org/xre/app-info;1"].
41 getService(Ci.nsIXULRuntime).widgetToolkit;
43 if (widgetToolkit == "cocoa") {
44 nativeMouseMove = 5; // NSMouseMoved
45 } else if (widgetToolkit == "windows") {
46 nativeMouseMove = 1; // MOUSEEVENTF_MOVE
47 } else if (/^gtk/.test(widgetToolkit)) {
48 nativeMouseMove = 3; // GDK_MOTION_NOTIFY
49 } else {
50 todo_is("widgetToolkit", widgetToolkit, "Platform not supported");
51 done();
54 // This first event is to ensure that the next event will have different
55 // coordinates to the previous mouse position, and so actually generates
56 // mouse events. The mouse is not moved off the window, as that might
57 // move focus to another application.
58 utils.sendNativeMouseEvent(window.mozInnerScreenX, window.mozInnerScreenY,
59 nativeMouseMove, 0, window.documentElement);
61 panel.openPopup(document.getElementById("anchor"), "after_start");
64 function sendMouseEvent() {
65 rect = panel.getBoundingClientRect();
66 let x = window.mozInnerScreenX + rect.left + 1;
67 let y = window.mozInnerScreenY + rect.top + 2;
68 utils.sendNativeMouseEvent(x, y, nativeMouseMove, 0,
69 window.documentElement);
72 function checkCoords(event) {
73 is(event.clientX, rect.left + 1, "Motion x coordinate");
74 is(event.clientY, rect.top + 2, "Motion y coordinate");
75 done();
78 function done() {
79 SimpleTest.finish();
81 ]]>
82 </script>
83 </window>