Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 6 | |
michael@0 | 7 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 9 | |
michael@0 | 10 | <vbox align="start"> |
michael@0 | 11 | <button id="button1" label="Button 1" style="margin-top: 50px;"/> |
michael@0 | 12 | <button id="button2" label="Button 2" style="margin-top: 60px;"/> |
michael@0 | 13 | </vbox> |
michael@0 | 14 | |
michael@0 | 15 | <menupopup id="popup" onpopupshown="popupshown()" onpopuphidden="SimpleTest.finish()"> |
michael@0 | 16 | <menuitem label="One"/> |
michael@0 | 17 | <menuitem label="Two"/> |
michael@0 | 18 | </menupopup> |
michael@0 | 19 | |
michael@0 | 20 | <script> |
michael@0 | 21 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 22 | |
michael@0 | 23 | function runTest(id) |
michael@0 | 24 | { |
michael@0 | 25 | $("popup").openPopup($("button1"), "after_start"); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | function popupshown() |
michael@0 | 29 | { |
michael@0 | 30 | var popup = $("popup"); |
michael@0 | 31 | var popupheight = popup.getBoundingClientRect().height; |
michael@0 | 32 | var button1rect = $("button1").getBoundingClientRect(); |
michael@0 | 33 | var button2rect = $("button2").getBoundingClientRect(); |
michael@0 | 34 | |
michael@0 | 35 | checkCoords(popup, button1rect.left, button1rect.bottom, "initial"); |
michael@0 | 36 | |
michael@0 | 37 | popup.moveToAnchor($("button1"), "after_start", 0, 8); |
michael@0 | 38 | checkCoords(popup, button1rect.left, button1rect.bottom + 8, "move anchor top + 8"); |
michael@0 | 39 | |
michael@0 | 40 | popup.moveToAnchor($("button1"), "after_start", 6, -10); |
michael@0 | 41 | checkCoords(popup, button1rect.left + 6, button1rect.bottom - 10, "move anchor left + 6, top - 10"); |
michael@0 | 42 | |
michael@0 | 43 | popup.moveToAnchor($("button1"), "before_start", -2, 0); |
michael@0 | 44 | checkCoords(popup, button1rect.left - 2, button1rect.top - popupheight, "move anchor before_start"); |
michael@0 | 45 | |
michael@0 | 46 | popup.moveToAnchor($("button2"), "before_start"); |
michael@0 | 47 | checkCoords(popup, button2rect.left, button2rect.top - popupheight, "move button2"); |
michael@0 | 48 | |
michael@0 | 49 | popup.moveToAnchor($("button1"), "end_before"); |
michael@0 | 50 | checkCoords(popup, button1rect.right, button1rect.top, "move anchor end_before"); |
michael@0 | 51 | |
michael@0 | 52 | popup.moveToAnchor($("button2"), "after_start", 5, 4); |
michael@0 | 53 | checkCoords(popup, button2rect.left + 5, button2rect.bottom + 4, "move button2 left + 5, top + 4"); |
michael@0 | 54 | |
michael@0 | 55 | popup.moveTo($("button1").boxObject.screenX + 10, $("button1").boxObject.screenY + 12); |
michael@0 | 56 | checkCoords(popup, button1rect.left + 10, button1rect.top + 12, "move to button1 screen with offset"); |
michael@0 | 57 | |
michael@0 | 58 | popup.moveToAnchor($("button1"), "after_start", 1, 2); |
michael@0 | 59 | checkCoords(popup, button1rect.left + 1, button1rect.bottom + 2, "move button2 after screen"); |
michael@0 | 60 | |
michael@0 | 61 | popup.hidePopup(); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | function checkCoords(popup, expectedx, expectedy, testid) |
michael@0 | 65 | { |
michael@0 | 66 | var rect = popup.getBoundingClientRect(); |
michael@0 | 67 | is(Math.round(rect.left), Math.round(expectedx), testid + " left"); |
michael@0 | 68 | is(Math.round(rect.top), Math.round(expectedy), testid + " top"); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | SimpleTest.waitForFocus(runTest); |
michael@0 | 72 | |
michael@0 | 73 | </script> |
michael@0 | 74 | |
michael@0 | 75 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 76 | <p id="display"> |
michael@0 | 77 | </p> |
michael@0 | 78 | <div id="content" style="display: none"> |
michael@0 | 79 | </div> |
michael@0 | 80 | <pre id="test"> |
michael@0 | 81 | </pre> |
michael@0 | 82 | </body> |
michael@0 | 83 | |
michael@0 | 84 | </window> |