2026-10-30 17:31:27 +03:00
|
|
|
|
// The web version in a headless browser (Firefox; Chromium with CP_BROWSER=chromium):
|
|
|
|
|
|
// the page for phones, the program, opening a PGN by its button (Ctrl+O) and by
|
|
|
|
|
|
// dropping it, a game from the classics, moves, a download of the PGN, a move on the
|
|
|
|
|
|
// board, the browser's Back. Screenshots go to <out-dir>; what is checked is printed.
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
//
|
|
|
|
|
|
// node apps/web/check/app.mjs <app-dir> <out-dir> (app-dir: apps/web/build.sh's)
|
|
|
|
|
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
|
|
|
import { join, resolve } from 'node:path';
|
|
|
|
|
|
import { fileURLToPath } from 'node:url';
|
2026-10-30 17:31:27 +03:00
|
|
|
|
import { session } from './steps.mjs';
|
|
|
|
|
|
import { sleep } from './bidi.mjs';
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
|
|
|
|
|
|
const [appDir, outDir] = process.argv.slice(2).map((p) => resolve(p));
|
|
|
|
|
|
const root = fileURLToPath(new URL('../../..', import.meta.url));
|
|
|
|
|
|
mkdirSync(outDir, { recursive: true });
|
|
|
|
|
|
let failures = 0;
|
|
|
|
|
|
const check = (ok, what) => {
|
|
|
|
|
|
console.log(`${ok ? 'ok ' : 'FAIL'} ${what}`);
|
|
|
|
|
|
if (!ok) failures++;
|
|
|
|
|
|
};
|
2026-10-30 17:31:27 +03:00
|
|
|
|
// Places of buttons in a 1400×860 window.
|
|
|
|
|
|
const DOWNLOAD = [Number(process.env.DOWNLOAD_X || 1263), Number(process.env.DOWNLOAD_Y || 24)];
|
|
|
|
|
|
const E2 = [519, 703];
|
|
|
|
|
|
const E4 = [519, 505];
|
2026-10-30 17:58:01 +03:00
|
|
|
|
// 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];
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
|
2026-10-30 17:31:27 +03:00
|
|
|
|
const s = await session(appDir, 18766);
|
|
|
|
|
|
const { t } = s;
|
|
|
|
|
|
const shot = async (name) => writeFileSync(join(outDir, name), await t.screenshot());
|
|
|
|
|
|
const text = () => t.evaluate(`document.getElementById('cp-device').innerText`);
|
|
|
|
|
|
const started = () => t.waitFor(`document.getElementById('cp-status').hidden && !document.getElementById('cp-app').hidden`, 30000);
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
try {
|
2026-10-30 17:31:27 +03:00
|
|
|
|
// ----- the page for phones and tablets, without the program ----------------------------
|
|
|
|
|
|
await t.navigate(`${s.base}?phone=1&lang=ru`);
|
|
|
|
|
|
await sleep(800);
|
|
|
|
|
|
check(/ChessPenguin на телефоне и планшете/.test(await text()), 'the device page in Russian');
|
|
|
|
|
|
check(/Всё равно открыть веб-версию/.test(await text()), 'with «open the web version anyway»');
|
|
|
|
|
|
const wasm = await t.evaluate(`performance.getEntriesByType('resource').some(e => e.name.endsWith('.wasm'))`);
|
|
|
|
|
|
check(!wasm, 'the program is not downloaded on it');
|
|
|
|
|
|
await shot('web-phone-ru.png');
|
|
|
|
|
|
await t.navigate(`${s.base}?phone=1&lang=de`);
|
|
|
|
|
|
await sleep(500);
|
|
|
|
|
|
check(/auf Handy und Tablet/.test(await text()), 'the device page in German');
|
|
|
|
|
|
await t.navigate(`${s.base}?phone=android&lang=ru`);
|
|
|
|
|
|
await sleep(800);
|
|
|
|
|
|
check(/Скачать для Android/.test(await text()), 'the Android variant');
|
|
|
|
|
|
await t.navigate(`${s.base}?phone=ios&lang=en`);
|
|
|
|
|
|
await sleep(800);
|
|
|
|
|
|
check(/iPhone and iPad app is coming soon/.test(await text()), 'the iPhone and iPad variant');
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
|
|
|
|
|
|
// ----- the program -------------------------------------------------------------------------
|
2026-10-30 17:31:27 +03:00
|
|
|
|
await t.navigate(`${s.base}?lang=en`);
|
|
|
|
|
|
await started();
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
await sleep(2500);
|
2026-10-30 17:31:27 +03:00
|
|
|
|
check(true, `the program started in ${s.b.name}`);
|
|
|
|
|
|
await shot('web-1-library.png');
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
|
|
|
|
|
|
// Open a PGN by the button's shortcut: the browser's file chooser gets the file.
|
2026-10-30 17:31:27 +03:00
|
|
|
|
const pgn = join(s.b.profile, 'Test games.pgn');
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
copyFileSync(join(root, 'examples/alekhine.pgn'), pgn);
|
Web version: databases read in a worker, the shelf's counts, Chrome and Edge remember chosen files
The page's reader: a Web Worker with a second instance of the program reads
a database (PGN, CBV, ZIP, 7Z) and gives back its text and index; the page
puts it together without reading it again (chess_core::PgnIndex,
PgnDatabase::into_index / from_index, serde behind a feature). A 13 MB CBV:
the longest frame 17 ms in Firefox, 67 ms in Chromium (1000 ms before).
platform::open_database is the same on both sides: away from the screen,
done when read. The shelf's cards count the games the same way (one file
at a time); the counts are kept through platform::fs.
Chrome, Edge (File System Access): a chosen file's handle is kept in the
browser's storage; at the next visit the file is read again by itself when
the browser allows it, else the card offers «Allow reading» (the browser's
own question). Files of different visits get folders of their own.
Checks: t.choose(files, open) for both browsers (in Chromium the handles of
the site's private file system stand for the dialog's); app.mjs checks the
draft, the question on leaving and the remembered file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:50:54 +03:00
|
|
|
|
await t.choose([pgn], () => t.key('o', ['ctrl']));
|
2026-10-30 17:31:27 +03:00
|
|
|
|
await sleep(3000);
|
|
|
|
|
|
await shot('web-2-opened.png');
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
|
|
|
|
|
|
// Drop a file on the window.
|
|
|
|
|
|
const dropped = readFileSync(join(root, 'examples/classics.pgn'), 'utf8');
|
|
|
|
|
|
await t.evaluate(`(() => {
|
|
|
|
|
|
const dt = new DataTransfer();
|
|
|
|
|
|
dt.items.add(new File([${JSON.stringify(dropped)}], 'Dropped classics.pgn', { type: 'application/x-chess-pgn' }));
|
|
|
|
|
|
const c = document.getElementById('cp-canvas');
|
|
|
|
|
|
for (const type of ['dragenter', 'dragover', 'drop'])
|
|
|
|
|
|
c.dispatchEvent(new DragEvent(type, { dataTransfer: dt, bubbles: true, cancelable: true, clientX: 700, clientY: 400 }));
|
|
|
|
|
|
return true;
|
|
|
|
|
|
})()`);
|
2026-10-30 17:31:27 +03:00
|
|
|
|
await sleep(3000);
|
|
|
|
|
|
await shot('web-3-dropped.png');
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
|
2026-10-30 17:31:27 +03:00
|
|
|
|
// A game from the table (double click), its moves on the board.
|
|
|
|
|
|
await t.click(300, 322, { double: true });
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
await sleep(1500);
|
2026-10-30 17:31:27 +03:00
|
|
|
|
await shot('web-4-game.png');
|
|
|
|
|
|
await t.key('right', [], 12);
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
await sleep(800);
|
2026-10-30 17:31:27 +03:00
|
|
|
|
await shot('web-5-moves.png');
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
|
|
|
|
|
|
// Download the PGN of the game (the header's button).
|
2026-10-30 17:31:27 +03:00
|
|
|
|
await t.click(...DOWNLOAD);
|
|
|
|
|
|
await sleep(2500);
|
|
|
|
|
|
const files = existsSync(s.b.downloads) ? readdirSync(s.b.downloads).filter((f) => f.endsWith('.pgn')) : [];
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
check(files.length === 1, `a PGN downloaded: ${files.join(', ') || 'none'}`);
|
|
|
|
|
|
if (files.length) {
|
2026-10-30 17:31:27 +03:00
|
|
|
|
const body = readFileSync(join(s.b.downloads, files[0]), 'utf8');
|
|
|
|
|
|
check(/\[White "/.test(body) && /1\. /.test(body), 'the download is the game in PGN');
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-30 17:31:27 +03:00
|
|
|
|
// The browser's Back is «← Library».
|
|
|
|
|
|
await t.evaluate(`history.back()`);
|
|
|
|
|
|
await sleep(1500);
|
|
|
|
|
|
await shot('web-6-back.png');
|
|
|
|
|
|
check(await t.evaluate(`history.state === null || !history.state.cpGame`), 'Back left the game for the library');
|
|
|
|
|
|
|
|
|
|
|
|
// A move on the board of a new game (Ctrl+N; N in a browser): e2–e4 by two clicks.
|
|
|
|
|
|
await t.key('n');
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
await sleep(1200);
|
2026-10-30 17:31:27 +03:00
|
|
|
|
await t.click(...E2);
|
|
|
|
|
|
await sleep(300);
|
|
|
|
|
|
await t.click(...E4);
|
|
|
|
|
|
await sleep(1000);
|
|
|
|
|
|
await shot('web-8-e4.png');
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
|
Web version: databases read in a worker, the shelf's counts, Chrome and Edge remember chosen files
The page's reader: a Web Worker with a second instance of the program reads
a database (PGN, CBV, ZIP, 7Z) and gives back its text and index; the page
puts it together without reading it again (chess_core::PgnIndex,
PgnDatabase::into_index / from_index, serde behind a feature). A 13 MB CBV:
the longest frame 17 ms in Firefox, 67 ms in Chromium (1000 ms before).
platform::open_database is the same on both sides: away from the screen,
done when read. The shelf's cards count the games the same way (one file
at a time); the counts are kept through platform::fs.
Chrome, Edge (File System Access): a chosen file's handle is kept in the
browser's storage; at the next visit the file is read again by itself when
the browser allows it, else the card offers «Allow reading» (the browser's
own question). Files of different visits get folders of their own.
Checks: t.choose(files, open) for both browsers (in Chromium the handles of
the site's private file system stand for the dialog's); app.mjs checks the
draft, the question on leaving and the remembered file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:50:54 +03:00
|
|
|
|
// An unsaved game: the browser asks before the page is left, and its draft is kept.
|
|
|
|
|
|
check(await t.evaluate(`typeof window.onbeforeunload === 'function'`), 'unsaved: the browser asks before leaving');
|
|
|
|
|
|
await sleep(1500);
|
|
|
|
|
|
const draft = () => t.evaluate(`new Promise((ok) => {
|
|
|
|
|
|
const q = indexedDB.open('chesspenguin');
|
|
|
|
|
|
q.onsuccess = () => {
|
|
|
|
|
|
const r = q.result.transaction('files').objectStore('files').get('/data/draft.json');
|
|
|
|
|
|
r.onsuccess = () => ok(r.result ? JSON.parse(new TextDecoder().decode(r.result)).pgn : '');
|
|
|
|
|
|
};
|
|
|
|
|
|
q.onerror = () => ok('');
|
|
|
|
|
|
})`);
|
|
|
|
|
|
check(/1\. e4/.test(await draft()), 'the draft of the unsaved game is kept');
|
|
|
|
|
|
|
|
|
|
|
|
// The settings and the shelf after a reload (the browser's storage). The question on
|
|
|
|
|
|
// leaving is answered «Leave».
|
|
|
|
|
|
await t.evaluate(`(window.onbeforeunload = null, true)`);
|
2026-10-30 17:31:27 +03:00
|
|
|
|
await t.navigate(`${s.base}?lang=en`);
|
|
|
|
|
|
await started();
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
await sleep(2500);
|
2026-10-30 17:31:27 +03:00
|
|
|
|
await shot('web-9-reloaded.png');
|
Web version: databases read in a worker, the shelf's counts, Chrome and Edge remember chosen files
The page's reader: a Web Worker with a second instance of the program reads
a database (PGN, CBV, ZIP, 7Z) and gives back its text and index; the page
puts it together without reading it again (chess_core::PgnIndex,
PgnDatabase::into_index / from_index, serde behind a feature). A 13 MB CBV:
the longest frame 17 ms in Firefox, 67 ms in Chromium (1000 ms before).
platform::open_database is the same on both sides: away from the screen,
done when read. The shelf's cards count the games the same way (one file
at a time); the counts are kept through platform::fs.
Chrome, Edge (File System Access): a chosen file's handle is kept in the
browser's storage; at the next visit the file is read again by itself when
the browser allows it, else the card offers «Allow reading» (the browser's
own question). Files of different visits get folders of their own.
Checks: t.choose(files, open) for both browsers (in Chromium the handles of
the site's private file system stand for the dialog's); app.mjs checks the
draft, the question on leaving and the remembered file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:50:54 +03:00
|
|
|
|
check(/1\. e4/.test(await draft()), 'the draft is there after the reload (offered over the library)');
|
|
|
|
|
|
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)');
|
2026-10-30 17:58:01 +03:00
|
|
|
|
// 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');
|
Web version: databases read in a worker, the shelf's counts, Chrome and Edge remember chosen files
The page's reader: a Web Worker with a second instance of the program reads
a database (PGN, CBV, ZIP, 7Z) and gives back its text and index; the page
puts it together without reading it again (chess_core::PgnIndex,
PgnDatabase::into_index / from_index, serde behind a feature). A 13 MB CBV:
the longest frame 17 ms in Firefox, 67 ms in Chromium (1000 ms before).
platform::open_database is the same on both sides: away from the screen,
done when read. The shelf's cards count the games the same way (one file
at a time); the counts are kept through platform::fs.
Chrome, Edge (File System Access): a chosen file's handle is kept in the
browser's storage; at the next visit the file is read again by itself when
the browser allows it, else the card offers «Allow reading» (the browser's
own question). Files of different visits get folders of their own.
Checks: t.choose(files, open) for both browsers (in Chromium the handles of
the site's private file system stand for the dialog's); app.mjs checks the
draft, the question on leaving and the remembered file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:50:54 +03:00
|
|
|
|
}
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
} finally {
|
2026-10-30 17:31:27 +03:00
|
|
|
|
await s.stop();
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
}
|
2026-10-30 17:31:27 +03:00
|
|
|
|
for (const e of s.errors) console.log('console:', e);
|
|
|
|
|
|
check(s.errors.length === 0, 'no panic or error in the console');
|
Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play,
new databases, adding to a database, preparation, translation, their
shortcuts and the Translation tab. Files dropped on the window open like
chosen ones (in a browser; the desktop program takes no drops, as before),
with «Release to open» while they are dragged over it.
/app/: ?phone=android and ?phone=ios show those variants of the device page.
apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac,
Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and
app.mjs (headless Firefox: the device page in three languages without the
program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped
PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the
settings after a reload). All pass.
docs/dev/web.md: the architecture, the platform layer, what is not built for
a browser, the build and the checks, what comes next; docs/dev/uci.md and
desktop.md updated, web/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:18:45 +03:00
|
|
|
|
console.log(failures ? `${failures} failed` : 'all ok');
|
|
|
|
|
|
process.exit(failures ? 1 : 0);
|