This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository enlightenment.
View the commit online.
commit fe1170bc2db99ec1002119539b923fe132fff903
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Nov 25 21:04:59 2026 -0600
tests - drive Firefox, Chromium and Brave in a browser suite
Every other Wayland test is a client written for the suite. Browsers
are the clients users care about most and the hardest ones: they draw
their own decorations with a shadow outside the window, map helper
windows, and resize at their own pace. This runs each installed one,
checks that it shows the page it was given, and then maximizes,
unmaximizes, moves, resizes and minimises it, checking each time that
it comes back exactly where it was. That is how the configure size bug
fixed before this was found, 5 runs out of 5 with Firefox.
The browser is run-nested.sh's new E_TEST_APP: started in the session
with HOME in the throwaway directory, so the existing cleanup finds all
its processes. E_TEST_APP_CHECK turns a browser that is not installed
into a skip. browser-run.sh gives it a throwaway profile, a private
D-Bus, no network, no DISPLAY and a pinned locale, so nothing of the
user's own session is reached.
The waits are for a state, never for a delay: each step waits until the
window has the geometry it must end up with, with E_TEST_WAIT_SECONDS
raised to 60 for a browser that starts slowly. The suite is left out of
a plain meson test, and runs with --suite browser.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/tests/meson.build | 3 ++
src/tests/wayland/browser-run.sh | 88 +++++++++++++++++++++++++++++++
src/tests/wayland/e_wl_testkit.c | 57 +++++++++++++++++++-
src/tests/wayland/e_wl_testkit.h | 10 +++-
src/tests/wayland/meson.build | 23 +++++++++
src/tests/wayland/pages/probe.html | 5 ++
src/tests/wayland/run-nested.sh | 20 +++++++
src/tests/wayland/test_browser.c | 103 +++++++++++++++++++++++++++++++++++++
8 files changed, 306 insertions(+), 3 deletions(-)
diff --git a/src/tests/meson.build b/src/tests/meson.build
index b00e13daa..4dbbaeef0 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -22,3 +22,6 @@ if get_option('wl') == true
endif
subdir('x11')
+
+# The browser suite runs only when asked for: meson test --suite browser
+add_test_setup('default', exclude_suites: ['browser'], is_default: true)
diff --git a/src/tests/wayland/browser-run.sh b/src/tests/wayland/browser-run.sh
new file mode 100755
index 000000000..a4952b095
--- /dev/null
+++ b/src/tests/wayland/browser-run.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+# Run a browser as run-nested.sh's E_TEST_APP, cut off from the user's own
+# session: a throwaway profile, a private D-Bus so no portal or secret
+# service of the real desktop answers, no network, a pinned locale.
+#
+# browser-run.sh <firefox|chromium|brave> <url>
+# browser-run.sh --find <firefox|chromium|brave> fails when not installed
+
+set -eu
+
+_find() {
+ case "$1" in
+ firefox) set -- firefox firefox-esr ;;
+ chromium) set -- chromium chromium-browser google-chrome google-chrome-stable ;;
+ brave) set -- brave brave-browser ;;
+ *) return 1 ;;
+ esac
+ for b in "$@"; do
+ command -v "$b" 2>/dev/null && return 0
+ done
+ return 1
+}
+
+if [ "${1:-}" = "--find" ]; then
+ _find "${2:-}" >/dev/null
+ exit
+fi
+
+BROWSER=$1
+URL=""
+BIN=$(_find "$BROWSER")
+PROFILE=""
+mkdir -p "$PROFILE"
+
+# The content sandbox of the browsers does not read from the source tree, so
+# a local page is copied next to the profile.
+case "$URL" in
+file://*)
+ cp "${URL#file://}" "$E_TEST_RUNDIR/page.html"
+ URL=""
+ ;;
+esac
+
+ENV="LC_ALL=C.UTF-8 TZ=UTC XDG_SESSION_TYPE=wayland"
+
+case "$BROWSER" in
+firefox)
+ # A new profile opens the startup page but ignores a URL given on the
+ # command line, and so does -private-window.
+ cat > "$PROFILE/user.js" <<JS
+user_pref("browser.startup.homepage", "$URL");
+user_pref("browser.startup.page", 1);
+user_pref("browser.privatebrowsing.autostart", true);
+user_pref("browser.shell.checkDefaultBrowser", false);
+user_pref("browser.startup.homepage_override.mstone", "ignore");
+user_pref("app.update.enabled", false);
+user_pref("datareporting.policy.dataSubmissionEnabled", false);
+user_pref("toolkit.telemetry.enabled", false);
+user_pref("network.captive-portal-service.enabled", false);
+user_pref("network.connectivity-service.enabled", false);
+user_pref("browser.safebrowsing.malware.enabled", false);
+user_pref("browser.safebrowsing.phishing.enabled", false);
+user_pref("extensions.update.enabled", false);
+JS
+ # Without -no-remote, a Firefox already running gets the URL and this
+ # one exits.
+ set -- "$BIN" -profile "$PROFILE" -no-remote "$URL"
+ ENV="$ENV MOZ_ENABLE_WAYLAND=1 MOZ_CRASHREPORTER_DISABLE=1"
+ ;;
+chromium|brave)
+ # Software rendering: the test canvas cannot import GPU buffers, and a
+ # browser finding that out at startup is slow. E_TEST_BROWSER_FLAGS is for
+ # a test that needs a feature turned on.
+ set -- "$BIN" --user-data-dir="$PROFILE" --incognito \
+ --no-first-run --no-default-browser-check \
+ --disable-search-engine-choice-screen \
+ --password-store=basic --use-mock-keychain \
+ --disable-component-update --disable-background-networking \
+ --host-resolver-rules="MAP * ~NOTFOUND" \
+ --ozone-platform=wayland --disable-gpu ${E_TEST_BROWSER_FLAGS:-} \
+ "$URL"
+ ;;
+esac
+
+if command -v dbus-run-session >/dev/null 2>&1; then
+ exec env -u DISPLAY $ENV dbus-run-session -- "$@"
+fi
+exec env -u DISPLAY $ENV DBUS_SESSION_BUS_ADDRESS=unix:path=/nonexistent "$@"
diff --git a/src/tests/wayland/e_wl_testkit.c b/src/tests/wayland/e_wl_testkit.c
index 141777712..d2b1be0fb 100644
--- a/src/tests/wayland/e_wl_testkit.c
+++ b/src/tests/wayland/e_wl_testkit.c
@@ -668,11 +668,19 @@ _tk_now(void)
return ts.tv_sec + (ts.tv_nsec / 1e9);
}
+static int
+_tk_wait_seconds(void)
+{
+ const char *s = getenv("E_TEST_WAIT_SECONDS");
+
+ return (s && (atoi(s) > 0)) ? atoi(s) : TK_WAIT_SECONDS;
+}
+
Tk_Client *
tk_wait_states(Tk *tk, const char *app_id, unsigned int mask,
unsigned int want, const char *what)
{
- double deadline = _tk_now() + TK_WAIT_SECONDS;
+ double deadline = _tk_now() + _tk_wait_seconds();
Tk_Client *c;
for (;;)
@@ -683,7 +691,52 @@ tk_wait_states(Tk *tk, const char *app_id, unsigned int mask,
tk_sync(tk);
}
tk_fail(tk, "%s: states still 0x%x after %ds, waiting for 0x%x in 0x%x",
- what, c->states, TK_WAIT_SECONDS, want, mask);
+ what, c->states, _tk_wait_seconds(), want, mask);
+}
+
+Tk_Client *
+tk_wait(Tk *tk, const char *app_id, int (*done)(const Tk_Client *c, void *data),
+ void *data, const char *what)
+{
+ double deadline = _tk_now() + _tk_wait_seconds();
+ Tk_Client *c;
+
+ for (;;)
+ {
+ c = tk_expect(tk, app_id);
+ if (done(c, data)) return c;
+ if (_tk_now() > deadline) break;
+ tk_sync(tk);
+ }
+ tk_fail(tk, "%s: still %dx%d+%d+%d states 0x%x output %u after %ds", what,
+ c->w, c->h, c->x, c->y, c->states, c->output, _tk_wait_seconds());
+}
+
+Tk_Client *
+tk_wait_window(Tk *tk, const char *app_id_part)
+{
+ double deadline = _tk_now() + _tk_wait_seconds();
+ Tk_Client *best;
+ int i, n;
+
+ for (;;)
+ {
+ best = NULL;
+ n = tk_clients(tk, NULL, 0);
+ for (i = 0; i < n; i++)
+ {
+ Tk_Client *c = &tk->clients[i];
+
+ if (!strstr(c->app_id, app_id_part)) continue;
+ if (!(c->states & WL_TEST_CLIENT_STATE_VISIBLE)) continue;
+ if ((!best) || ((c->w * c->h) > (best->w * best->h))) best = c;
+ }
+ if (best) return best;
+ if (_tk_now() > deadline) break;
+ tk_sync(tk);
+ }
+ tk_fail(tk, "no shown window with an app_id containing '%s' after %ds",
+ app_id_part, _tk_wait_seconds());
}
void
diff --git a/src/tests/wayland/e_wl_testkit.h b/src/tests/wayland/e_wl_testkit.h
index 5005030d6..a01c84528 100644
--- a/src/tests/wayland/e_wl_testkit.h
+++ b/src/tests/wayland/e_wl_testkit.h
@@ -139,10 +139,18 @@ Tk_Client *tk_expect(Tk *tk, const char *app_id);
/* Some of what E does to a window is animated by the theme. Waits, one
* compositor main loop iteration at a time, until the window's states
* masked by mask are want, and fails saying what it waited for if that
- * takes more than TK_WAIT_SECONDS. */
+ * takes more than TK_WAIT_SECONDS, or E_TEST_WAIT_SECONDS when set. */
#define TK_WAIT_SECONDS 10
Tk_Client *tk_wait_states(Tk *tk, const char *app_id, unsigned int mask,
unsigned int want, const char *what);
+/* The same, until done returns non-zero for the window. */
+Tk_Client *tk_wait(Tk *tk, const char *app_id,
+ int (*done)(const Tk_Client *c, void *data), void *data,
+ const char *what);
+/* Waits for a shown window of a program the test did not write, whose
+ * app_id contains app_id_part, and returns the largest one: a browser maps
+ * small helper windows too. */
+Tk_Client *tk_wait_window(Tk *tk, const char *app_id_part);
/* Run one of E's own actions on a window. Empty or NULL params means none. */
void tk_action(Tk *tk, unsigned int id, const char *name, const char *params);
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index 110b62c0a..05406deac 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -145,3 +145,26 @@ if get_option('xwayland') and not config_h.has('HAVE_WAYLAND_ONLY')
)
endforeach
endif
+
+# Real browsers, when installed: slow, and depending on programs this tree
+# does not ship, so they have a suite of their own.
+browser_run = meson.current_source_dir() / 'browser-run.sh'
+test_browser = executable('test_wl_browser',
+ ['test_browser.c', tk_src, test_proto_src],
+ dependencies: [dependency('wayland-client')],
+)
+foreach b: ['firefox', 'chromium', 'brave']
+ test('browser-' + b,
+ run_nested,
+ args: [test_browser, b, 'e-browser-probe'],
+ env: {
+ 'E_TEST_COMPOSITOR': e_test_compositor,
+ 'E_TEST_APP': ' '.join([browser_run, b,
+ 'file://' + meson.current_source_dir() / 'pages' / 'probe.html']),
+ 'E_TEST_APP_CHECK': ' '.join([browser_run, '--find', b]),
+ 'E_TEST_WAIT_SECONDS': '60',
+ },
+ suite: 'browser',
+ timeout: 300,
+ )
+endforeach
diff --git a/src/tests/wayland/pages/probe.html b/src/tests/wayland/pages/probe.html
new file mode 100644
index 000000000..516f08826
--- /dev/null
+++ b/src/tests/wayland/pages/probe.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<title>e-browser-probe</title>
+<body style="margin:0;background:#2b6cb0;color:#fff;font:48px sans-serif">
+ <p style="padding:24px">e-browser-probe</p>
+</body>
diff --git a/src/tests/wayland/run-nested.sh b/src/tests/wayland/run-nested.sh
index 0ed2b242b..37a7bd6f1 100755
--- a/src/tests/wayland/run-nested.sh
+++ b/src/tests/wayland/run-nested.sh
@@ -9,6 +9,11 @@
# E_TEST_BACKEND buffer (default) | x11 | wl -- see E_WL_FORCE
# E_TEST_TIMEOUT seconds to wait for E's socket (default 20)
# E_TEST_KEEP set to 1 to keep the temp dir and print E's log path
+# E_TEST_APP a program the test did not write, run in the session
+# before the client, with HOME and E_TEST_RUNDIR set to the
+# temp dir
+# E_TEST_APP_CHECK a command that fails when that program is not
+# installed, which makes the test a skip (77)
# WAYLAND_DEBUG passed through to the client
#
# The client gets E_TEST_PID, the compositor's pid: Xwayland's lock file names
@@ -36,6 +41,11 @@ if [ -z "$COMPOSITOR" ] || [ ! -f "$COMPOSITOR" ]; then
fi
TIMEOUT=${E_TEST_TIMEOUT:-20}
+if [ -n "${E_TEST_APP_CHECK:-}" ] && ! sh -c "$E_TEST_APP_CHECK" >/dev/null 2>&1; then
+ echo "run-nested.sh: skipped, '$E_TEST_APP_CHECK' failed" >&2
+ exit 77
+fi
+
RUNDIR=$(mktemp -d "${TMPDIR:-/tmp}/e-wl-test.XXXXXX")
chmod 0700 "$RUNDIR"
@@ -142,6 +152,12 @@ if [ -z "$SOCKET" ]; then
exit 1
fi
+# Its HOME is the temp dir, so the cleanup above finds all its processes.
+if [ -n "${E_TEST_APP:-}" ]; then
+ XDG_RUNTIME_DIR="$RUNDIR" WAYLAND_DISPLAY="$SOCKET" HOME="$RUNDIR" \
+ E_TEST_RUNDIR="$RUNDIR" sh -c "$E_TEST_APP" >"$RUNDIR/app.log" 2>&1 &
+fi
+
set +e
XDG_RUNTIME_DIR="$RUNDIR" WAYLAND_DISPLAY="$SOCKET" E_TEST_PID="$E_PID" \
E_TEST_PRIVILEGES_DIR="$RUNDIR/.e/e/wayland-privileges" "$@"
@@ -150,6 +166,10 @@ set -e
if [ $client_status -ne 0 ]; then
echo "run-nested.sh: client '$1' exited $client_status" >&2
+ if [ -s "$RUNDIR/app.log" ]; then
+ echo "--- app log (end) ---" >&2
+ tail -40 "$RUNDIR/app.log" >&2 || :
+ fi
echo "--- compositor log ---" >&2
cat "$E_LOG" >&2 || :
fi
diff --git a/src/tests/wayland/test_browser.c b/src/tests/wayland/test_browser.c
new file mode 100644
index 000000000..92dba410e
--- /dev/null
+++ b/src/tests/wayland/test_browser.c
@@ -0,0 +1,103 @@
+/* A real browser, as browser-run.sh started it: its window has to survive
+ * what a user does to it. Browsers draw their own decorations with a shadow
+ * outside the window, so geometry is checked against where the window
+ * started, not against the screen.
+ *
+ * argv[1] part of the browser's app_id
+ * argv[2] the title of the page it was given */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "e_wl_testkit.h"
+
+#define PROG "test-browser"
+#define MAX (WL_TEST_CLIENT_STATE_MAXIMIZED_H | WL_TEST_CLIENT_STATE_MAXIMIZED_V)
+#define SHOWN (WL_TEST_CLIENT_STATE_ICONIFIED | WL_TEST_CLIENT_STATE_VISIBLE)
+
+typedef struct
+{
+ int x, y, w, h;
+ unsigned int output;
+} Geometry;
+
+static int
+_at(const Tk_Client *c, void *data)
+{
+ const Geometry *g = data;
+
+ return (c->x == g->x) && (c->y == g->y) && (c->w == g->w) && (c->h == g->h) &&
+ (c->output == g->output);
+}
+
+static int
+_bigger(const Tk_Client *c, void *data)
+{
+ const Geometry *g = data;
+
+ return (c->states & MAX) && ((c->w > g->w) || (c->h > g->h));
+}
+
+static int
+_titled(const Tk_Client *c, void *data)
+{
+ return !!strstr(c->title, data);
+}
+
+int
+main(int argc, char **argv)
+{
+ char app_id[256];
+ Geometry start, g;
+ unsigned int id;
+ Tk_Client *c;
+ Tk *tk;
+
+ if (argc < 3) return 2;
+ tk = tk_connect(PROG);
+ c = tk_wait_window(tk, argv[1]);
+ id = c->id;
+ snprintf(app_id, sizeof(app_id), "%s", c->app_id);
+ tk_wait(tk, app_id, _titled, argv[2], "the browser to show the page");
+
+ /* Firefox opens maximized, Chromium does not. */
+ if (tk_expect(tk, app_id)->states & MAX)
+ {
+ tk_action(tk, id, "window_maximized_toggle", NULL);
+ tk_wait_states(tk, app_id, MAX, 0, "unmaximized to start");
+ }
+ c = tk_expect(tk, app_id);
+ start = (Geometry){ c->x, c->y, c->w, c->h, c->output };
+ printf(PROG ": '%s' at %dx%d+%d+%d\n", app_id, start.w, start.h, start.x, start.y);
+
+ tk_action(tk, id, "window_maximized_toggle", NULL);
+ tk_wait(tk, app_id, _bigger, &start, "maximized");
+ tk_action(tk, id, "window_maximized_toggle", NULL);
+ tk_wait(tk, app_id, _at, &start, "unmaximized back where it was");
+
+ g = start;
+ g.x += 50;
+ g.y += 40;
+ tk_action(tk, id, "window_move_by", "50 40");
+ tk_wait(tk, app_id, _at, &g, "moved by 50,40 at the same size");
+ tk_action(tk, id, "window_move_by", "-50 -40");
+ tk_wait(tk, app_id, _at, &start, "moved back");
+
+ g = start;
+ g.w += 120;
+ g.h += 90;
+ tk_action(tk, id, "window_resize_by", "120 90");
+ tk_wait(tk, app_id, _at, &g, "resized by 120,90");
+ tk_action(tk, id, "window_resize_by", "-120 -90");
+ tk_wait(tk, app_id, _at, &start, "resized back");
+
+ tk_action(tk, id, "window_iconic_toggle", NULL);
+ tk_wait_states(tk, app_id, SHOWN, WL_TEST_CLIENT_STATE_ICONIFIED, "iconified");
+ tk_action(tk, id, "window_iconic_toggle", NULL);
+ tk_wait_states(tk, app_id, SHOWN, WL_TEST_CLIENT_STATE_VISIBLE, "restored");
+ tk_wait(tk, app_id, _at, &start, "restored where it was");
+
+ printf(PROG ": ok\n");
+ tk_disconnect(tk);
+ return 0;
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.