Web version: «Allow reading» checked, a kept copy lets the handle go, dropped files told apart in Chrome; docs: §9, the checks in Chromium

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-30 17:58:01 +03:00
parent f694bc768b
commit bda92c5675
8 changed files with 117 additions and 14 deletions

View file

@ -22,6 +22,10 @@ const check = (ok, what) => {
const DOWNLOAD = [Number(process.env.DOWNLOAD_X || 1263), Number(process.env.DOWNLOAD_Y || 24)];
const E2 = [519, 703];
const E4 = [519, 505];
// The card of «Test games» on the shelf after a reload (the draft's strip above it) and
// «Allow reading» on its pane.
const TEST_CARD = [300, 88];
const ALLOW = [70, 232];
const s = await session(appDir, 18766);
const { t } = s;
@ -131,6 +135,20 @@ try {
if (await t.evaluate(`typeof window.showOpenFilePicker === 'function'`)) {
// Chrome, Edge: the file chosen before the reload is read again by itself.
check(s.logs.some((l) => /remembered file read again: .*Test games\.pgn/.test(l)), 'the chosen file is remembered (File System Access)');
// When the browser asks first (its permission not kept): the card offers «Allow
// reading», the browser's question is answered «Allow», the file is read.
await t.beforeLoad(`FileSystemHandle.prototype.queryPermission = async () => 'prompt';
FileSystemHandle.prototype.requestPermission = async () => 'granted';`);
await t.navigate(`${s.base}?lang=en`);
await started();
await sleep(2500);
await t.click(...TEST_CARD);
await sleep(1500);
await shot('web-10-allow.png');
await t.click(...ALLOW);
await sleep(2500);
await shot('web-11-allowed.png');
check(s.logs.some((l) => /remembered file allowed again: .*Test games\.pgn/.test(l)), '«Allow reading» reads the remembered file again');
}
} finally {
await s.stop();

View file

@ -7,6 +7,7 @@
// t.navigate(url) · t.evaluate(js) · t.waitFor(js, ms) · t.screenshot()
// t.click(x, y, {double, right}) · t.key(key, mods, times) · t.setFiles(inputId, paths)
// t.choose(paths, open): the user chooses the files in the dialog open() brings up
// t.beforeLoad(js): js runs in every page loaded later, before its scripts
import { spawn } from 'node:child_process';
import { mkdirSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
@ -67,6 +68,8 @@ async function firefox(port) {
waitFor: waitFor(evaluate),
navigate: t.navigate,
screenshot: t.screenshot,
// `js` runs in every page loaded from now on, before the page's own scripts.
beforeLoad: (js) => ff.browser.send('script.addPreloadScript', { functionDeclaration: `() => { ${js} }`, contexts: [t.context] }),
click: async (x, y, { double = false, right = false } = {}) => {
const acts = [{ type: 'pointerMove', x, y }];
for (let i = 0; i < (double ? 2 : 1); i++) {
@ -181,6 +184,7 @@ async function chromium(port) {
send: s,
evaluate,
waitFor: waitFor(evaluate),
beforeLoad: (js) => s('Page.addScriptToEvaluateOnNewDocument', { source: js }),
navigate: async (url) => {
await s('Page.navigate', { url });
await waitFor(evaluate)(`document.readyState === 'complete'`, 30000);