2008-06-15 18:36:28 -07:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
2011-09-29 13:05:10 -07:00
|
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
2008-06-15 18:36:28 -07:00
|
|
|
<!--
|
|
|
|
XUL <resizer> tests
|
|
|
|
-->
|
|
|
|
<window title="XUL resizer tests"
|
2009-12-23 10:45:44 -08:00
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
2011-09-29 13:05:10 -07:00
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
2008-06-15 18:36:28 -07:00
|
|
|
|
2009-07-27 01:47:02 -07:00
|
|
|
<!-- test results are displayed in the html:body -->
|
2008-06-15 18:36:28 -07:00
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
</body>
|
|
|
|
|
|
|
|
<!-- test code goes here -->
|
|
|
|
<script type="application/javascript"><![CDATA[
|
2009-12-23 10:45:44 -08:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
2011-11-12 03:06:54 -08:00
|
|
|
SimpleTest.ignoreAllUncaughtExceptions();
|
2008-06-15 18:36:28 -07:00
|
|
|
|
2009-12-23 10:45:44 -08:00
|
|
|
function openPopup()
|
|
|
|
{
|
|
|
|
document.getElementById("panel").
|
|
|
|
openPopupAtScreen(Math.round(window.mozInnerScreenX) + window.innerWidth - 130,
|
|
|
|
Math.round(window.mozInnerScreenY) + window.innerHeight - 130);
|
2008-06-15 18:36:28 -07:00
|
|
|
}
|
2009-12-23 10:45:44 -08:00
|
|
|
|
|
|
|
var step = 0;
|
|
|
|
function popupShown(event)
|
|
|
|
{
|
|
|
|
if (step == 0) {
|
|
|
|
// check to make sure that the popup cannot be resized past the edges of
|
|
|
|
// the content area
|
|
|
|
var resizerrect = document.getElementById("resizer").getBoundingClientRect();
|
|
|
|
synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mousedown" });
|
|
|
|
synthesizeMouse(document.documentElement, resizerrect.left + 2000, resizerrect.top + 2000, { type:"mousemove" });
|
|
|
|
|
|
|
|
// allow a one pixel variance as rounding is always done to the inside
|
|
|
|
// of a rectangle.
|
|
|
|
var popuprect = document.getElementById("panel").getBoundingClientRect();
|
|
|
|
ok(Math.round(popuprect.right) == window.innerWidth ||
|
|
|
|
Math.round(popuprect.right) == window.innerWidth - 1,
|
|
|
|
"resized to content edge width");
|
|
|
|
ok(Math.round(popuprect.bottom) == window.innerHeight ||
|
|
|
|
Math.round(popuprect.bottom) == window.innerHeight - 1,
|
|
|
|
"resized to content edge height");
|
|
|
|
|
|
|
|
resizerrect = document.getElementById("resizer").getBoundingClientRect();
|
|
|
|
synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mouseup" });
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// the popup is opened twice. Make sure that for the second time, the
|
|
|
|
// resized popup opens in the same direction as there should still be
|
|
|
|
// room for it
|
|
|
|
var popuprect = document.getElementById("panel").getBoundingClientRect();
|
|
|
|
is(Math.round(popuprect.left), window.innerWidth - 130, "reopen popup left");
|
|
|
|
is(Math.round(popuprect.top), window.innerHeight - 130, "reopen popup top");
|
|
|
|
}
|
|
|
|
|
|
|
|
event.target.hidePopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
function doResizerWindowTests() {
|
|
|
|
step++;
|
|
|
|
if (step == 1) {
|
|
|
|
openPopup();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (/Mac/.test(navigator.platform)) {
|
|
|
|
window.open("window_resizer.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome");
|
|
|
|
}
|
|
|
|
else {
|
2010-03-02 05:25:49 -08:00
|
|
|
// Skip window_resizer.xul tests.
|
|
|
|
todo(false, "We can't test GTK and Windows native drag resizing implementations.");
|
|
|
|
// Run window_resizer_element.xul test only.
|
2009-12-23 10:45:44 -08:00
|
|
|
lastResizerTest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function lastResizerTest()
|
|
|
|
{
|
|
|
|
window.open("window_resizer_element.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome");
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForFocus(openPopup);
|
2008-06-15 18:36:28 -07:00
|
|
|
]]></script>
|
2009-12-23 10:45:44 -08:00
|
|
|
|
|
|
|
<panel id="panel" onpopupshown="popupShown(event)" onpopuphidden="doResizerWindowTests()">
|
|
|
|
<resizer id="resizer" dir="bottomend" width="16" height="16"/>
|
|
|
|
<hbox width="50" height="50" flex="1"/>
|
|
|
|
</panel>
|
|
|
|
|
2008-06-15 18:36:28 -07:00
|
|
|
</window>
|