2009-12-23 10:45:44 -08:00
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
|
|
align="start">
|
2011-09-29 13:05:10 -07:00
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
2009-12-23 10:45:44 -08:00
|
|
|
<script><![CDATA[
|
|
|
|
var is = window.opener.SimpleTest.is;
|
2013-01-03 11:02:36 -08:00
|
|
|
window.onerror = window.opener.onerror;
|
2009-12-23 10:45:44 -08:00
|
|
|
|
|
|
|
const anchorPositions =
|
|
|
|
[ "before_start", "before_end", "after_start", "after_end",
|
|
|
|
"start_before", "start_after", "end_before", "end_after", "overlap", "screen"];
|
|
|
|
var currentPosition;
|
|
|
|
|
|
|
|
function testResizer(resizerid, noShrink, hResize, vResize, testid)
|
|
|
|
{
|
|
|
|
var rect = document.getElementById(resizerid + "-container").getBoundingClientRect();
|
|
|
|
var resizer = document.getElementById(resizerid);
|
|
|
|
var resizerrect = resizer.getBoundingClientRect();
|
|
|
|
|
|
|
|
var originalX = resizerrect.left;
|
|
|
|
var originalY = resizerrect.top;
|
|
|
|
|
|
|
|
const scale = 20;
|
|
|
|
for (var mouseX = -1; mouseX <= 1; ++mouseX) {
|
|
|
|
for (var mouseY = -1; mouseY <= 1; ++mouseY) {
|
|
|
|
var expectedWidth = rect.width + hResize * mouseX * scale;
|
|
|
|
var expectedHeight = rect.height + vResize * mouseY * scale;
|
|
|
|
|
|
|
|
if (noShrink) {
|
|
|
|
if (mouseX == -1)
|
|
|
|
expectedWidth = rect.width;
|
|
|
|
if (mouseY == -1)
|
|
|
|
expectedHeight = rect.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
synthesizeMouse(document.documentElement, originalX + 5, originalY + 5, { type:"mousedown" });
|
|
|
|
synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
|
|
|
|
originalY + 5 + mouseY * scale, { type:"mousemove" });
|
|
|
|
|
|
|
|
var newrect = document.getElementById(resizerid + "-container").getBoundingClientRect();
|
|
|
|
is(Math.round(newrect.width), Math.round(expectedWidth), "resize element " + resizerid +
|
|
|
|
" " + testid + " width moving " + mouseX + "," + mouseY + ",,," + hResize);
|
|
|
|
is(Math.round(newrect.height), Math.round(expectedHeight), "resize element " + resizerid +
|
|
|
|
" " + testid + " height moving " + mouseX + "," + mouseY);
|
2011-08-18 07:25:36 -07:00
|
|
|
// release
|
|
|
|
synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
|
2011-09-29 13:05:10 -07:00
|
|
|
originalY + 5 + mouseY * scale, { type:"mouseup" });
|
2011-08-18 07:25:36 -07:00
|
|
|
// return to the original size
|
|
|
|
synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
|
2011-09-29 13:05:10 -07:00
|
|
|
originalY + 5 + mouseY * scale, { type:"dblclick" });
|
2011-08-18 07:25:36 -07:00
|
|
|
var newrect = document.getElementById(resizerid + "-container").getBoundingClientRect();
|
|
|
|
is(Math.round(newrect.width), Math.round(rect.width), "resize element " + resizerid +
|
|
|
|
" " + testid + " doubleclicking to restore original size");
|
|
|
|
is(Math.round(newrect.height), Math.round(rect.height), "resize element " + resizerid +
|
|
|
|
" " + testid + " doubleclicking to restore original size");
|
2011-09-29 13:05:10 -07:00
|
|
|
}
|
2009-12-23 10:45:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function doTest() {
|
|
|
|
// first, check if a resizer with a element attribute set to an element that
|
|
|
|
// does not exist does not cause a problem
|
|
|
|
var resizer = document.getElementById("notfound");
|
|
|
|
synthesizeMouse(resizer, 5, 5, { type:"mousedown" });
|
|
|
|
synthesizeMouse(resizer, 10, 10, { type:"mousemove" });
|
|
|
|
synthesizeMouse(resizer, 5, 5, { type:"mouseup" });
|
|
|
|
|
|
|
|
testResizer("outside", true, 1, 1, "");
|
|
|
|
testResizer("html", true, 1, 1, "");
|
|
|
|
testResizer("inside", true, 1, 1, "");
|
|
|
|
testResizer("inside-large", false, 1, 1, "");
|
|
|
|
testResizer("inside-with-border", true, 1, 1, "");
|
|
|
|
|
|
|
|
document.getElementById("inside-popup-container").
|
|
|
|
openPopupAtScreen(Math.ceil(window.mozInnerScreenX) + 100, Math.ceil(window.mozInnerScreenY) + 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
function popupShown(event)
|
|
|
|
{
|
|
|
|
testResizer("inside-popup", false, 1, 1, "");
|
|
|
|
document.getElementById("inside-popup-container").id = "outside-popup-container";
|
|
|
|
testResizer("outside-popup", false, 1, 1, "");
|
|
|
|
|
|
|
|
var resizerrect = document.getElementById("inside-popup").getBoundingClientRect();
|
|
|
|
synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mousedown" });
|
|
|
|
synthesizeMouse(document.documentElement, resizerrect.left + 2000, resizerrect.top + 2000, { type:"mousemove" });
|
|
|
|
|
|
|
|
var isMac = (navigator.platform.indexOf("Mac") >= 0);
|
|
|
|
var popuprect = document.getElementById("outside-popup-container").getBoundingClientRect();
|
|
|
|
// subtract 3 due to space left for panel dropshadow
|
|
|
|
is(Math.ceil(window.mozInnerScreenX) + popuprect.right,
|
|
|
|
(isMac ? screen.availLeft + screen.availWidth : screen.left + screen.width) - 3, "resized to edge width");
|
|
|
|
is(Math.ceil(window.mozInnerScreenY) + popuprect.bottom,
|
|
|
|
(isMac ? screen.availTop + screen.availHeight : screen.top + screen.height) - 3, "resized to edge height");
|
|
|
|
|
|
|
|
resizerrect = document.getElementById("inside-popup").getBoundingClientRect();
|
|
|
|
synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mouseup" });
|
|
|
|
|
|
|
|
event.target.hidePopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
function popupHidden()
|
|
|
|
{
|
|
|
|
if (anchorPositions.length == 0) {
|
|
|
|
window.close();
|
|
|
|
window.opener.SimpleTest.finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
currentPosition = anchorPositions.shift();
|
|
|
|
var anchor = document.getElementById("anchor");
|
|
|
|
var popup = document.getElementById("anchored-panel-container");
|
|
|
|
|
|
|
|
if (currentPosition == "screen")
|
|
|
|
popup.openPopupAtScreen(window.screenX + 100, window.screenY + 100);
|
|
|
|
else
|
|
|
|
popup.openPopup(anchor, currentPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
function anchoredPopupShown(event)
|
|
|
|
{
|
|
|
|
var leftAllowed = (currentPosition.indexOf("end_") == -1 && currentPosition.indexOf("_start") == -1);
|
|
|
|
var rightAllowed = (currentPosition.indexOf("start_") == -1 && currentPosition.indexOf("_end") == -1);
|
|
|
|
var topAllowed = (currentPosition.indexOf("after_") == -1 && currentPosition.indexOf("_before") == -1);
|
|
|
|
var bottomAllowed = (currentPosition.indexOf("before_") == -1 && currentPosition.indexOf("_after") == -1);
|
|
|
|
|
|
|
|
if (currentPosition == "overlap") {
|
|
|
|
leftAllowed = topAllowed = false;
|
|
|
|
rightAllowed = bottomAllowed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var resizerTypes = [ "topleft", "top", "topright", "left", "right",
|
|
|
|
"bottomleft", "bottom", "bottomright", "bottomend" ];
|
|
|
|
for (var r = 0; r < resizerTypes.length; r++) {
|
|
|
|
var resizerType = resizerTypes[r];
|
|
|
|
var horiz = 0, vert = 0;
|
|
|
|
if (leftAllowed && resizerType.indexOf("left") >= 0) horiz = -1;
|
|
|
|
else if (rightAllowed && (resizerType.indexOf("right") >= 0 || resizerType == "bottomend")) horiz = 1;
|
|
|
|
|
|
|
|
if (topAllowed && resizerType.indexOf("top") >= 0) vert = -1;
|
|
|
|
else if (bottomAllowed && resizerType.indexOf("bottom") >= 0) vert = 1;
|
|
|
|
|
|
|
|
document.getElementById("anchored-panel").dir = resizerType;
|
|
|
|
testResizer("anchored-panel", false, horiz, vert, currentPosition + " " + resizerType);
|
|
|
|
}
|
|
|
|
|
|
|
|
event.target.hidePopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
window.opener.SimpleTest.waitForFocus(doTest, window);
|
|
|
|
]]></script>
|
|
|
|
|
|
|
|
<resizer id="outside" dir="bottomend" element="outside-container"/>
|
|
|
|
<resizer id="notfound" dir="bottomend" element="nothing"/>
|
|
|
|
<hbox id="outside-container">
|
|
|
|
<hbox minwidth="46" minheight="39"/>
|
|
|
|
</hbox>
|
|
|
|
<html:div id="html-container" xmlns:html="http://www.w3.org/1999/xhtml">
|
|
|
|
<html:button>One</html:button><html:br/>
|
|
|
|
<resizer id="html" dir="bottomend" element="_parent"/>
|
|
|
|
</html:div>
|
|
|
|
<hbox id="anchor" align="start" style="margin-left: 100px;">
|
2010-03-19 04:49:33 -07:00
|
|
|
<hbox id="inside-container" align="start">
|
2009-12-23 10:45:44 -08:00
|
|
|
<hbox minwidth="45" minheight="41"/>
|
|
|
|
<resizer id="inside" dir="bottomend" element="_parent"/>
|
|
|
|
</hbox>
|
2010-03-19 04:49:33 -07:00
|
|
|
<hbox id="inside-large-container" width="70" height="70" align="start">
|
2009-12-23 10:45:44 -08:00
|
|
|
<resizer id="inside-large" dir="bottomend" element="_parent"/>
|
|
|
|
</hbox>
|
2010-03-19 04:49:33 -07:00
|
|
|
<hbox id="inside-with-border-container" style="border: 5px solid red; padding: 2px; margin: 2px;" align="start">
|
2009-12-23 10:45:44 -08:00
|
|
|
<hbox minwidth="35" minheight="30"/>
|
|
|
|
<resizer id="inside-with-border" dir="bottomend" element="_parent"/>
|
|
|
|
</hbox>
|
|
|
|
</hbox>
|
|
|
|
|
2010-03-19 04:49:33 -07:00
|
|
|
<panel id="inside-popup-container" align="start" onpopupshown="popupShown(event)" onpopuphidden="popupHidden()">
|
2009-12-23 10:45:44 -08:00
|
|
|
<resizer id="inside-popup" dir="bottomend"/>
|
|
|
|
<hbox width="50" height="50" flex="1"/>
|
|
|
|
</panel>
|
|
|
|
<resizer id="outside-popup" dir="bottomend" element="outside-popup-container"/>
|
|
|
|
|
2010-03-19 04:49:33 -07:00
|
|
|
<panel id="anchored-panel-container" align="start" onpopupshown="anchoredPopupShown(event)"
|
2009-12-23 10:45:44 -08:00
|
|
|
onpopuphidden="popupHidden()">
|
|
|
|
<hbox width="50" height="50" flex="1"/>
|
|
|
|
<resizer id="anchored-panel" width="20" height="20"/>
|
|
|
|
</panel>
|
|
|
|
|
|
|
|
</window>
|