summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml')
-rw-r--r--toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml130
1 files changed, 130 insertions, 0 deletions
diff --git a/toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml b/toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml
new file mode 100644
index 0000000000..524a95b643
--- /dev/null
+++ b/toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml
@@ -0,0 +1,130 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onpopupshown="popupshown(event.target)" onpopuphidden="nextTest()">
+
+<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<label value="Popup Test"/>
+
+<menupopup id="popup">
+ <menuitem label="One"/>
+ <menuitem label="Two"/>
+</menupopup>
+
+<panel id="panel" noautohide="true" height="20">
+ <label value="OK"/>
+</panel>
+
+<script>
+<![CDATA[
+
+let menupopup;
+function margins(popup) {
+ let ret = {};
+ let cs = getComputedStyle(popup);
+ for (let side of ["top", "right", "bottom", "left"]) {
+ ret[side] = parseFloat(cs.getPropertyValue("margin-" + side));
+ }
+ return ret;
+}
+
+let tests = [
+ {
+ test: () => menupopup.openPopupAtScreenRect("after_start", 150, 250, 30, 40),
+ verify: popup => {
+ let rect = popup.getOuterScreenRect();
+ let margin = margins(popup);
+ is(rect.left - margin.left, 150, "popup at screen position x");
+ is(rect.top - margin.top, 290, "popup at screen position y");
+ }
+ },
+ {
+ test: () => menupopup.openPopupAtScreenRect("after_start", 150, 350, 30, 9000),
+ verify: popup => {
+ let rect = popup.getOuterScreenRect();
+ let margin = margins(popup);
+ is(rect.left - margin.left, 150, "flipped popup at screen position x");
+ is(rect.bottom + margin.bottom, 350, "flipped popup at screen position y");
+ }
+ },
+ {
+ test: () => menupopup.openPopupAtScreenRect("end_before", 150, 250, 30, 40),
+ verify: popup => {
+ let rect = popup.getOuterScreenRect();
+ let margin = margins(popup);
+ is(rect.left - margin.left, 180, "popup at end_before screen position x");
+ is(rect.top - margin.top, 250, "popup at end_before screen position y");
+ }
+ },
+ {
+ test: () => $("panel").openPopupAtScreenRect("after_start", 150, 250, 30, 40),
+ verify: popup => {
+ let rect = popup.getOuterScreenRect();
+ let margin = margins(popup);
+ is(rect.left - margin.left, 150, "panel at screen position x");
+ is(rect.top - margin.top, 290, "panel at screen position y");
+ }
+ },
+ {
+ test: () => $("panel").openPopupAtScreenRect("before_start", 150, 250, 30, 40),
+ verify: popup => {
+ let rect = popup.getOuterScreenRect();
+ let margin = margins(popup);
+ is(rect.left - margin.left, 150, "panel at before_start screen position x");
+ is(rect.bottom + margin.bottom, 250, "panel at before_start screen position y");
+ }
+ },
+];
+
+function runTest(id)
+{
+ menupopup = $("popup");
+ nextTest();
+}
+
+function nextTest()
+{
+ if (!tests.length) {
+ window.close();
+ window.arguments[0].SimpleTest.finish();
+ return;
+ }
+
+ tests[0].test();
+}
+
+function popupshown(popup)
+{
+ tests[0].verify(popup);
+ tests.shift();
+ popup.hidePopup();
+}
+
+function is(left, right, message)
+{
+ window.arguments[0].SimpleTest.is(left, right, message);
+}
+
+function ok(value, message)
+{
+ window.arguments[0].SimpleTest.ok(value, message);
+}
+
+window.arguments[0].SimpleTest.waitForFocus(runTest, window);
+
+]]>
+</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>