Current section
Files
Jump to
Current section
Files
priv/cursor-spike/focus3.mjs
import { chromium, firefox, webkit } from 'playwright';
for (const [n,l] of [['chromium',chromium],['firefox',firefox],['webkit',webkit]]) {
const b = await l.launch(); const p = await (await b.newContext()).newPage();
await p.goto('http://127.0.0.1:4126/');
await p.waitForFunction(()=>document.querySelector('[data-phx-main]')?.classList.contains('phx-connected'),null,{timeout:8000});
await p.waitForTimeout(200);
// aria-activedescendant model: focus stays on CONTAINER, never on items
await p.evaluate(()=>document.getElementById('clist').focus());
const before = await p.evaluate(()=>document.activeElement?.id);
await p.evaluate(()=>document.getElementById('c-content').click()); // synthetic content patch
await p.waitForFunction(()=>document.querySelector('[data-item="alpha"]')?.textContent.includes('v1'),null,{timeout:6000});
await p.waitForTimeout(150);
const afterContent = await p.evaluate(()=>document.activeElement?.id);
// container replacement (tag swap) with container focused
await p.evaluate(()=>document.getElementById('clist').focus());
await p.evaluate(()=>document.getElementById('c-container-tag').click());
await p.waitForFunction(()=>document.getElementById('clist')?.tagName==='OL',null,{timeout:6000});
await p.waitForTimeout(150);
const afterReplace = await p.evaluate(()=>document.activeElement?.id);
console.log(n.padEnd(9), 'containerFocus before='+before, 'afterContentPatch='+afterContent, 'afterContainerReplace='+(afterReplace||'(lost)'));
await b.close();
}