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