Bug 1884032 [wpt PR 44942] - [css-color] add missing colorscheme-aware tests, a=testonly
[gecko.git] / widget / tests / test_panel_mouse_coords.xhtml
blob43c4e1024901f513dae5fbe5373bc2c9199b943c
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 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
11 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
13 <panel id="thepanel" level="parent"
14 onpopupshown="sendMouseEvent();"
15 onmousemove="checkCoords(event);"
16 style="width: 80px; height: 80px">
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 panel = document.getElementById('thepanel');
32 let rect = null;
35 function startTest() {
36 // This first event is to ensure that the next event will have different
37 // coordinates to the previous mouse position, and so actually generates
38 // mouse events. The mouse is not moved off the window, as that might
39 // move focus to another application.
40 synthesizeNativeMouseEvent({
41 type: "mousemove",
42 screenX: window.mozInnerScreenX,
43 screenY: window.mozInnerScreenY,
44 elementOnWidget: window.documentElement,
45 });
47 panel.openPopup(document.getElementById("anchor"), "after_start");
50 function sendMouseEvent() {
51 rect = panel.getBoundingClientRect();
52 synthesizeNativeMouseEvent({
53 type: "mousemove",
54 target: panel,
55 offsetX: 10,
56 offsetY: 20,
57 });
60 function checkCoords(event) {
61 if (!rect) {
62 return;
64 isfuzzy(event.clientX, rect.left + 10, window.devicePixelRatio, "Motion x coordinate");
65 isfuzzy(event.clientY, rect.top + 20, window.devicePixelRatio, "Motion y coordinate");
66 info(`Event client: ${event.clientX}, ${event.clientY}, panel client: ${rect.left}, ${rect.top}`);
67 info(`Event screen: ${event.screenX}, ${event.screenY}, panel screen: ${panel.screenX}, ${panel.screenY}`);
68 info(`offset client: ${event.clientX - rect.left}, ${event.clientY - rect.top}`);
69 info(`offset screen: ${event.screenX - panel.screenX}, ${event.screenY - panel.screenY}`);
70 done();
73 function done() {
74 SimpleTest.finish();
76 ]]>
77 </script>
78 </window>