WEFT_OS/tests/frame/input.html

32 lines
1.1 KiB
HTML
Raw Permalink Normal View History

test: verify native pointer and keyboard input through weft-compositor Nothing checked that input reaches a page through the compositor; the Servo hosts' input forwarding had only been compiled. tests/frame/check_input.py runs weft-servo-shell with tests/frame/input.html on the nested desktop and injects real X input with xdotool into weft-compositor's window. The compositor's winit backend routes it through its seat to the Wayland client, which has no X display. The page must react in its presented pixels: clicks 6 px either side of the boundary between its halves change only the half under the pointer, and the a and Shift+a key presses arrive with the right key value and modifier. The harness gives the compositor's X window input focus, as a window manager would; the client's keyboard focus comes from the compositor's click-to-focus. The nested desktop setup shared with check_frame.py moves to tests/frame/session.py. Xvfb now reports the display it picked through -displayfd, so concurrent runs cannot share an X server, and a run clears only the logs and capture it writes. Validation: - check_input.py: 3 of 3 runs pass; two concurrent runs pass - negative pages fail: no script; left click handled by the right half; an element extending the left half 20 px across the boundary; a key handler ignoring Shift - check_frame.py --host system, --host app, --host app --slow-style 3 pass after the refactor - unverified: key release and repeat, pointer motion and button release events, wheel, focus loss, non-US layouts, non-ASCII text, scale changes, weft-app-shell input
2026-10-09 01:18:53 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WEFT input reference</title>
<style>
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
body { display: grid; grid-template-columns: 1fr 1fr; }
#left { background: rgb(255, 0, 0); }
#right { background: rgb(0, 0, 255); }
</style>
</head>
<body>
<div id="left"></div>
<div id="right"></div>
<script>
// Each input the harness sends changes one half to a colour it checks for.
const left = document.getElementById("left");
const right = document.getElementById("right");
left.addEventListener("click", () => { left.style.background = "rgb(0, 255, 0)"; });
right.addEventListener("click", () => { right.style.background = "rgb(255, 255, 255)"; });
document.addEventListener("keydown", (event) => {
if (event.key === "a" && !event.shiftKey) {
right.style.background = "rgb(255, 255, 0)";
} else if (event.key === "A" && event.shiftKey) {
right.style.background = "rgb(255, 0, 255)";
}
});
</script>
</body>
</html>