2007-11-22 06:12:03 -08:00
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
|
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
|
|
|
|
|
|
|
|
|
|
<window title="Popups in Scaled Content"
|
|
|
|
|
onload="setTimeout(runTests, 0);"
|
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
|
|
|
|
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
|
|
|
|
|
|
<!-- This test checks that the position is correct in two cases:
|
|
|
|
|
- a popup anchored at an element in a scaled document
|
|
|
|
|
- a popup opened at a screen coordinate in a scaled window
|
|
|
|
|
-->
|
|
|
|
|
|
|
|
|
|
<iframe id="frame" width="60" height="140"
|
2008-04-18 20:45:33 -07:00
|
|
|
|
src="data:text/html,<html><body><input size='4' id='one'><input size='4' id='two'></body></html>"/>
|
2007-11-22 06:12:03 -08:00
|
|
|
|
|
|
|
|
|
<menupopup id="popup" onpopupshown="shown()" onpopuphidden="nextTest()">
|
|
|
|
|
<menuitem label="One"/>
|
|
|
|
|
</menupopup>
|
|
|
|
|
|
|
|
|
|
<script class="testbody" type="application/javascript">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
|
|
var screenTest = false;
|
|
|
|
|
var screenx = -1, screeny = -1;
|
|
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
|
|
function runTests()
|
|
|
|
|
{
|
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
|
setScale($("frame").contentWindow, 2);
|
|
|
|
|
|
|
|
|
|
var anchor = $("frame").contentDocument.getElementById("two");
|
|
|
|
|
$("popup").openPopup(anchor, "after_start");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setScale(win, scale)
|
|
|
|
|
{
|
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
|
var wn = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
|
|
|
|
.getInterface(Components.interfaces.nsIWebNavigation);
|
|
|
|
|
var shell = wn.QueryInterface(Components.interfaces.nsIDocShell);
|
|
|
|
|
var docViewer = shell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
|
|
|
|
|
docViewer.fullZoom = scale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function shown()
|
|
|
|
|
{
|
|
|
|
|
if (screenTest) {
|
2009-11-17 12:30:25 -08:00
|
|
|
|
var box = $("popup").boxObject;
|
|
|
|
|
is(box.screenX, screenx, "screen left position");
|
|
|
|
|
is(box.screenY, screeny, "screen top position");
|
2007-11-22 06:12:03 -08:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
|
|
|
|
|
|
var anchor = $("frame").contentDocument.getElementById("two");
|
|
|
|
|
|
|
|
|
|
is(Math.round(anchor.getBoundingClientRect().left * 2),
|
|
|
|
|
Math.round($("popup").getBoundingClientRect().left), "anchored left position");
|
|
|
|
|
is(Math.round(anchor.getBoundingClientRect().bottom * 2),
|
|
|
|
|
Math.round($("popup").getBoundingClientRect().top), "anchored top position");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("popup").hidePopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function nextTest()
|
|
|
|
|
{
|
|
|
|
|
if (screenTest) {
|
2008-04-18 20:45:33 -07:00
|
|
|
|
setScale(window, 1);
|
2007-11-22 06:12:03 -08:00
|
|
|
|
SimpleTest.finish();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
screenTest = true;
|
2009-11-17 12:30:25 -08:00
|
|
|
|
var box = document.documentElement.boxObject;
|
|
|
|
|
|
2009-11-18 01:36:22 -08:00
|
|
|
|
// - the iframe is at 4×, but out here css pixels are only 2× device pixels
|
|
|
|
|
// - the popup manager rounds off (or truncates) the coordinates to
|
|
|
|
|
// integers, so ensure we pass in even numbers to openPopupAtScreen
|
|
|
|
|
screenx = (x = even(box.screenX + 120))/2;
|
|
|
|
|
screeny = (y = even(box.screenY + 120))/2;
|
2009-11-18 04:15:03 -08:00
|
|
|
|
setScale(window, 2);
|
2009-11-17 12:30:25 -08:00
|
|
|
|
$("popup").openPopupAtScreen(x, y);
|
2007-11-22 06:12:03 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-18 01:36:22 -08:00
|
|
|
|
function even(n)
|
|
|
|
|
{
|
|
|
|
|
return (n % 2) ? n+1 : n;
|
|
|
|
|
}
|
2007-11-22 06:12:03 -08:00
|
|
|
|
]]>
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
|
<p id="display">
|
|
|
|
|
</p>
|
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
</div>
|
|
|
|
|
<pre id="test">
|
|
|
|
|
</pre>
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
|
|
</window>
|