2007-08-27 09:23:52 -07:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
|
|
|
|
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
2009-09-03 12:30:07 -07:00
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
|
|
|
|
|
|
|
<menupopup id="popup" onpopupshowing="if (isSecondTest) popupShowing(event)" onpopupshown="popupShown()"
|
|
|
|
onpopuphidden="nextTest()">
|
2007-08-27 09:23:52 -07:00
|
|
|
<menuitem label="One"/>
|
|
|
|
<menuitem label="Two"/>
|
|
|
|
</menupopup>
|
|
|
|
|
2009-09-03 12:30:07 -07:00
|
|
|
<button id="button" label="OK" popup="popup"/>
|
|
|
|
|
2007-08-27 09:23:52 -07:00
|
|
|
<script class="testbody" type="application/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
|
2009-09-03 12:30:07 -07:00
|
|
|
var isSecondTest = false;
|
|
|
|
|
2007-08-27 09:23:52 -07:00
|
|
|
function openPopup()
|
|
|
|
{
|
|
|
|
document.getElementById("popup").openPopup(parent.document.getElementById("outerbutton"), "after_start", 3, 1);
|
|
|
|
}
|
|
|
|
|
2009-09-03 12:30:07 -07:00
|
|
|
function popupShowing(event)
|
|
|
|
{
|
|
|
|
var buttonrect = document.getElementById("button").getBoundingClientRect();
|
|
|
|
parent.opener.wrappedJSObject.SimpleTest.is(event.clientX, buttonrect.left + 6, "popup clientX with mouse");
|
|
|
|
parent.opener.wrappedJSObject.SimpleTest.is(event.clientY, buttonrect.top + 6, "popup clientY with mouse");
|
|
|
|
}
|
|
|
|
|
2007-08-27 09:23:52 -07:00
|
|
|
function popupShown()
|
|
|
|
{
|
2009-09-03 12:30:07 -07:00
|
|
|
var left, top;
|
2007-08-27 09:23:52 -07:00
|
|
|
var popuprect = document.getElementById("popup").getBoundingClientRect();
|
2009-09-03 12:30:07 -07:00
|
|
|
if (isSecondTest) {
|
|
|
|
var buttonrect = document.getElementById("button").getBoundingClientRect();
|
|
|
|
left = buttonrect.left + 6;
|
|
|
|
top = buttonrect.top + 6;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var iframerect = parent.document.getElementById("frame").getBoundingClientRect();
|
|
|
|
var buttonrect = parent.document.getElementById("outerbutton").getBoundingClientRect();
|
|
|
|
|
|
|
|
// The popup should appear anchored on the bottom left edge of the button, however
|
|
|
|
// the client rectangle is relative to the iframe's document. Thus the coordinates
|
|
|
|
// are:
|
|
|
|
// left = iframe's left - anchor button's left - 3 pixel offset passed to openPopup +
|
|
|
|
// iframe border (17px) + iframe padding (0)
|
|
|
|
// top = iframe's top - anchor button's bottom - 1 pixel offset passed to openPopup +
|
|
|
|
// iframe border (0) + iframe padding (3px);
|
|
|
|
left = -(Math.round(iframerect.left) - Math.round(buttonrect.left) + 14);
|
|
|
|
top = -(Math.round(iframerect.top) - Math.round(buttonrect.bottom) + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
var testid = isSecondTest ? "with mouse" : "anchored to parent frame";
|
|
|
|
parent.opener.wrappedJSObject.SimpleTest.is(Math.round(popuprect.left), left, "popup left " + testid);
|
|
|
|
parent.opener.wrappedJSObject.SimpleTest.is(Math.round(popuprect.top), top, "popup top " + testid);
|
|
|
|
|
|
|
|
document.getElementById("popup").hidePopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
function nextTest()
|
|
|
|
{
|
|
|
|
if (isSecondTest) {
|
|
|
|
parent.opener.wrappedJSObject.SimpleTest.finish();
|
|
|
|
parent.close();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// this second test ensures that the popupshowing coordinates when a popup in
|
|
|
|
// a frame is opened are correct
|
|
|
|
isSecondTest = true;
|
|
|
|
synthesizeMouse(document.getElementById("button"), 6, 6, { });
|
|
|
|
}
|
2007-08-27 09:23:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</page>
|