earshelf / source /scripts /phone-cleanup.mjs
WilburDev's picture
Deploy 2026-11-19T12:25Z
4a58e48 verified
Raw History Blame Contribute Delete
720 Bytes
// Removes all EarShelf test data from the phone's Chrome and closes only the tab this session opened.
import { chromium } from '@playwright/test';
const b = await chromium.connectOverCDP('http://localhost:9333');
const ctx = b.contexts()[0];
const p = ctx.pages().find((x) => x.url().startsWith('http://localhost:4175'));
if (p) {
await p.evaluate(async () => { for (const r of await navigator.serviceWorker.getRegistrations()) await r.unregister(); });
await (await ctx.newCDPSession(p)).send('Storage.clearDataForOrigin', { origin: 'http://localhost:4175', storageTypes: 'all' });
await p.close();
}
console.log('remaining tabs:', ctx.pages().map((x) => x.url().slice(0, 60)));
await b.close().catch(() => {});