3 <title>Event.screenX/Y on a zoomed page.
</title>
4 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
5 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
10 background-color: blue;
11 /* We want synthesizeMouseAtCenter to click on the same point regardless of
12 zoom, so we achieve that by centering the target in our viewport */
21 <div id=
"target" style=
""></div>
23 const target
= document
.getElementById("target");
24 async
function getScreenPositionOfTarget() {
25 return new Promise(resolve
=> {
26 target
.addEventListener("click", function(e
) {
27 resolve({ x
: e
.screenX
, y
: e
.screenY
});
29 synthesizeMouseAtCenter(target
, {});
33 function getScreen() {
36 height
: screen
.height
,
42 add_task(async () => {
43 let pos
= await
getScreenPositionOfTarget();
46 SpecialPowers
.setFullZoom(window
, 2);
47 let zoomedPos
= await
getScreenPositionOfTarget();
48 let zoomedScreen
= getScreen();
50 info(`Original pos=${JSON.stringify(pos)} s=${JSON.stringify(s)}`);
51 info(`Zoomed pos=${JSON.stringify(zoomedPos)} s=${JSON.stringify(zoomedScreen)}`);
53 isfuzzy(pos
.x
, zoomedPos
.x
* 2, 1, "screenX coordinate");
54 isfuzzy(pos
.y
, zoomedPos
.y
* 2, 1, "screenY coordinate");
56 isfuzzy(s
.top
, zoomedScreen
.top
* 2, 1, "Screen.top");
57 isfuzzy(s
.left
, zoomedScreen
.left
* 2, 1, "Screen.left");
58 isfuzzy(s
.width
, zoomedScreen
.width
* 2, 1, "Screen.width");
59 isfuzzy(s
.height
, zoomedScreen
.height
* 2, 1, "Screen.height");
61 SpecialPowers
.setFullZoom(window
, 1);