summaryrefslogtreecommitdiffstats
path: root/layout/forms/test/test_bug665540.html
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/forms/test/test_bug665540.html
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/forms/test/test_bug665540.html')
-rw-r--r--layout/forms/test/test_bug665540.html133
1 files changed, 133 insertions, 0 deletions
diff --git a/layout/forms/test/test_bug665540.html b/layout/forms/test/test_bug665540.html
new file mode 100644
index 0000000000..b84c5afd57
--- /dev/null
+++ b/layout/forms/test/test_bug665540.html
@@ -0,0 +1,133 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=665540
+-->
+<head>
+ <title>Test for Bug 665540 Select dropdown position in fullscreen window</title>
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+</head>
+<body onload="openFullscreenWindow()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=665540">Mozilla Bug 665540</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 665540 **/
+
+SimpleTest.waitForExplicitFinish();
+
+var win;
+var select;
+var optiona;
+var eventType = "mouseover";
+var timeoutID;
+var eventOffsetX = 2;
+var eventOffsetY = 2;
+
+let sizemodeChanged = false;
+let fullscreenChanged = false;
+let childHasFocused = false;
+
+function openFullscreenWindow() {
+ win = window.browsingContext.topChromeWindow
+ .openDialog("bug665540_window.xhtml", "_blank", "resizable=yes,chrome");
+
+ win.addEventListener("sizemodechange", () => {
+ info("sizemodechange. windowState = " + win.windowState + " fullScreen = " + win.fullScreen);
+ sizemodeChanged = true;
+ tryStart();
+ }, { once: true });
+
+ win.addEventListener("fullscreen", () => {
+ info("fullscreen event. windowState = " + win.windowState + " fullScreen = " + win.fullScreen);
+ fullscreenChanged = true;
+ tryStart();
+ }, { once: true });
+
+ SimpleTest.waitForFocus(() => {
+ win.fullScreen = true;
+ }, win);
+
+ // Close our window if the test times out so that it doesn't interfere
+ // with later tests.
+ timeoutID = setTimeout(function () {
+ ok(false, "Test timed out.");
+ // Provide some time for a screenshot
+ setTimeout(finish, 1000);
+ }, 20000);
+}
+
+function tryStart() {
+ // wait until the window goes full screen and its size mode actually changes.
+ if (!sizemodeChanged || !fullscreenChanged) {
+ return;
+ }
+ SimpleTest.waitForFocus(start, win);
+}
+
+function start() {
+ // The select doesn't open if the mouse click is fired too soon
+ // (on X11 at least).
+ setTimeout(openSelect, 1000);
+}
+
+function openSelect() {
+ select = win.document.getElementById("select");
+ synthesizeMouseAtCenter(select, {}, win);
+ // A yield was required on X11 tinderbox machines.
+ // (Wasn't required on other platforms nor on an X11 system with kwin.)
+ setTimeout(checkPosition, 1000);
+}
+
+function checkPosition() {
+ optiona = win.document.getElementById("optiona");
+ optiona.addEventListener(eventType, eventReceived);
+
+ // If the select dropdown is opened in the position where
+ // getBoundingClientRect() predicts, then optiona will receive the event.
+ // The event is received asynchronously (I don't know why), so the handler
+ // is removed later.
+ synthesizeMouse(optiona, eventOffsetX, eventOffsetY,
+ { type: eventType }, win);
+}
+
+function eventReceived(event) {
+ clearTimeout(timeoutID);
+ optiona.removeEventListener(eventType, eventReceived);
+
+ var rect = optiona.getBoundingClientRect();
+
+ // Note that fullscreen only fully covers one monitor, so win.screenX can
+ // be non-zero.
+ is(event.screenX, win.screenX + rect.left + eventOffsetX,
+ "event.screenX should match sent event");
+ is(event.screenY, win.screenY + rect.top + eventOffsetY,
+ "event.screenY should match sent event");
+
+ finish();
+}
+
+function finish() {
+ if (select && navigator.platform.includes("Win")) {
+ todo(false,
+ "Should not have to close select before closing its window");
+ // This avoids mochitest "Unable to restore focus" errors (bug 670053).
+ synthesizeMouseAtCenter(select, {}, win);
+ }
+
+ is(win.windowState, win.STATE_FULLSCREEN,
+ "window state should still be fullscreen");
+
+ win.close();
+ SimpleTest.finish();
+}
+</script>
+</pre>
+</body>
+</html>