2009-12-23 10:45:44 -08:00
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
2008-06-15 18:36:28 -07:00
|
|
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
2009-12-23 10:45:44 -08:00
|
|
|
screenX="200" screenY="200" width="300" height="300"
|
|
|
|
onload="setTimeout(doTest, 0)">
|
2008-06-15 18:36:28 -07:00
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
<script><![CDATA[
|
|
|
|
var is = window.opener.SimpleTest.is;
|
|
|
|
|
|
|
|
function doTest() {
|
|
|
|
// from test_resizer.xul
|
|
|
|
var expectX = 200;
|
|
|
|
var expectY = 200;
|
|
|
|
var expectXMost = 500;
|
|
|
|
var expectYMost = 500;
|
|
|
|
var screenScale = expectX/window.screenX;
|
|
|
|
var root = document.documentElement;
|
|
|
|
|
2009-12-23 10:45:44 -08:00
|
|
|
var oldScreenX = window.screenX;
|
|
|
|
var oldScreenY = window.screenY;
|
|
|
|
var oldWidth = window.outerWidth;
|
|
|
|
var oldHeight = window.outerHeight;
|
|
|
|
|
2008-06-15 18:36:28 -07:00
|
|
|
function testResizer(dx, dy) {
|
|
|
|
var offset = 20;
|
|
|
|
var scale = 5;
|
|
|
|
// target the centre of the resizer
|
|
|
|
var offsetX = window.innerWidth/2 + (window.innerWidth/3)*dx;
|
|
|
|
var offsetY = window.innerHeight/2 + (window.innerHeight/3)*dy;
|
|
|
|
|
2009-12-23 10:45:44 -08:00
|
|
|
for (var mouseX = -1; mouseX <= 1; ++mouseX) {
|
|
|
|
for (var mouseY = -1; mouseY <= 1; ++mouseY) {
|
2008-06-15 18:36:28 -07:00
|
|
|
var newExpectX = expectX;
|
|
|
|
var newExpectXMost = expectXMost;
|
|
|
|
var newExpectY = expectY;
|
|
|
|
var newExpectYMost = expectYMost;
|
|
|
|
if (dx < 0) {
|
|
|
|
newExpectX += mouseX*scale;
|
|
|
|
} else if (dx > 0) {
|
|
|
|
newExpectXMost += mouseX*scale;
|
|
|
|
}
|
|
|
|
if (dy < 0) {
|
|
|
|
newExpectY += mouseY*scale;
|
|
|
|
} else if (dy > 0) {
|
|
|
|
newExpectYMost += mouseY*scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
synthesizeMouse(root, offsetX, offsetY, { type:"mousedown" });
|
|
|
|
synthesizeMouse(root, offsetX + mouseX*scale, offsetY + mouseY*scale, { type:"mousemove" });
|
2009-12-23 10:45:44 -08:00
|
|
|
if (window instanceof Components.interfaces.nsIDOMChromeWindow) {
|
|
|
|
is(window.screenX*screenScale, newExpectX,
|
|
|
|
"Bad x for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
|
|
|
|
is(window.screenY*screenScale, newExpectY,
|
|
|
|
"Bad y for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
|
|
|
|
is(window.outerWidth, newExpectXMost - newExpectX,
|
|
|
|
"Bad width for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
|
|
|
|
is(window.outerHeight, newExpectYMost - newExpectY,
|
|
|
|
"Bad height for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
is(window.screenX, oldScreenX, "window not moved for non-chrome window screenX");
|
|
|
|
is(window.screenY, oldScreenY, "window not moved for non-chrome window screenY");
|
|
|
|
is(window.outerWidth, oldWidth, "window not moved for non-chrome window outerWidth");
|
|
|
|
is(window.outerHeight, oldHeight, "window not moved for non-chrome window outerHeight");
|
|
|
|
}
|
|
|
|
|
2008-06-15 18:36:28 -07:00
|
|
|
// move it back before we release! Adjust for any window movement
|
|
|
|
synthesizeMouse(root, offsetX - (newExpectX - expectX),
|
|
|
|
offsetY - (newExpectY - expectY), { type:"mousemove" });
|
|
|
|
synthesizeMouse(root, offsetX, offsetY, { type:"mouseup" });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-23 10:45:44 -08:00
|
|
|
function testElementResizer()
|
|
|
|
{
|
|
|
|
var resizers = document.getElementsByTagName("resizer");
|
|
|
|
for (var r = 0; r < resizers.length; r++) {
|
|
|
|
resizers.setAttribute("element", "container");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-15 18:36:28 -07:00
|
|
|
testResizer(-1, -1);
|
|
|
|
testResizer(-1, 0);
|
|
|
|
testResizer(-1, 1);
|
|
|
|
testResizer(0, -1);
|
|
|
|
testResizer(0, 1);
|
|
|
|
testResizer(1, -1);
|
|
|
|
testResizer(1, 0);
|
|
|
|
testResizer(1, 1);
|
|
|
|
window.close();
|
2009-12-23 10:45:44 -08:00
|
|
|
window.opener.nextResizerTest();
|
2008-06-15 18:36:28 -07:00
|
|
|
}
|
|
|
|
]]></script>
|
|
|
|
<hbox flex="1">
|
|
|
|
<vbox flex="1">
|
|
|
|
<resizer dir="topleft" flex="1"/>
|
|
|
|
<resizer dir="left" flex="1"/>
|
|
|
|
<resizer dir="bottomleft" flex="1"/>
|
|
|
|
</vbox>
|
|
|
|
<vbox flex="1">
|
|
|
|
<resizer dir="top" flex="1"/>
|
|
|
|
<hbox flex="1"/>
|
|
|
|
<resizer dir="bottom" flex="1"/>
|
|
|
|
</vbox>
|
|
|
|
<vbox flex="1">
|
|
|
|
<resizer dir="topright" flex="1"/>
|
|
|
|
<resizer dir="right" flex="1"/>
|
|
|
|
<resizer dir="bottomright" flex="1"/>
|
|
|
|
</vbox>
|
|
|
|
</hbox>
|
|
|
|
</window>
|