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 | Test for menus with the anchor attribute set |
michael@0 | 6 | --> |
michael@0 | 7 | <window title="Anchored Menus Test" |
michael@0 | 8 | align="start" |
michael@0 | 9 | onload="setTimeout(runTest, 0,'tb1');" |
michael@0 | 10 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 11 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 12 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 13 | <script type="application/javascript" src="xul_selectcontrol.js"/> |
michael@0 | 14 | |
michael@0 | 15 | <hbox> |
michael@0 | 16 | |
michael@0 | 17 | <toolbarbutton id="tb1" type="menu-button" label="Open" anchor="dropmarker"> |
michael@0 | 18 | <menupopup id="popup1" |
michael@0 | 19 | onpopupshown="checkPopup(this, document.getAnonymousElementByAttribute(this.parentNode, 'anonid', 'dropmarker'))" |
michael@0 | 20 | onpopuphidden="runTest('tb2')"> |
michael@0 | 21 | <menuitem label="Item"/> |
michael@0 | 22 | </menupopup> |
michael@0 | 23 | </toolbarbutton> |
michael@0 | 24 | |
michael@0 | 25 | <toolbarbutton id="tb2" type="menu-button" label="Open" anchor="someanchor"> |
michael@0 | 26 | <menupopup id="popup2" onpopupshown="checkPopup(this, $('someanchor'))" onpopuphidden="runTest('tb3')"> |
michael@0 | 27 | <menuitem label="Item"/> |
michael@0 | 28 | </menupopup> |
michael@0 | 29 | </toolbarbutton> |
michael@0 | 30 | |
michael@0 | 31 | <toolbarbutton id="tb3" type="menu-button" label="Open" anchor="noexist"> |
michael@0 | 32 | <menupopup id="popup3" onpopupshown="checkPopup(this, this.parentNode)" onpopuphidden="SimpleTest.finish()"> |
michael@0 | 33 | <menuitem label="Item"/> |
michael@0 | 34 | </menupopup> |
michael@0 | 35 | </toolbarbutton> |
michael@0 | 36 | |
michael@0 | 37 | </hbox> |
michael@0 | 38 | |
michael@0 | 39 | <hbox pack="end" width="180"> |
michael@0 | 40 | <button id="someanchor" label="Anchor"/> |
michael@0 | 41 | </hbox> |
michael@0 | 42 | |
michael@0 | 43 | <!-- test results are displayed in the html:body --> |
michael@0 | 44 | <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> |
michael@0 | 45 | |
michael@0 | 46 | <script type="application/javascript"><![CDATA[ |
michael@0 | 47 | |
michael@0 | 48 | function runTest(menuid) |
michael@0 | 49 | { |
michael@0 | 50 | let menu = $(menuid); |
michael@0 | 51 | let dropmarker = document.getAnonymousElementByAttribute(menu, "anonid", "dropmarker"); |
michael@0 | 52 | |
michael@0 | 53 | synthesizeMouseAtCenter(dropmarker, { }); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function isWithinHalfPixel(a, b) |
michael@0 | 57 | { |
michael@0 | 58 | return Math.abs(a - b) <= 0.5; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function checkPopup(popup, anchor) |
michael@0 | 62 | { |
michael@0 | 63 | let popupRect = popup.getBoundingClientRect(); |
michael@0 | 64 | let anchorRect = anchor.getBoundingClientRect(); |
michael@0 | 65 | |
michael@0 | 66 | ok(isWithinHalfPixel(popupRect.left, anchorRect.left), popup.id + " left"); |
michael@0 | 67 | ok(isWithinHalfPixel(popupRect.top, anchorRect.bottom), popup.id + " top"); |
michael@0 | 68 | |
michael@0 | 69 | popup.hidePopup(); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 73 | |
michael@0 | 74 | ]]> |
michael@0 | 75 | </script> |
michael@0 | 76 | |
michael@0 | 77 | </window> |