A browser puts only the first frame of an image on the clipboard, with HTML that names the image address. - Documents and cards download the original of a GIF, WebP, or AVIF address. The host commands workspace_save_image_url and workspace_download_image read the format from the file contents and refuse other data. A failed download keeps the first frame and shows a message. - Copy image in the RuneStone browser keeps the bytes that the page loaded. The engine reads them through the DevTools Protocol, so the website gets no second request. The new copiedImage command gives them in parts below the line limit of the host. A paste uses them first. - An empty dropped image file shows a message. Firefox gives such a file when the website refuses its download. Copy image needs a new browser engine build. Card 0d5c18f7.
26 lines
1.4 KiB
JavaScript
26 lines
1.4 KiB
JavaScript
// This IPC adapter exists only for the browser UI smoke test.
|
|
import { app } from 'electron';
|
|
import { createEngine } from '../src/engine.mjs';
|
|
app.enableSandbox();
|
|
app.setPath('userData', process.env.RS_INTERACTION_ROOT);
|
|
app.on('window-all-closed', () => {});
|
|
app.whenReady().then(async () => {
|
|
let framePending = false;
|
|
// The fixture server of the smoke test is on 127.0.0.1. The engine blocks local addresses for other hosts.
|
|
const engine = await createEngine({ directory: process.env.RS_INTERACTION_ROOT, allowedTestHosts: new Set(['127.0.0.1']), canEmitFrame: () => !framePending, emit: value => {
|
|
if (value.event === 'frame') framePending = true;
|
|
process.send?.({ event: value }, () => { if (value.event === 'frame') framePending = false; });
|
|
} });
|
|
process.on('message', async ({ id, command, args }) => {
|
|
try {
|
|
let result;
|
|
if (command === 'testEvaluate') result = await engine.tabs.get(args.tabId).view.webContents.executeJavaScript(args.code);
|
|
else if (command === 'shutdown') { await engine.shutdown(); process.send?.({ id, result: null }); app.exit(0); return; }
|
|
else result = await engine.command(command, args);
|
|
process.send?.({ id, result });
|
|
} catch (error) { process.send?.({ id, error: String(error) }); }
|
|
});
|
|
process.on('disconnect', () => { void engine.shutdown().finally(() => app.exit(0)); });
|
|
process.send?.({ ready: true });
|
|
});
|