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 | |
michael@0 | 4 | <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 5 | |
michael@0 | 6 | <script type="application/javascript" |
michael@0 | 7 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
michael@0 | 8 | |
michael@0 | 9 | <menupopup id="popup" onpopupshowing="if (isSecondTest) popupShowing(event)" onpopupshown="popupShown()" |
michael@0 | 10 | onpopuphidden="nextTest()"> |
michael@0 | 11 | <menuitem label="One"/> |
michael@0 | 12 | <menuitem label="Two"/> |
michael@0 | 13 | </menupopup> |
michael@0 | 14 | |
michael@0 | 15 | <button id="button" label="OK" popup="popup"/> |
michael@0 | 16 | |
michael@0 | 17 | <script class="testbody" type="application/javascript"> |
michael@0 | 18 | <![CDATA[ |
michael@0 | 19 | |
michael@0 | 20 | var isSecondTest = false; |
michael@0 | 21 | |
michael@0 | 22 | function openPopup() |
michael@0 | 23 | { |
michael@0 | 24 | document.getElementById("popup").openPopup(parent.document.getElementById("outerbutton"), "after_start", 3, 1); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | function popupShowing(event) |
michael@0 | 28 | { |
michael@0 | 29 | var buttonrect = document.getElementById("button").getBoundingClientRect(); |
michael@0 | 30 | parent.opener.wrappedJSObject.SimpleTest.is(event.clientX, buttonrect.left + 6, "popup clientX with mouse"); |
michael@0 | 31 | parent.opener.wrappedJSObject.SimpleTest.is(event.clientY, buttonrect.top + 6, "popup clientY with mouse"); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | function popupShown() |
michael@0 | 35 | { |
michael@0 | 36 | var left, top; |
michael@0 | 37 | var popuprect = document.getElementById("popup").getBoundingClientRect(); |
michael@0 | 38 | if (isSecondTest) { |
michael@0 | 39 | var buttonrect = document.getElementById("button").getBoundingClientRect(); |
michael@0 | 40 | left = buttonrect.left + 6; |
michael@0 | 41 | top = buttonrect.top + 6; |
michael@0 | 42 | } |
michael@0 | 43 | else { |
michael@0 | 44 | var iframerect = parent.document.getElementById("frame").getBoundingClientRect(); |
michael@0 | 45 | var buttonrect = parent.document.getElementById("outerbutton").getBoundingClientRect(); |
michael@0 | 46 | |
michael@0 | 47 | // The popup should appear anchored on the bottom left edge of the button, however |
michael@0 | 48 | // the client rectangle is relative to the iframe's document. Thus the coordinates |
michael@0 | 49 | // are: |
michael@0 | 50 | // left = iframe's left - anchor button's left - 3 pixel offset passed to openPopup + |
michael@0 | 51 | // iframe border (17px) + iframe padding (0) |
michael@0 | 52 | // top = iframe's top - anchor button's bottom - 1 pixel offset passed to openPopup + |
michael@0 | 53 | // iframe border (0) + iframe padding (3px); |
michael@0 | 54 | left = -(Math.round(iframerect.left) - Math.round(buttonrect.left) + 14); |
michael@0 | 55 | top = -(Math.round(iframerect.top) - Math.round(buttonrect.bottom) + 2); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | var testid = isSecondTest ? "with mouse" : "anchored to parent frame"; |
michael@0 | 59 | parent.opener.wrappedJSObject.SimpleTest.is(Math.round(popuprect.left), left, "popup left " + testid); |
michael@0 | 60 | parent.opener.wrappedJSObject.SimpleTest.is(Math.round(popuprect.top), top, "popup top " + testid); |
michael@0 | 61 | |
michael@0 | 62 | document.getElementById("popup").hidePopup(); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | function nextTest() |
michael@0 | 66 | { |
michael@0 | 67 | if (isSecondTest) { |
michael@0 | 68 | parent.opener.wrappedJSObject.SimpleTest.finish(); |
michael@0 | 69 | parent.close(); |
michael@0 | 70 | } |
michael@0 | 71 | else { |
michael@0 | 72 | // this second test ensures that the popupshowing coordinates when a popup in |
michael@0 | 73 | // a frame is opened are correct |
michael@0 | 74 | isSecondTest = true; |
michael@0 | 75 | synthesizeMouse(document.getElementById("button"), 6, 6, { }); |
michael@0 | 76 | } |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | ]]> |
michael@0 | 80 | </script> |
michael@0 | 81 | |
michael@0 | 82 | </page> |