Files
mumh5/test/e2e/web-shell.cjs
T
kibiandClaude Opus 5.5 826542ed8a Add a STUN responder to the proxy for screen sharing between browsers
The browser build uses it automatically, so no outside server is contacted.
Covered by unit tests and a two-browser step in the web E2E.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 21:38:42 +02:00

24 lines
1.3 KiB
JavaScript

// A bare browser window for the web E2E: no preload, so the page runs as it would in a browser.
const { app, BrowserWindow, desktopCapturer, session } = require('electron');
const fs = require('node:fs');
const path = require('node:path');
app.whenReady().then(() => {
session.defaultSession.setPermissionRequestHandler((_wc, _permission, cb) => cb(true));
// Electron would open a save dialog; a browser saves to the downloads folder
session.defaultSession.on('will-download', (_e, item) => {
const file = path.join(process.env.MUMH5_DOWNLOADS, item.getFilename());
item.setSavePath(file);
item.once('done', (_ev, state) => { if (state === 'completed') fs.writeFileSync(file + '.done', ''); });
});
// Stands in for the browser's own "choose what to share" dialog: always the first screen
session.defaultSession.setDisplayMediaRequestHandler(async (_request, callback) => {
let sources = [];
for (let i = 0; i < 10 && !sources.length; i++) sources = await desktopCapturer.getSources({ types: ['screen'] });
try { callback(sources.length ? { video: sources[0] } : {}); } catch { /* refused */ }
});
const win = new BrowserWindow({ width: 1280, height: 800, webPreferences: { contextIsolation: true, sandbox: true, nodeIntegration: false } });
win.loadURL(process.env.MUMH5_WEB_URL);
});
app.on('window-all-closed', () => app.quit());