summaryrefslogtreecommitdiffstats
path: root/widget/tests/test_panel_mouse_coords.xul
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /widget/tests/test_panel_mouse_coords.xul
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'widget/tests/test_panel_mouse_coords.xul')
-rw-r--r--widget/tests/test_panel_mouse_coords.xul83
1 files changed, 83 insertions, 0 deletions
diff --git a/widget/tests/test_panel_mouse_coords.xul b/widget/tests/test_panel_mouse_coords.xul
new file mode 100644
index 000000000..41ef49044
--- /dev/null
+++ b/widget/tests/test_panel_mouse_coords.xul
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=835044
+-->
+<window title="Mozilla Bug 835044"
+ onload="startTest()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+<panel id="thepanel" level="parent"
+ onpopupshown="sendMouseEvent();"
+ onmousemove="checkCoords(event);"
+ width="80" height="80">
+</panel>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=835044"
+ id="anchor"
+ target="_blank">Mozilla Bug 835044</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+let utils = window.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIDOMWindowUtils);
+let panel = document.getElementById('thepanel');
+let nativeMouseMove;
+let rect;
+
+function startTest() {
+ let widgetToolkit = Cc["@mozilla.org/xre/app-info;1"].
+ getService(Ci.nsIXULRuntime).widgetToolkit;
+
+ if (widgetToolkit == "cocoa") {
+ nativeMouseMove = 5; // NSMouseMoved
+ } else if (widgetToolkit == "windows") {
+ nativeMouseMove = 1; // MOUSEEVENTF_MOVE
+ } else if (/^gtk/.test(widgetToolkit)) {
+ nativeMouseMove = 3; // GDK_MOTION_NOTIFY
+ } else {
+ todo_is("widgetToolkit", widgetToolkit, "Platform not supported");
+ done();
+ }
+
+ // This first event is to ensure that the next event will have different
+ // coordinates to the previous mouse position, and so actually generates
+ // mouse events. The mouse is not moved off the window, as that might
+ // move focus to another application.
+ utils.sendNativeMouseEvent(window.mozInnerScreenX, window.mozInnerScreenY,
+ nativeMouseMove, 0, window.documentElement);
+
+ panel.openPopup(document.getElementById("anchor"), "after_start");
+}
+
+function sendMouseEvent() {
+ rect = panel.getBoundingClientRect();
+ let x = window.mozInnerScreenX + rect.left + 1;
+ let y = window.mozInnerScreenY + rect.top + 2;
+ utils.sendNativeMouseEvent(x, y, nativeMouseMove, 0,
+ window.documentElement);
+}
+
+function checkCoords(event) {
+ is(event.clientX, rect.left + 1, "Motion x coordinate");
+ is(event.clientY, rect.top + 2, "Motion y coordinate");
+ done();
+}
+
+function done() {
+ SimpleTest.finish();
+}
+ ]]>
+ </script>
+</window>