File size: 1,390 Bytes
39371ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { chromium } from 'playwright';
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
const browser = await chromium.launch({ executablePath: '/usr/bin/chromium', headless: true,
  args: ['--disable-gpu', '--disable-software-rasterizer'] });
try {
  const page = await browser.newPage();
  const requests = []; page.on('request', request => requests.push(request.url()));
  await page.goto('http://127.0.0.1:4173/');
  await page.waitForFunction(() => window.browserPi); await page.evaluate(() => window.browserPi.ready);
  await page.locator('#load').click();
  await page.waitForFunction(() => document.querySelector('#notice').textContent.includes('WebGPU'));
  assert.equal(await page.evaluate(() => window.browserPi.loaded), false);
  await page.locator('#command').fill('echo shell-still-works'); await page.locator('#shell-run').click();
  await page.waitForFunction(() => document.querySelector('#terminal-output').textContent.includes('[exit 0]'));
  const message = await page.locator('#notice').textContent();
  assert(!requests.some(url => url.includes('huggingface.co')));
  await fs.writeFile('../validation/agent-browser-no-gpu.json', JSON.stringify({ passed: true, message, shellWorks: true, modelRequests: 0 }, null, 2));
  console.log('Unavailable GPU: actionable error; shell works; no model download.');
} finally { await browser.close(); }