okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-split-linuxui (83aa59fdc) into f-split-int2b6a38b328

main
1.8 KiB25 linesraw
1import test from 'node:test';
2import assert from 'node:assert/strict';
3import { readFile } from 'node:fs/promises';
4import { transform } from 'esbuild';
5
6// WebKitGTK 2.52 crashes its UI process (null pointer in AcceleratedBackingStore::update) on document.startViewTransition,
7// so the route morph must never be used there. This test pins the engine check and that the router uses it.
8const source = await readFile(new URL('../src/lib/router.ts', import.meta.url), 'utf8');
9const fn = source.match(/export function isWebKitGtk[\s\S]*?\r?\n}\r?\n/)[0];
10const { code } = await transform(fn, { loader: 'ts', format: 'esm' });
11const { isWebKitGtk } = await import(`data:text/javascript;base64,${Buffer.from(code).toString('base64')}`);
12
13test('WebKitGTK is recognised, other engines are not', () => {
14  assert.equal(isWebKitGtk('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15'), true);
15  assert.equal(isWebKitGtk('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko)'), true);
16  assert.equal(isWebKitGtk('Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0'), false);
17  assert.equal(isWebKitGtk('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0 Safari/537.36'), false);
18  assert.equal(isWebKitGtk('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15'), false);
19  assert.equal(isWebKitGtk('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0 Edg/130.0'), false);
20});
21
22test('the router skips the view transition on WebKitGTK', () => {
23  assert.match(source, /typeof document\.startViewTransition === 'function' &&\s*!isWebKitGtk\(\)/);
24  assert.equal((source.match(/document\.startViewTransition\(/g) ?? []).length, 1, 'one call site only, guarded above');
25});