summaryrefslogtreecommitdiffstats
path: root/layout/xul/test/window_resizer.xhtml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /layout/xul/test/window_resizer.xhtml
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/xul/test/window_resizer.xhtml')
-rw-r--r--layout/xul/test/window_resizer.xhtml113
1 files changed, 113 insertions, 0 deletions
diff --git a/layout/xul/test/window_resizer.xhtml b/layout/xul/test/window_resizer.xhtml
new file mode 100644
index 0000000000..8e3ca6d159
--- /dev/null
+++ b/layout/xul/test/window_resizer.xhtml
@@ -0,0 +1,113 @@
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ screenX="200" screenY="200" width="300" height="300"
+ onload="setTimeout(doTest, 0)">
+<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+<script><![CDATA[
+var is = window.arguments[0].SimpleTest.is;
+
+function doTest() {
+ // from test_resizer.xhtml
+ var expectX = 200;
+ var expectY = 200;
+ var expectXMost = 500;
+ var expectYMost = 500;
+ var screenScale = expectX/window.screenX;
+ var root = document.documentElement;
+
+ var oldScreenX = window.screenX;
+ var oldScreenY = window.screenY;
+ var oldWidth = window.outerWidth;
+ var oldHeight = window.outerHeight;
+
+ 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;
+
+ for (var mouseX = -1; mouseX <= 1; ++mouseX) {
+ for (var mouseY = -1; mouseY <= 1; ++mouseY) {
+ 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" });
+ 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);
+
+ // 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" });
+ }
+ }
+ }
+
+ testResizer(-1, -1);
+ testResizer(-1, 0);
+ testResizer(-1, 1);
+ testResizer(0, -1);
+ testResizer(0, 1);
+ testResizer(1, -1);
+ testResizer(1, 0);
+ testResizer(1, 1);
+
+ var resizers = document.getElementsByTagName("resizer");
+ Array.prototype.forEach.call(resizers, function (element) {
+ is(getComputedStyle(element, "").cursor,
+ element.getAttribute("expectedcursor"),
+ "cursor for " + element.getAttribute("dir"));
+ });
+
+ // now check the cursors in rtl. The bottomend resizer
+ // should be reversed
+ document.documentElement.setAttribute("localedir", "rtl");
+ Array.prototype.forEach.call(resizers, function (element) {
+ is(getComputedStyle(element, "").cursor,
+ element.getAttribute("dir") == "bottomend" ? "sw-resize" :
+ element.getAttribute("expectedcursor"),
+ "cursor for " + element.getAttribute("dir"));
+ });
+
+ window.close();
+ window.arguments[0].lastResizerTest();
+}
+]]></script>
+ <hbox id="container" flex="1">
+ <vbox flex="1">
+ <resizer dir="topleft" expectedcursor="nw-resize" flex="1"/>
+ <resizer dir="left" expectedcursor="ew-resize" flex="1"/>
+ <resizer dir="bottomleft" expectedcursor="sw-resize" flex="1"/>
+ </vbox>
+ <vbox flex="1">
+ <resizer dir="top" expectedcursor="ns-resize" flex="1"/>
+ <resizer id="bottomend" dir="bottomend" expectedcursor="se-resize" flex="1"/>
+ <resizer dir="bottom" expectedcursor="ns-resize" flex="1"/>
+ </vbox>
+ <vbox flex="1">
+ <resizer dir="topright" expectedcursor="ne-resize" flex="1"/>
+ <resizer dir="right" expectedcursor="ew-resize" flex="1"/>
+ <resizer dir="bottomright" expectedcursor="se-resize" flex="1"/>
+ </vbox>
+ </hbox>
+</window>