test_bug987230.xhtml (3582B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?> 3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 4 <!-- 5 https://bugzilla.mozilla.org/show_bug.cgi?id=987230 6 --> 7 <window title="Mozilla Bug 987230" 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 9 onload="SimpleTest.waitForFocus(startTest, window)"> 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 11 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 12 13 14 <!-- test results are displayed in the html:body --> 15 <body xmlns="http://www.w3.org/1999/xhtml"> 16 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=987230" 17 target="_blank">Mozilla Bug 987230</a> 18 </body> 19 20 <vbox> 21 <toolbar> 22 <toolbarbutton id="toolbarbutton-anchor" 23 label="Anchor" 24 consumeanchor="toolbarbutton-anchor" 25 onclick="onAnchorClick(event)" 26 style="padding: 50px !important; list-style-image: url(chrome://branding/content/icon32.png)"/> 27 </toolbar> 28 <spacer flex="1"/> 29 <hbox id="hbox-anchor" 30 style="padding: 20px" 31 onclick="onAnchorClick(event)"> 32 <hbox id="inner-anchor" 33 consumeanchor="hbox-anchor" 34 > 35 Another anchor 36 </hbox> 37 </hbox> 38 <spacer flex="1"/> 39 </vbox> 40 41 <panel id="mypopup" 42 type="arrow" 43 onpopupshown="onMyPopupShown(event)" 44 onpopuphidden="onMyPopupHidden(event)">This is a test popup</panel> 45 46 <!-- test code goes here --> 47 <script type="application/javascript"> 48 <![CDATA[ 49 /** Test for Bug 987230 */ 50 SimpleTest.waitForExplicitFinish(); 51 52 SimpleTest.requestCompleteLog(); 53 54 function onMyPopupHidden(e) { 55 ok(true, "Popup hidden"); 56 if (outerAnchor.id == "toolbarbutton-anchor") { 57 popupHasShown = false; 58 outerAnchor = document.getElementById("hbox-anchor"); 59 anchor = document.getElementById("inner-anchor"); 60 nextTest(); 61 } else { 62 //XXXgijs set mouse position back outside the iframe: 63 let frameRect = window.frameElement.getBoundingClientRect(); 64 let scale = window.devicePixelRatio; 65 let outsideOfFrameX = (window.mozInnerScreenX + frameRect.width + 100) * scale; 66 let outsideOfFrameY = Math.max(0, window.mozInnerScreenY - 100) * scale; 67 68 info("Mousemove: " + outsideOfFrameX + ", " + outsideOfFrameY + 69 " (from innerscreen " + window.mozInnerScreenX + ", " + window.mozInnerScreenY + 70 " and rect width " + frameRect.width + " and scale " + scale + ")"); 71 synthesizeNativeMouseEvent({ 72 type: "mousemove", 73 screenX: outsideOfFrameX, 74 screenY: outsideOfFrameY, 75 scale: "inScreenPixels", 76 elementOnWidget: null, 77 }); 78 SimpleTest.finish(); 79 } 80 } 81 82 let popupHasShown = false; 83 function onMyPopupShown(e) { 84 popupHasShown = true; 85 synthesizeNativeMouseEvent({ type: "click", target: outerAnchor, offsetX: 5, offsetY: 5 }); 86 } 87 88 function onAnchorClick(e) { 89 info("click: " + e.target.id); 90 ok(!popupHasShown, "Popup should only be shown once"); 91 popup.openPopup(anchor, "bottomcenter topright"); 92 } 93 94 let popup, outerAnchor, anchor; 95 96 function startTest() { 97 popup = document.getElementById("mypopup"); 98 outerAnchor = document.getElementById("toolbarbutton-anchor"); 99 anchor = outerAnchor.icon; 100 nextTest(); 101 } 102 103 function nextTest(e) { 104 synthesizeMouse(outerAnchor, 5, 5, {}); 105 } 106 107 ]]> 108 </script> 109 </window>