S006: mainstream user agent, heavy-web smoke on real sites

Default UA is Servo's in Firefox's exact form (Gecko/20100101, no Servo token),
following Servo's version (inject::mainstream_ua, tested); a custom UA still wins.
tests/smoke/heavy-web.txt (needs internet): DuckDuckGo, Wikipedia, YouTube in one
go (home, search, video, ads, PiP). Selftest waitfor, locate + click @, expect > n.
input.txt checks Enter submits a form and the keys a page sees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-12 09:06:29 -06:00
commit b623926df3
10 changed files with 195 additions and 16 deletions

View file

@ -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, 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) |
| `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; `basics.txt` tabs, navigation, find, zoom, full screen, pop-ups, offline; `heavy-web.txt` DuckDuckGo, Wikipedia, YouTube, needs internet, `SMOKE_TIMEOUT=900`); 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) |

View file

@ -19,10 +19,10 @@ Check every row of FEATURES.md "Browser basics" works in the real app, fix what
- [ ] Check keyboard shortcuts from `keys.rs` with `do <action>` lines
- [ ] Mark each row in FEATURES.md `verified` or `broken: <why>` (with a PROGRESS 'Later' line for broken ones)
- [x] R1-03/R1-12 YouTube: find why https://www.youtube.com/ fails with `client error (SendRequest)` (start in `src/net/` fetch/bridge path, not page JS), fix, regression test where pure
- [ ] R1-14 user agent: set a mainstream Firefox/Chrome-like UA through Servo prefs, check per-site overrides
- [x] R1-14 user agent: set a mainstream Firefox/Chrome-like UA through Servo prefs, check per-site overrides
- [ ] R1-13 DuckDuckGo dark mode icons: check site `prefers-color-scheme`/`color-scheme` handling vs Nacre chrome icon colours, fix the side that's wrong
- [ ] R1-04/R1-14 site doctor checklist (no Tor/proxies): YouTube, Google sign-in page, captchas, DuckDuckGo, Reddit, GitHub, HTTP caching; fix in place or log as Servo limit; result list in PROGRESS
- [ ] R4-07 heavy-web smoke `tests/smoke/heavy-web.txt` (needs internet, never Tor/proxy, VPN off): YouTube, Wikipedia, DuckDuckGo load, click, scroll, type, play; fails on a broken page; note R4-08 "Settings updated" popup source if seen
- [x] R4-07 heavy-web smoke `tests/smoke/heavy-web.txt` (needs internet, never Tor/proxy, VPN off): YouTube, Wikipedia, DuckDuckGo load, click, scroll, type, play; fails on a broken page; note R4-08 "Settings updated" popup source if seen
- [ ] Mark R1-03, R1-04, R1-12, R1-13, R1-14 fixed/open in `docs/review/phase1.md`, R4-03/05/07 (and R4-08 if found) in `docs/review/phase4.md`
- [ ] All basics scripts green together
- [ ] PROGRESS entry, INDEX line, commit `S006: …` and push

View file

@ -56,6 +56,6 @@ R4-03 [fixed S006] YouTube still does not load (= R1-12, R1-03). Where: https://
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 [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-07 [fixed S006] 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. Done: `tests/smoke/heavy-web.txt` (needs internet; selftest `waitfor`, `locate`/`click @`, `pagetype`, `assert`, `expect`). DuckDuckGo and Wikipedia pass (search, results, scroll, links, WebM playback). YouTube home, search and the watch page load, ads are hidden and counted; playback and PiP fail: Servo 0.7 has no MediaSource ("Your browser can't play this video"), and the result list lays out at zero size.
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.
R4-09 [open] Discord Rich Presence works with the user's test app ID (set in Settings, not hard-coded: `discord.rs` uses `settings.client_id` / `site_ids`), but the site icon never shows in Discord. Lead: `src/discord.rs` sends `assets.large_image` only when `https_short(image)` holds, so data:/non-https/long favicon URLs are dropped silently; check which favicon URL reaches it and fall back to a known https icon (e.g. the site's /favicon.ico or a favicon service) or the app's uploaded asset. Severity: low. (user) → S009.

View file

@ -2438,7 +2438,7 @@ impl App {
if old.web.user_agent != new.web.user_agent
&& let Some(servo) = &self.servo
{
let ua = if new.web.user_agent.trim().is_empty() { servo::UserAgentPlatform::default().to_user_agent_string() } else { new.web.user_agent.trim().to_owned() };
let ua = if new.web.user_agent.trim().is_empty() { crate::inject::mainstream_ua(&servo::UserAgentPlatform::default().to_user_agent_string()) } else { new.web.user_agent.trim().to_owned() };
servo.set_preference("user_agent", servo::PrefValue::Str(ua.clone()));
*self.shared.user_agent.borrow_mut() = ua.clone();
crate::net::fetch::set_user_agent(&ua);

View file

@ -353,9 +353,7 @@ impl App {
prefs.network_https_proxy_uri = proxy;
prefs.network_http_no_proxy = String::new();
}
if !settings.web.user_agent.trim().is_empty() {
prefs.user_agent = settings.web.user_agent.trim().to_owned();
}
prefs.user_agent = if settings.web.user_agent.trim().is_empty() { crate::inject::mainstream_ua(&prefs.user_agent) } else { settings.web.user_agent.trim().to_owned() };
*self.shared.user_agent.borrow_mut() = prefs.user_agent.clone();
crate::net::fetch::set_user_agent(&prefs.user_agent);
prefs.dom_webxr_enabled = false;

View file

@ -528,6 +528,14 @@ const GOOGLE_SIGNIN_JS: &str = r#"(() => { if (!/(^|\.)accounts\.google\.com$/.t
/// The Firefox user agent used on Google's sign-in pages.
pub const FIREFOX_UA: &str = "Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0";
/// The default user agent: Servo's own, in Firefox's exact form ("... rv:N) Gecko/20100101 Firefox/N"), so sites
/// that sniff for a known browser serve their Firefox pages; the Firefox version follows Servo's default.
pub fn mainstream_ua(servo_default: &str) -> String {
let without_servo: Vec<&str> = servo_default.split(' ').filter(|part| !part.starts_with("Servo/")).collect();
let ua = without_servo.join(" ");
if ua.contains("Gecko/") { ua } else { ua.replacen(" Firefox/", " Gecko/20100101 Firefox/", 1) }
}
/// Small helpers for browser -> page calls.
pub fn call(path: &str, args: &[Value]) -> String {
let args: Vec<String> = args.iter().map(Value::to_string).collect();
@ -550,6 +558,13 @@ pub fn redirect_page(to: &str, note: &str) -> Vec<u8> {
mod tests {
use super::*;
#[test]
fn mainstream_user_agent() {
let ua = mainstream_ua("Mozilla/5.0 (X11; Linux x86_64; rv:153.0) Servo/0.7.0 Firefox/153.0");
assert_eq!(ua, "Mozilla/5.0 (X11; Linux x86_64; rv:153.0) Gecko/20100101 Firefox/153.0");
assert_eq!(mainstream_ua(&ua), ua);
}
#[test]
fn messages() {
let m = parse_message("abc", r#"abc{"t":"media","d":{"title":"x"}}"#).unwrap();

View file

@ -3,6 +3,7 @@
//!
//! wait <seconds> let the browser run
//! waitload [seconds] wait until the current tab finished loading (default limit 30 s)
//! waitfor <s> <js expr> poll the expression until it gives true, at most s seconds (timeout fails the run)
//! open <url> load in the current tab newtab <url> open in a new tab
//! page <nacre://...> show an internal page
//! shot <name> [pip] save the window (or the picture-in-picture window) as <name>.png
@ -22,10 +23,10 @@
//! js <script> run JavaScript in the current tab; the result goes to the log
//! assert <js expression> the expression must give true, else `ASSERT FAILED` in the log fails the smoke run
//! expect <pointer> <json> a value of the `status` JSON must equal json (e.g. `expect /tabs/1/pinned true`;
//! `/active/...` is the active tab, `/tab_count` the number of tabs)
//! `/active/...` is the active tab, `/tab_count` the number of tabs; `> n` a number above n)
//! 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)
//! locate <css selector> find an element, scroll it into view; `click @` / `rclick @` then click its centre
//! locate <css selector> find the first visible matching element, scroll it into view; `click @` / `rclick @` then click its centre
//! 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}` / `{escape}` in the text press Enter / Escape
@ -67,6 +68,10 @@ pub struct SelfTest {
held: Option<egui::Pos2>,
/// The centre of the element the last `locate` found (page pixels), for `click @`.
located: std::sync::Arc<std::sync::Mutex<Option<(f64, f64)>>>,
/// `waitfor`: the expression and when to give up.
wait_js: Option<(String, Instant)>,
/// (an evaluation is in flight, the last one gave true)
js_poll: std::sync::Arc<std::sync::Mutex<(bool, bool)>>,
}
impl SelfTest {
@ -75,7 +80,7 @@ impl SelfTest {
let text = std::fs::read_to_string(&path).ok()?;
let dir = path.parent().map(|p| p.to_owned()).unwrap_or_else(|| PathBuf::from("."));
let lines = text.lines().map(|l| l.trim().to_owned()).filter(|l| !l.is_empty() && !l.starts_with('#')).collect();
Some(SelfTest { lines, next: 0, wait_until: None, wait_load_until: None, dir, pending_shot: false, pending_release: None, held: None, located: Default::default() })
Some(SelfTest { lines, next: 0, wait_until: None, wait_load_until: None, dir, pending_shot: false, pending_release: None, held: None, located: Default::default(), wait_js: None, js_poll: Default::default() })
}
fn log(&self, text: &str) {
@ -130,6 +135,30 @@ impl App {
}
continue;
}
if let Some((expr, until)) = test.wait_js.clone() {
let (in_flight, done) = test.js_poll.lock().map(|p| *p).unwrap_or((false, false));
if done || Instant::now() >= until {
test.log(&if done { format!("waitfor ok: {expr}") } else { format!("ASSERT FAILED (waitfor timed out): {expr}") });
test.wait_js = None;
if let Ok(mut p) = test.js_poll.lock() {
*p = (false, false);
}
continue;
}
test.wait_until = Some(Instant::now() + Duration::from_millis(250));
let poll = test.js_poll.clone();
if !in_flight && let Some(web) = self.windows.get(&window).and_then(|w| w.active_webview()) {
if let Ok(mut p) = poll.lock() {
p.0 = true;
}
web.evaluate_javascript(expr, move |result| {
if let Ok(mut p) = poll.lock() {
*p = (false, matches!(result, Ok(servo::JSValue::Boolean(true))));
}
});
}
return;
}
if test.next >= test.lines.len() {
return;
}
@ -161,6 +190,14 @@ impl App {
t.wait_load_until = Some(Instant::now() + Duration::from_secs_f64(secs));
}
},
"waitfor" => {
// `waitfor <seconds> <js expression>`: poll until the expression gives true; a timeout fails the run.
let (secs, expr) = rest.split_once(char::is_whitespace).unwrap_or(("30", rest));
let secs: f64 = secs.parse().unwrap_or(30.0);
if let Some(t) = self.selftest.as_mut() {
t.wait_js = Some((expr.trim().to_owned(), Instant::now() + Duration::from_secs_f64(secs)));
}
},
"open" => self.navigate(window, rest.to_owned()),
"newtab" => self.open(window, rest.to_owned(), Disposition::NewForegroundTab, None),
"page" => {
@ -204,7 +241,13 @@ impl App {
None => pointer.to_owned(),
};
let got = status.pointer(&pointer).cloned().unwrap_or(serde_json::Value::Null);
if got == want {
// `expect <pointer> > n`: a number above n.
let above = rest.split_once(char::is_whitespace).and_then(|(_, w)| w.trim().strip_prefix('>')).and_then(|n| n.trim().parse::<f64>().ok());
let ok = match above {
Some(n) => got.as_f64().is_some_and(|g| g > n),
None => got == want,
};
if ok {
self.selftest_log(&format!("expect ok: {pointer} = {got}"));
} else {
self.selftest_log(&format!("ASSERT FAILED: {pointer} is {got}, expected {want}"));
@ -334,7 +377,7 @@ impl App {
}
},
"locate" => {
// Find the first element matching a CSS selector and scroll it into view, for `click @`.
// Find the first visible element matching a CSS selector and scroll it into view, for `click @`.
let Some(web) = self.windows.get(&window).and_then(|w| w.active_webview()).cloned() else { return };
let Some(located) = self.selftest.as_ref().map(|t| t.located.clone()) else { return };
if let Ok(mut l) = located.lock() {
@ -342,7 +385,7 @@ impl App {
}
let log_path = dir.join("selftest.log");
let selector = serde_json::to_string(rest).unwrap_or_default();
let script = format!("(() => {{ const e = document.querySelector({selector}); if (!e) return null; e.scrollIntoView({{block: 'center'}}); const r = e.getBoundingClientRect(); return [r.left + r.width / 2, r.top + r.height / 2]; }})()");
let script = format!("(() => {{ const e = [...document.querySelectorAll({selector})].find(e => {{ const r = e.getBoundingClientRect(); return r.width > 0 && r.height > 0; }}); if (!e) return null; e.scrollIntoView({{block: 'center'}}); const r = e.getBoundingClientRect(); return [r.left + r.width / 2, r.top + r.height / 2]; }})()");
web.evaluate_javascript(script, move |result| {
use std::io::Write as _;
let point = match &result {

111
tests/smoke/heavy-web.txt Normal file
View file

@ -0,0 +1,111 @@
# Heavy real-site use (R4-07): DuckDuckGo, Wikipedia, YouTube load, take clicks, typing and the wheel, and play
# video (Wikipedia's <video>; YouTube can't play in Servo 0.7: no MediaSource).
# NEEDS INTERNET. Direct connections only: never a VPN, Tor or proxy (keep Nacre's VPN off; the profile is new).
# Run with SMOKE_TIMEOUT=600 tools/smoke.sh tests/smoke/heavy-web.txt; any failed check fails the run.
# Sites change their markup: when a selector stops matching, `waitfor` times out or the log says `locate -> None`.
# Servo fires `input` events after a burst of keys, so Enter is typed as its own step (as a person types).
# DuckDuckGo may answer "Oops… server error" after many runs in a row (its rate limit): wait and run again.
wait 3
# DuckDuckGo: type a search, get results, scroll, open one.
open https://duckduckgo.com/
waitfor 60 !!document.querySelector("textarea[name=q], input[name=q]")
wait 1
shot ddg-home
locate textarea[name=q], input[name=q]
wait 1
click @
wait 0.5
pagetype servo browser engine
wait 1
pagetype {enter}
waitfor 60 location.search.includes("q=servo") && document.querySelectorAll("a[data-testid=result-title-a]").length > 0
wait 2
shot ddg-results
pagescroll 400 300 800
waitfor 10 window.scrollY > 0
locate a[data-testid=result-title-a]
wait 1
click @
waitfor 60 location.hostname !== "duckduckgo.com" && document.readyState !== "loading"
wait 2
shot ddg-result-opened
# Wikipedia: an article, scroll, follow a link, search, play the article's video file.
open https://en.wikipedia.org/wiki/Web_browser
waitfor 60 document.title.includes("Web browser") && document.readyState === "complete"
wait 1
pagescroll 400 300 1200
waitfor 10 window.scrollY > 0
shot wiki-article
locate #mw-content-text p a[title]
wait 1
click @
waitfor 60 location.pathname !== "/wiki/Web_browser" && location.pathname.startsWith("/wiki/") && document.readyState !== "loading"
open https://en.wikipedia.org/wiki/Special:Search
waitfor 60 !!document.querySelector("#searchText input")
wait 1
locate #searchText input
wait 1
click @
wait 0.5
pagetype Servo (software)
wait 2
# Enter in this widget doesn't submit with the selftest's keys (a plain form does, see input.txt); click Search.
locate #searchText ~ * button[type=submit], #mw-search-top-table button[type=submit], button[type=submit]
wait 1
click @
waitfor 60 document.title.includes("Servo")
wait 1
shot wiki-search
# The article's video file (VP8 WebM, ranged requests) plays; the article's own <video> is a placeholder its
# player script fills on click.
open https://upload.wikimedia.org/wikipedia/commons/c/c1/Web_browser_demo.webm
waitfor 60 !!document.querySelector("video")
js (() => { const v = document.querySelector("video"); v.muted = true; v.play(); return "play"; })()
waitfor 90 document.querySelector("video").currentTime > 0.5
shot wiki-video
# YouTube in one go (S006/S007/S009): home, search, a video from the results, playback, ad blocking, picture in
# picture (D-008: PiP reloads the page in its own web view and seeks). Shots and status for each step.
# Playback needs MediaSource, which Servo 0.7 lacks: the time check fails until that changes (logged below).
open https://www.youtube.com/
waitfor 120 [...document.querySelectorAll("input[name=search_query]")].some(e => e.getBoundingClientRect().width > 0)
wait 3
shot yt-home
status yt-home
locate input[name=search_query]
wait 1
click @
wait 0.5
pagetype servo browser
wait 1
pagetype {enter}
waitfor 120 location.pathname === "/results" && !!document.querySelector("ytd-video-renderer")
wait 2
shot yt-results
# Servo 0.7 lays YouTube's result list out at zero size (it is in the DOM), so the video is opened by address.
open https://www.youtube.com/watch?v=jNQXAC9IVRw
waitfor 120 location.pathname === "/watch" && !!document.querySelector("video")
wait 5
js JSON.stringify({ MediaSource: typeof MediaSource, ManagedMediaSource: typeof ManagedMediaSource, src: document.querySelector("video").currentSrc.slice(0, 60), error: document.querySelector("#movie_player .ytp-error") ? document.querySelector("#movie_player .ytp-error").innerText.slice(0, 80) : null })
js (() => { const v = document.querySelector("video"); v.muted = true; v.play(); return "play"; })()
waitfor 60 document.querySelector("video").currentTime > 1
shot yt-video
status yt-video
# Ad blocking: no ad slots on the page, and the shield counts blocked requests.
assert ![...document.querySelectorAll("ytd-ad-slot-renderer, ytd-in-feed-ad-layout-renderer, ytd-player-legacy-desktop-watch-ads-renderer, .ytp-ad-player-overlay, .ytp-ad-text")].some(e => e.getBoundingClientRect().height > 0)
expect /active/blocked > 0
flyout shield
wait 1
shot yt-shield
flyout none
# Picture in picture (needs a video with a source: fails with YouTube until playback works).
cmd pip
wait 8
expect /active/pip true
shot yt-pip pip
status yt-pip
cmd exitpip
wait 3
expect /active/pip false
shot yt-pip-back
status done
quit

View file

@ -1,6 +1,7 @@
# 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).
# 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),
# form field y 200..230, textarea y 250..280.
wait 3
open @PAGES@/input.html
waitload
@ -13,6 +14,15 @@ wait 0.3
pagetype hello
wait 0.5
assert document.activeElement.id === "field" && document.getElementById("field").value === "hello"
click 60 215
pagetype abc{enter}
wait 1
assert window.submits === 1
click 60 265
pagetype x{enter}
wait 0.5
js JSON.stringify(window.keys)
assert JSON.stringify(window.keys) === '["x:88:Unidentified","Enter:13:Enter"]' || window.keys[1].startsWith("Enter:13")
rclick 60 150
wait 1
assert window.menus === 1

View file

@ -1,8 +1,10 @@
<!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>
<style>body { font: 16px sans-serif; margin: 0; padding: 20px } a, input, textarea { 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>
<form id="form" action="#submitted" onsubmit="window.submits = (window.submits || 0) + 1"><input id="query" name="q" type="text"></form>
<textarea id="area" onkeydown="window.keys = (window.keys || []).concat([event.key + ':' + event.keyCode + ':' + event.code])"></textarea>
<div style="height: 3000px"></div>