gui tests: a page's page-away beacon is left out of the writes they count, as update/using is (#6709)

80a315a70 (11-14) sends POST /api/page-away when the page is hidden.
WebKit's page fires visibilitychange hidden in agent-bulk-visibility,
so its write count read 6 for 5, red in every language in WebKit
alone since then (git bisect run from e430e2750, red alone every
time in 2.7s). The seven files that leave the window's update/using
ping out of their counts now leave page-away out too; it writes
nothing either.

Run (rebased on 47ce008da, mote): agent-bulk-visibility,
agent-disconnect-preview, library-bar-more, provider-find,
sessions-folder-delete, settings-search, signin-close: pass 74 fail 0.
Without the change: pass 69 fail 5 (the five WebKit subtests of
agent-bulk-visibility).

Not done: a shared helper for "the page's writes", which would carry
the next such ping to every counting test at once; each file still
has its own route.
This commit is contained in:
yetone
2026-11-16 00:12:45 +08:00
parent 47ce008da8
commit 38e60d7449
7 changed files with 12 additions and 12 deletions
@@ -29,8 +29,8 @@ for (const engine of process.env.BROWSER ? [process.env.BROWSER] : ['chromium',
await page.route('**/*', async (route) => {
const req = route.request(), url = new URL(req.url());
const json = (data) => route.fulfill({ json: data });
// the window saying it is in use (update/using) is not the page's doing
if (req.method() === 'POST' && url.pathname !== '/api/update/using') posts.push([url.pathname, req.postDataJSON()]);
// the window saying it is in use (update/using), or that it went from view (page-away), is not the page's doing
if (req.method() === 'POST' && url.pathname !== '/api/update/using' && url.pathname !== '/api/page-away') posts.push([url.pathname, req.postDataJSON()]);
if (url.pathname === '/boot.js') return route.fulfill({ contentType: 'text/javascript', body: `window.bootPrefs = ${JSON.stringify({lang, theme, web:true})};` });
if (url.pathname === '/wails/runtime.js') return route.fulfill({ contentType: 'text/javascript', body: 'export const Window = {};' });
if (url.pathname === '/api/state') return json(state);
@@ -35,8 +35,8 @@ function serve(lang, textSize, posts) {
return async (route) => {
const req = route.request(), url = new URL(req.url());
const json = (data) => route.fulfill({ json: data });
// the window saying it is in use (update/using) is not the page's doing
if (req.method() === "POST" && url.pathname !== "/api/update/using") posts.push(url.pathname);
// the window saying it is in use (update/using), or that it went from view (page-away), is not the page's doing
if (req.method() === "POST" && url.pathname !== "/api/update/using" && url.pathname !== "/api/page-away") posts.push(url.pathname);
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang, theme: "light", textSize, web: false })};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json(state);
+2 -2
View File
@@ -24,8 +24,8 @@ function server(lang, state, posts) {
const req = route.request();
const url = new URL(req.url());
const json = (data) => route.fulfill({ json: data });
// the window saying it is in use (update/using) is not the page's doing (#5982)
if (req.method() === "POST" && url.pathname !== "/api/update/using") posts.push(url.pathname);
// the window saying it is in use (update/using), or that it went from view (page-away), is not the page's doing (#5982)
if (req.method() === "POST" && url.pathname !== "/api/update/using" && url.pathname !== "/api/page-away") posts.push(url.pathname);
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" } });
+2 -2
View File
@@ -63,8 +63,8 @@ function fixture(lang) {
providers.providers = order.map((id) => providers.providers.find((p) => p.id === id));
return json(providers);
}
// the window saying it is in use (update/using) is not the page's doing
if (request.method() !== "GET" && url.pathname !== "/api/update/using") posted.push(url.pathname);
// the window saying it is in use (update/using), or that it went from view (page-away), is not the page's doing
if (request.method() !== "GET" && url.pathname !== "/api/update/using" && url.pathname !== "/api/page-away") posted.push(url.pathname);
if (url.pathname === "/api/providers") return json(providers);
if (url.pathname === "/api/groups") return json({ groups: [] });
if (url.pathname === "/api/plugins") return json({ plugins: [] });
@@ -73,8 +73,8 @@ function serve(lang, calls) {
return json(out);
}
if (url.pathname.startsWith("/api/")) {
// the window's in-use ping (update/using) is no part of a delete
if (req.method() === "POST" && url.pathname !== "/api/update/using") calls.push({ path: url.pathname });
// the window's in-use ping (update/using) and its page-away are no part of a delete
if (req.method() === "POST" && url.pathname !== "/api/update/using" && url.pathname !== "/api/page-away") calls.push({ path: url.pathname });
return json({});
}
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
+1 -1
View File
@@ -37,7 +37,7 @@ function server(lang, posts, web, { provs = ["codex", "claude"], off = [], built
const req = route.request(), url = new URL(req.url());
const json = (data) => route.fulfill({ json: data });
// the window's in-use signal (any key or click, 10c4dc109) writes no setting (#6133)
if (req.method() !== "GET" && url.pathname !== "/api/update/using") posts.push(url.pathname);
if (req.method() !== "GET" && url.pathname !== "/api/update/using" && url.pathname !== "/api/page-away") posts.push(url.pathname);
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:${web},textSize:100,featuresOff:${JSON.stringify(off)}};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light", textSize: 100 }, fx: cur.fx });
+1 -1
View File
@@ -167,7 +167,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const missing = await page.evaluate(() => ["Stop waiting for this sign-in"].filter((k) => !I18N.zh[k]));
assert.deepEqual(missing, []);
// a Windows window tints its title bar to the page (6927bedfc), which changes nothing; so does the "in use" ping a click sends (10c4dc109)
assert.deepEqual(ctl.other.filter((o) => o.startsWith("POST") && !o.includes("/api/open") && !o.includes("/api/window/titlebar") && !o.includes("/api/update/using")), [], "nothing else was changed");
assert.deepEqual(ctl.other.filter((o) => o.startsWith("POST") && !o.includes("/api/open") && !o.includes("/api/window/titlebar") && !o.includes("/api/update/using") && !o.includes("/api/page-away")), [], "nothing else was changed");
assert.deepEqual(errors, []);
});
}