S006: R4-05 clicks, keys and wheel reach web pages again
window_input asked egui's is_pointer_over_egui, which is true over the page because it sits in the central panel; only floating layers count now. Selftest click/rclick/pagescroll go through window_input, pagetype types into the page, assert fails the smoke run; tests/smoke/input.txt fails on the old code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
bed183c2db
commit
3f213ccbe1
9 changed files with 139 additions and 20 deletions
|
|
@ -65,7 +65,7 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl
|
|||
| `nice cargo build --release -j 2` | compile check, produces `target/release/nacre` | now |
|
||||
| `nice cargo test --release -j 2` | unit tests (44, ~16 s test-profile build then <1 s run; shares the S001 build) (util, settings, history, bookmarks, permissions, vault, dns, bridge loopback, download, adblock, keys, scripts, updates, inject, hub, theme, ui::widgets input, ui::paint, ui::pages::newtab) | first successful build; not alongside a build |
|
||||
| `src/selftest.rs` | in-app self test: `NACRE_SCRIPT=<file>` runs script commands (listed at its top) | now |
|
||||
| `tools/smoke.sh <script> [outdir]` | smoke run on a hidden Xvfb display with a throwaway home and software GL; outdir (default `target/smoke/<name>-<time>`) gets `nacre.log`, `selftest.log`, `<shot>.png`, `<status>.json`, `home/`; exits non-zero on crash, panic or no `status done`. Scripts in `tests/smoke/` (`launch.txt` offline, `https.txt` needs internet, `restore.txt` with `SMOKE_HOME=<launch outdir>/home`, `chrome.txt` chrome and every flyout dark and light, offline; `colours.txt` colours after welcome and site colour vs internal pages, hidden `SMOKE_SIZE=1280x1100`); header documents env vars and commands. `SMOKE_VISIBLE=1` shows the run on the user's screen (DP-1, real GPU, niri tiles the window so shots are narrower); use it whenever the user is watching (D-009). Read the PNGs | now (S003) |
|
||||
| `tools/smoke.sh <script> [outdir]` | smoke run on a hidden Xvfb display with a throwaway home and software GL; outdir (default `target/smoke/<name>-<time>`) gets `nacre.log`, `selftest.log`, `<shot>.png`, `<status>.json`, `home/`; exits non-zero on crash, panic, no `status done` or a failed `assert <js>`. Scripts in `tests/smoke/` (`launch.txt` offline, `https.txt` needs internet, `restore.txt` with `SMOKE_HOME=<launch outdir>/home`, `chrome.txt` chrome and every flyout dark and light, offline; `colours.txt` colours after welcome and site colour vs internal pages, hidden `SMOKE_SIZE=1280x1100`; `input.txt` real clicks, typing, right click, wheel on a web page, offline); header documents env vars and commands. `SMOKE_VISIBLE=1` shows the run on the user's screen (DP-1, real GPU, niri tiles the window so shots are narrower); use it whenever the user is watching (D-009). Read the PNGs | now (S003) |
|
||||
| `nacre://gallery` + `SMOKE_SIZE=1400x2800 tools/smoke.sh tests/smoke/gallery.txt` | every design token and widget, dark and light (+ new tab and settings shots); read the PNGs | now (S015) |
|
||||
| `SMOKE_SIZE=1400x1200 tools/smoke.sh tests/smoke/newtab.txt` | new tab page dark/light, nothing playing and a video playing, weather failed state, tall/narrow/phone widths (offline); `tests/smoke/newtab-weather.txt` shoots the real weather card (needs internet); read the PNGs | now (S017) |
|
||||
| `SMOKE_SIZE=1400x900 tools/smoke.sh tests/smoke/backgrounds.txt` | every new tab background with the pointer, Customize panel dark/light, image + blur, GIF frames; `perf-*-a/b.json` `frames` (median/max draw ms, `drawn` count) per background at Lots/Fast, hidden tab, still, Motion off. Selftest `pointer x y`, `customize`; `@PAGESDIR@` = path of tests/smoke/pages | now (S018) |
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ Check every row of FEATURES.md "Browser basics" works in the real app, fix what
|
|||
- Source files only where a check fails
|
||||
|
||||
## Steps
|
||||
- [ ] R4-05 CRITICAL first: web content takes no clicks/keys/context menu (DuckDuckGo); fix input forwarding to the WebView; regression smoke clicking a link and typing in a field on a local page
|
||||
- [x] R4-05 CRITICAL first: web content takes no clicks/keys/context menu (DuckDuckGo); fix input forwarding to the WebView; regression smoke clicking a link and typing in a field on a local page
|
||||
- [ ] Write smoke scripts covering: open/close/pin/mute/duplicate/reorder tabs, reopen closed, back/forward/reload/home, address bar URL vs search, find in page, zoom per site, full screen, new window
|
||||
- [ ] Add scripts for context menu, page dialogs (alert/confirm/prompt/select/file via local test pages), pop-ups/target=_blank, session restore across restart, single instance link forwarding
|
||||
- [ ] Run them; for each failure fix the code in place and add a regression unit test where the logic is pure
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ R4-01 [wontfix: user's niri dotfiles do not export a KDE/GNOME scheme; Nacre kee
|
|||
R4-02 [fixed fc0df2a] Duplicate toolbar icons: the shield and the globe (VPN) sat side by side. Where: right toolbar (screenshot 1.png). Fix: the VPN button is gone (also from Settings → toolbar choices); VPN state and switch are in the Protection flyout. Severity: low.
|
||||
R4-03 [open] YouTube still does not load (= R1-12, R1-03). Where: https://www.youtube.com. Severity: high. → S006.
|
||||
R4-04 [open] Address bar has no inline autofill: typing "wikipe" should complete to "wikipedia.org" in the field with the rest selected; Right arrow or Enter accepts it; with no completion Enter goes to what was typed. Today only a dropdown (screenshot 2.png). Where: address bar. Severity: medium.
|
||||
R4-05 [open] CRITICAL: websites do not work. DuckDuckGo loads but nothing can be clicked and there is no right-click menu on pages; input to web content seems broken. Where: any web page. Reproduce: open https://duckduckgo.com, click the search box or a link. Severity: critical. → S006 first.
|
||||
R4-05 [fixed S006] CRITICAL: websites do not work. DuckDuckGo loads but nothing can be clicked and there is no right-click menu on pages; input to web content seems broken. Where: any web page. Reproduce: open https://duckduckgo.com, click the search box or a link. Severity: critical. → S006 first. Fix: `window_input` used `is_pointer_over_egui`, which is true over the page (it sits in egui's central panel), so clicks and wheel never reached the WebView; now only floating layers (flyouts, menus, toasts) count. Selftest `click`/`rclick`/`pagescroll` now go through `window_input`; `tests/smoke/input.txt` fails on the old code.
|
||||
R4-06 [open] Nacre's own right-click (context) menu on pages: nice icons, rounded, coloured (Material You). Where: web pages (and links, images, text, fields). Severity: medium.
|
||||
R4-07 [open] Automated tests for real heavy web use (YouTube, Wikipedia, DuckDuckGo): a smoke run that loads, clicks, scrolls and plays and fails on a broken page. Severity: high. → S006/S007.
|
||||
R4-08 [open] A "Settings updated" popup keeps appearing when entering or switching to a tab; the user does not know what it means. Severity: medium. Source not found: no such string in `src/` or `assets/` (case-insensitive greps for "settings updated", "updated", "saved"), and none in `~/.config` (caelestia, niri). Nacre's own toasts all name a concrete action (`Shared::toast` callers in actions.rs). Leads to check when reproducing: (1) a page's Web Notification, shown by `App::on_notification` (src/app.rs) through `notify-send -a Nacre <title> <body>` or, without notify-send, as a toast "title: body"; the text would then come from a site, and a site on the allow list shows it on every visit; check Settings → Permissions → Notifications and which tab it appears on; (2) another app's desktop notification; (3) a nacre:// page script. Next step: reproduce on a throwaway profile and read `nacre.log` / run `dbus-monitor "interface='org.freedesktop.Notifications'"` while switching tabs. Wanted: shown only for something the user changed, and the text says what changed.
|
||||
|
|
|
|||
|
|
@ -1846,7 +1846,7 @@ impl ApplicationHandler<AppEvent> for App {
|
|||
|
||||
impl App {
|
||||
/// Keyboard and pointer input that isn't a redraw, resize or focus change.
|
||||
fn window_input(&mut self, window_id: WindowId, event: &WindowEvent) {
|
||||
pub(crate) fn window_input(&mut self, window_id: WindowId, event: &WindowEvent) {
|
||||
let keymap_action = if let WindowEvent::KeyboardInput { event: key, .. } = event {
|
||||
let mods = self.windows.get(&window_id).map(|w| w.modifiers).unwrap_or_default();
|
||||
Shortcut::from_event(key, mods).and_then(|s| self.shared.keymap.borrow().action_for(&s))
|
||||
|
|
@ -1856,7 +1856,11 @@ impl App {
|
|||
let Some(win) = self.windows.get_mut(&window_id) else { return };
|
||||
win.last_input = Instant::now();
|
||||
let egui_wants_keys = win.egui.egui_ctx.egui_wants_keyboard_input();
|
||||
let pointer_over_ui = win.egui.egui_ctx.is_pointer_over_egui();
|
||||
// Not `is_pointer_over_egui`: the page sits in egui's central panel, so that is true over the page too.
|
||||
let pointer_over_ui = match event {
|
||||
WindowEvent::CursorMoved { position, .. } => win.over_overlay(*position),
|
||||
_ => win.pointer.is_some_and(|p| win.over_overlay(p)),
|
||||
};
|
||||
let dialog_open = win.tab().is_some_and(|t| t.dialog.is_some()) || win.ui.blocks_page();
|
||||
match event {
|
||||
WindowEvent::ModifiersChanged(mods) => {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,12 @@
|
|||
//! update_lists, check_updates, close_tab, select <n>, zoom <step>,
|
||||
//! find <text>, download <url>, navigate <typed text>, mute, pin
|
||||
//! js <script> run JavaScript in the current tab; the result goes to the log
|
||||
//! click <x> <y> click in the page at CSS-ish pixel x,y (from the page's top left)
|
||||
//! assert <js expression> the expression must give true, else `ASSERT FAILED` in the log fails the smoke run
|
||||
//! click <x> <y> click in the page at CSS-ish pixel x,y (from the page's top left), through the
|
||||
//! window's input path; `rclick` the same with the right button (context menu)
|
||||
//! pagescroll <x> <y> <dy> turn the wheel over the page at x,y (as `click`) by dy pixels (positive: down)
|
||||
//! pagetype <text> type text into the page, if it has keyboard focus (after a `click` in a field);
|
||||
//! `{enter}` in the text presses Enter
|
||||
//! pointer <x> <y> | off move the interface's pointer to x,y in the page area (new tab backgrounds follow it)
|
||||
//! key <name> press and release a key in the interface: enter, escape, tab, space or a letter
|
||||
//! tap <x> <y> click the interface (not the web page) at x,y in the window (logical px, as in a
|
||||
|
|
@ -263,31 +268,92 @@ impl App {
|
|||
};
|
||||
self.run_in(window, command);
|
||||
},
|
||||
"js" => {
|
||||
"js" | "assert" => {
|
||||
let Some(web) = self.windows.get(&window).and_then(|w| w.active_webview()).cloned() else {
|
||||
self.selftest_log("js: no page");
|
||||
self.selftest_log(&format!("{verb}: no page"));
|
||||
if verb == "assert" {
|
||||
self.selftest_log(&format!("ASSERT FAILED (no page): {rest}"));
|
||||
}
|
||||
return;
|
||||
};
|
||||
let log_path = dir.join("selftest.log");
|
||||
let assert = verb == "assert";
|
||||
let script = rest.to_owned();
|
||||
web.evaluate_javascript(rest.to_owned(), move |result| {
|
||||
use std::io::Write as _;
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new().create(true).append(true).open(&log_path) {
|
||||
let _ = writeln!(f, "js -> {result:?}");
|
||||
if !assert {
|
||||
let _ = writeln!(f, "js -> {result:?}");
|
||||
} else if matches!(result, Ok(servo::JSValue::Boolean(true))) {
|
||||
let _ = writeln!(f, "assert ok: {script}");
|
||||
} else {
|
||||
let _ = writeln!(f, "ASSERT FAILED ({result:?}): {script}");
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
"click" => {
|
||||
"pagescroll" => {
|
||||
// Turn the wheel over the page at x,y (page pixels, as `click`) by dy pixels, through `window_input`.
|
||||
let mut parts = rest.split_whitespace().filter_map(|p| p.parse::<f64>().ok());
|
||||
let (x, y, dy) = (parts.next().unwrap_or(0.0), parts.next().unwrap_or(0.0), parts.next().unwrap_or(0.0));
|
||||
let pos = self.windows.get(&window).and_then(|win| {
|
||||
let rect = win.page_rect?;
|
||||
let scale = win.egui.egui_ctx.pixels_per_point() as f64;
|
||||
Some(winit::dpi::PhysicalPosition::new((rect.min.x as f64 + x) * scale, (rect.min.y as f64 + y) * scale))
|
||||
});
|
||||
if let Some(position) = pos {
|
||||
use winit::event::{DeviceId, MouseScrollDelta, TouchPhase, WindowEvent};
|
||||
let device_id = DeviceId::dummy();
|
||||
self.window_input(window, &WindowEvent::CursorMoved { device_id, position });
|
||||
let delta = MouseScrollDelta::PixelDelta(winit::dpi::PhysicalPosition::new(0.0, -dy));
|
||||
self.window_input(window, &WindowEvent::MouseWheel { device_id, delta, phase: TouchPhase::Moved });
|
||||
} else {
|
||||
self.selftest_log("pagescroll: no web page in this tab");
|
||||
}
|
||||
},
|
||||
"click" | "rclick" => {
|
||||
// Through the window's real input path (pointer over UI, dialogs, focus), as a user's click would.
|
||||
let mut parts = rest.split_whitespace().filter_map(|p| p.parse::<f64>().ok());
|
||||
let (x, y) = (parts.next().unwrap_or(0.0), parts.next().unwrap_or(0.0));
|
||||
if let Some(win) = self.windows.get_mut(&window)
|
||||
&& let Some(rect) = win.page_rect
|
||||
{
|
||||
let pos = self.windows.get(&window).and_then(|win| {
|
||||
let rect = win.page_rect?;
|
||||
let scale = win.egui.egui_ctx.pixels_per_point() as f64;
|
||||
let pos = winit::dpi::PhysicalPosition::new((rect.min.x as f64 + x) * scale, (rect.min.y as f64 + y) * scale);
|
||||
win.pointer = Some(pos);
|
||||
win.send_mouse_move(pos);
|
||||
win.send_mouse_button(winit::event::ElementState::Pressed, winit::event::MouseButton::Left);
|
||||
win.send_mouse_button(winit::event::ElementState::Released, winit::event::MouseButton::Left);
|
||||
Some(winit::dpi::PhysicalPosition::new((rect.min.x as f64 + x) * scale, (rect.min.y as f64 + y) * scale))
|
||||
});
|
||||
if let Some(position) = pos {
|
||||
use winit::event::{DeviceId, ElementState, MouseButton, WindowEvent};
|
||||
let button = if verb == "rclick" { MouseButton::Right } else { MouseButton::Left };
|
||||
let device_id = DeviceId::dummy();
|
||||
self.window_input(window, &WindowEvent::CursorMoved { device_id, position });
|
||||
for state in [ElementState::Pressed, ElementState::Released] {
|
||||
self.window_input(window, &WindowEvent::MouseInput { device_id, state, button });
|
||||
}
|
||||
} else {
|
||||
self.selftest_log("click: no web page in this tab");
|
||||
}
|
||||
},
|
||||
"pagetype" => {
|
||||
// Type text into the focused web page, if the page has keyboard focus as `window_input` decides it.
|
||||
if let Some(win) = self.windows.get(&window) {
|
||||
let takes = win.page_focused && !win.egui.egui_ctx.egui_wants_keyboard_input() && !win.tab().is_some_and(|t| t.dialog.is_some());
|
||||
match (takes, win.active_webview()) {
|
||||
(true, Some(web)) => {
|
||||
let mut keys: Vec<(keyboard_types::Key, keyboard_types::Code)> = Vec::new();
|
||||
for (i, part) in rest.split("{enter}").enumerate() {
|
||||
if i > 0 {
|
||||
keys.push((keyboard_types::Key::Named(keyboard_types::NamedKey::Enter), keyboard_types::Code::Enter));
|
||||
}
|
||||
keys.extend(part.chars().map(|c| (keyboard_types::Key::Character(c.to_string()), keyboard_types::Code::Unidentified)));
|
||||
}
|
||||
for (key, code) in keys {
|
||||
for state in [keyboard_types::KeyState::Down, keyboard_types::KeyState::Up] {
|
||||
let ev = keyboard_types::KeyboardEvent { state, key: key.clone(), code, ..Default::default() };
|
||||
web.notify_input_event(servo::InputEvent::Keyboard(servo::KeyboardEvent::new(ev)));
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => self.selftest_log("pagetype: the page doesn't have keyboard focus"),
|
||||
}
|
||||
}
|
||||
},
|
||||
"type" => {
|
||||
|
|
|
|||
|
|
@ -325,6 +325,14 @@ impl BrowserWindow {
|
|||
(x >= 0.0 && y >= 0.0 && x < w && y < h).then(|| servo::DevicePoint::new(x as f32, y as f32))
|
||||
}
|
||||
|
||||
/// A flyout, menu, toast or other floating egui layer is under the pointer (the chrome's panels and the page
|
||||
/// area are background layers and don't count).
|
||||
pub fn over_overlay(&self, pos: PhysicalPosition<f64>) -> bool {
|
||||
let scale = self.egui.egui_ctx.pixels_per_point() as f64;
|
||||
let p = egui::pos2((pos.x / scale) as f32, (pos.y / scale) as f32);
|
||||
self.egui.egui_ctx.layer_id_at(p).is_some_and(|l| l.order != egui::Order::Background)
|
||||
}
|
||||
|
||||
/// Like `page_point` but clamped, for drags that leave the page.
|
||||
pub fn page_point_clamped(&self, pos: PhysicalPosition<f64>) -> Option<servo::DevicePoint> {
|
||||
let rect = self.page_rect?;
|
||||
|
|
|
|||
28
tests/smoke/input.txt
Normal file
28
tests/smoke/input.txt
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Input to web content (R4-05): a real click on a link, typing in a field, a right click, the wheel. Offline.
|
||||
# Clicks go through the window's input path (App::window_input), as a user's would. Run with tools/smoke.sh.
|
||||
# Layout of pages/input.html: link at y 20..50, field at y 70..100, context-menu box at y 120..180 (x 20..320).
|
||||
wait 3
|
||||
open @PAGES@/input.html
|
||||
waitload
|
||||
wait 1
|
||||
click 60 35
|
||||
wait 0.5
|
||||
assert window.clicks === 1 && location.hash === "#clicked"
|
||||
click 60 85
|
||||
wait 0.3
|
||||
pagetype hello
|
||||
wait 0.5
|
||||
assert document.activeElement.id === "field" && document.getElementById("field").value === "hello"
|
||||
rclick 60 150
|
||||
wait 1
|
||||
assert window.menus === 1
|
||||
shot context-menu
|
||||
status menu
|
||||
key Escape
|
||||
wait 0.5
|
||||
pagescroll 200 400 600
|
||||
wait 1
|
||||
assert window.scrollY > 0
|
||||
shot scrolled
|
||||
status done
|
||||
quit
|
||||
8
tests/smoke/pages/input.html
Normal file
8
tests/smoke/pages/input.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>input</title>
|
||||
<style>body { font: 16px sans-serif; margin: 0; padding: 20px } a, input { display: block; margin: 0 0 20px; height: 30px; width: 300px; font-size: 16px }</style>
|
||||
<a id="link" href="#clicked" onclick="window.clicks = (window.clicks || 0) + 1">Click me</a>
|
||||
<input id="field" type="text">
|
||||
<div id="menu" style="width: 300px; height: 60px; background: #ccd" oncontextmenu="window.menus = (window.menus || 0) + 1">Right-click here</div>
|
||||
<div style="height: 3000px"></div>
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
# <name>.png `shot <name>` screenshots; <name>.json `status <name>` files
|
||||
# home/ the throwaway HOME / XDG_* folders (profile, history, session)
|
||||
# Exit 0 only if the browser exited by itself with status 0, no "panicked" is in nacre.log and the script
|
||||
# wrote `status done` (so every script must end with `status done` then `quit`).
|
||||
# wrote `status done` (so every script must end with `status done` then `quit`) and no `assert` failed.
|
||||
#
|
||||
# Environment:
|
||||
# SMOKE_HOME=dir reuse this throwaway home (e.g. a previous run's outdir/home) to test session restore
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
#
|
||||
# Script commands (src/selftest.rs has the full list): wait <s>, waitload [s], open <url>, newtab <url>,
|
||||
# page <nacre://...>, shot <name>, status <name>, set <json pointer> <json>, flyout <name>, do <action>,
|
||||
# cmd <name> [arg], js <script>, click <x> <y>, log <text>, quit. Lines starting with # are notes.
|
||||
# cmd <name> [arg], js <script>, assert <js>, click|rclick <x> <y>, pagetype <text>, log <text>, quit. Lines starting with # are notes.
|
||||
# In the script, @PAGES@ is replaced by the file:// URL of tests/smoke/pages, @PAGESDIR@ by its path.
|
||||
#
|
||||
# Never uses the user's profile, display, Discord socket or session bus; never sets a proxy.
|
||||
|
|
@ -97,6 +97,11 @@ if grep -q panicked "$out/nacre.log"; then
|
|||
grep -m3 -A2 panicked "$out/nacre.log"
|
||||
fail=1
|
||||
fi
|
||||
if grep -q "ASSERT FAILED" "$out/selftest.log" 2>/dev/null; then
|
||||
echo "smoke: failed asserts:"
|
||||
grep "ASSERT FAILED" "$out/selftest.log"
|
||||
fail=1
|
||||
fi
|
||||
if [ ! -f "$out/done.json" ]; then
|
||||
echo "smoke: script did not reach 'status done'"
|
||||
fail=1
|
||||
|
|
|
|||
Loading…
Reference in a new issue