78ebc4fffd
scripts/smoke.js, scripts/probe.js, scripts/probe-inject.js,
scripts/probe-minimal.js, scripts/smoke-final.js
The smoke test verifies the Beat Pocket extension loads and injects into
beat-battle.net:
1. Service worker registers (manifest valid, MV3 wiring works)
2. Content script runs (creates #bbp-host element on document.body)
3. No JS errors thrown on the page
4. Site renders normally (PLAY button still visible)
Why Playwright instead of raw --load-extension:
- Google Chrome refuses --load-extension on the command line
- Chromium full build accepts it but hangs under --virtual-time-budget
- Playwright's launchPersistentContext properly initializes extensions
in headless mode and gives a clean Chromium without the GCM/dbus noise
- The bundled Chromium is at
/root/.cache/ms-playwright/chromium-1208/chrome-linux64/chrome
Run with: node scripts/smoke-final.js (after npm install)
Probe results from this session:
- [final:dom] #bbp-host is appended to body via ensureHost()
- [final:errors] 0 page errors
- [final:console] 0 extension-related console lines (expected: silent
happy path; logs only on phase transitions)
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
// Test whether a MINIMAL extension's content script injects under headless
|
|
const { chromium } = require('/usr/lib/node_modules/@playwright/test');
|
|
|
|
const EXT_PATH = '/tmp/bbp-minimal';
|
|
|
|
(async () => {
|
|
const userDataDir = '/tmp/bb-minimal-' + Date.now();
|
|
const context = await chromium.launchPersistentContext(userDataDir, {
|
|
headless: true,
|
|
channel: 'chromium',
|
|
args: [
|
|
`--disable-extensions-except=${EXT_PATH}`,
|
|
`--load-extension=${EXT_PATH}`,
|
|
'--disable-dev-shm-usage',
|
|
'--no-sandbox',
|
|
],
|
|
viewport: { width: 414, height: 896 },
|
|
});
|
|
|
|
console.log('[minimal] workers:', context.serviceWorkers().length);
|
|
|
|
const page = context.pages()[0] || await context.newPage();
|
|
page.on('console', (m) => console.log(`[page:${m.type()}]`, m.text()));
|
|
page.on('pageerror', (e) => console.log('[page:error]', e.message));
|
|
|
|
await page.goto('https://beat-battle.net/', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
|
await page.waitForTimeout(4000);
|
|
|
|
const result = await page.evaluate(() => ({
|
|
htmlClass: document.documentElement.className,
|
|
hasMarker: !!document.getElementById('bbp-minimal-marker'),
|
|
markerText: document.getElementById('bbp-minimal-marker')?.textContent,
|
|
}));
|
|
console.log('[minimal:result]', result);
|
|
|
|
await context.close();
|
|
})().catch((e) => { console.error('FAIL:', e); process.exit(1); }); |