Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
5 <window title="Popup Coordinate Tests"
6 onload="setTimeout(openThePopup, 0, 'outer');"
7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
12 <deck style="margin-top: 5px; padding-top: 5px;">
13 <label id="outer" popup="outerpopup" value="Popup"/>
14 </deck>
16 <panel id="outerpopup"
17 onpopupshowing="popupShowingEventOccurred(event);"
18 onpopupshown="eventOccurred(event); openThePopup('inner')"
19 onpopuphiding="eventOccurred(event);"
20 onpopuphidden="eventOccurred(event); SimpleTest.finish();">
21 <button id="item1" label="First"/>
22 <label id="inner" value="Second" popup="innerpopup"/>
23 <button id="item2" label="Third"/>
24 </panel>
26 <menupopup id="innerpopup"
27 onpopupshowing="popupShowingEventOccurred(event);"
28 onpopupshown="eventOccurred(event); event.target.hidePopup();"
29 onpopuphiding="eventOccurred(event);"
30 onpopuphidden="eventOccurred(event); document.getElementById('outerpopup').hidePopup();">
31 <menuitem id="inner1" label="Inner First"/>
32 <menuitem id="inner2" label="Inner Second"/>
33 </menupopup>
35 <script>
36 SimpleTest.waitForExplicitFinish();
38 function openThePopup(id)
39 {
40 if (id == "inner")
41 document.getElementById("item1").focus();
43 var trigger = document.getElementById(id);
44 synthesizeMouse(trigger, 4, 5, { });
45 }
47 function eventOccurred(event)
48 {
49 var testname = event.type + " on " + event.target.id + " ";
50 ok(event instanceof MouseEvent, testname + "is a mouse event");
51 is(event.clientX, 0, testname + "clientX");
52 is(event.clientY, 0, testname + "clientY");
53 is(event.rangeParent, null, testname + "rangeParent");
54 is(event.rangeOffset, 0, testname + "rangeOffset");
55 }
57 function popupShowingEventOccurred(event)
58 {
59 // the popupshowing event should have the event coordinates and
60 // range position filled in.
61 var testname = "popupshowing on " + event.target.id + " ";
62 ok(event instanceof MouseEvent, testname + "is a mouse event");
64 var trigger = document.getElementById(event.target.id == "outerpopup" ? "outer" : "inner");
65 var rect = trigger.getBoundingClientRect();
66 is(event.clientX, Math.round(rect.left + 4), testname + "clientX");
67 is(event.clientY, Math.round(rect.top + 5), testname + "clientY");
68 // rangeOffset should be just after the trigger element. As rangeOffset
69 // considers the zeroth position to be before the first element, the value
70 // should be one higher than its index within its parent.
71 is(event.rangeParent, trigger.parentNode, testname + "rangeParent");
72 is(event.rangeOffset, Array.indexOf(trigger.parentNode.childNodes, trigger) + 1, testname + "rangeOffset");
74 var popuprect = event.target.getBoundingClientRect();
75 is(Math.round(popuprect.left), Math.round(rect.left + 4), "popup left");
76 is(Math.round(popuprect.top), Math.round(rect.top + 5), "popup top");
77 ok(popuprect.width > 0, "popup width");
78 ok(popuprect.height > 0, "popup height");
79 }
80 </script>
82 <body xmlns="http://www.w3.org/1999/xhtml">
83 <p id="display">
84 </p>
85 <div id="content" style="display: none">
86 </div>
87 <pre id="test">
88 </pre>
89 </body>
91 </window>