1import assert from 'node:assert/strict';2import { readFile } from 'node:fs/promises';3import test from 'node:test';45const main = await readFile(new URL('./main.js', import.meta.url), 'utf8');67test('mouse buttons use the same WebKit event family as motion and scrolling', () => {8 assert.match(9 main,10 /window\.addEventListener\('mousedown', handleMouseDown, \{ capture: true \}\);/,11 );12 assert.match(13 main,14 /window\.addEventListener\('mouseup', \(e\) => \{[\s\S]*?releaseMouseButton\(e\);[\s\S]*?\}, \{ capture: true \}\);/,15 );1617 const buttonHandlers = main.slice(18 main.indexOf('function handleMouseDown'),19 main.indexOf("window.addEventListener('contextmenu'"),20 );21 assert.doesNotMatch(buttonHandlers, /pointer(?:down|up|cancel)|pointerType|PointerCapture/);22});2324test('relative control consumes the synthetic local click before UI toggles see it', () => {25 assert.match(26 main,27 /window\.addEventListener\('click', suppressLocalClickDuringRelativeControl, \{ capture: true \}\);/,28 );2930 const clickGuard = main.slice(31 main.indexOf('function suppressLocalClickDuringRelativeControl'),32 main.indexOf("window.addEventListener('contextmenu'"),33 );34 assert.match(clickGuard, /controlRuntime\.active/);35 assert.match(clickGuard, /connectionState\.inputCapabilities\.relativePointer/);36 assert.match(clickGuard, /e\.preventDefault\(\)/);37 assert.match(clickGuard, /e\.stopImmediatePropagation\(\)/);38});