Update the browser, editor, settings, and installer

This commit is contained in:
Knotty Wyvern
2026-10-12 14:46:21 -07:00
parent 909894b9c8
commit f6eaa52949
163 changed files with 146260 additions and 534 deletions
+46 -5
View File
@@ -4,7 +4,7 @@ import { mkdtemp, mkdir, writeFile } from 'node:fs/promises';
import path from 'node:path';
import os from 'node:os';
import assert from 'node:assert/strict';
const runtime = path.resolve('../RuneStone_Browser');
const runtime = path.resolve('browser-runtime');
const require = createRequire(path.join(runtime, 'package.json'));
const { chromium } = require('playwright');
const electron = require('electron');
@@ -45,7 +45,7 @@ const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_P
const errors = [];
try {
await ready;
page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
page = await browser.newPage({ viewport: { width: 1280, height: 800 }, deviceScaleFactor: Number(process.env.BROWSER_TEST_SCALE || 1) });
page.on('pageerror', error => errors.push(error.message));
await page.exposeFunction('browserRpc', async (command, args) => { const entry = { command, args, start: Date.now() }; commands.push(entry); const result = await rpc(command, args); entry.elapsed = Date.now() - entry.start; return result; });
await page.addInitScript(() => {
@@ -77,12 +77,53 @@ try {
assert.equal(await page.getByRole('button', { name: 'New browser tab', exact: true }).count(), 0);
const tabId = await page.locator('[data-browser-state="ready"]').getAttribute('data-browser-tab');
const evaluate = code => rpc('testEvaluate', { tabId, code });
await evaluate(`document.body.innerHTML='<input id="typing" style="position:absolute;left:40px;top:40px;width:300px;height:40px"><a href="https://example.com/" style="position:absolute;left:40px;top:130px">Example link</a><p style="position:absolute;left:40px;top:200px">Page text</p>';true;`);
const initialBox = await surface.boundingBox();
await page.mouse.click(initialBox.x + 100, initialBox.y + 60);
await page.keyboard.type('Hello World!');
await page.waitForTimeout(200);
assert.equal(await evaluate('document.querySelector("#typing").value'), 'Hello World!');
await page.keyboard.press('Control+a'); await page.keyboard.press('Control+c');
await page.keyboard.press('End'); await page.keyboard.press('Control+v');
await page.waitForTimeout(200);
assert.equal(await evaluate('document.querySelector("#typing").value'), 'Hello World!Hello World!');
await page.getByRole('textbox', { name: 'Web page text input' }).evaluate(node => {
node.dispatchEvent(new CompositionEvent('compositionstart', { bubbles: true }));
node.dispatchEvent(new CompositionEvent('compositionend', { bubbles: true, data: '日本語' }));
});
await page.waitForTimeout(100);
assert.ok((await evaluate('document.querySelector("#typing").value')).endsWith('日本語'));
await page.mouse.click(initialBox.x + 100, initialBox.y + 60, { button: 'right' });
await page.getByRole('menu', { name: 'Browser page actions' }).waitFor();
await page.getByRole('menuitem', { name: 'Select all Ctrl+A', exact: true }).click();
await page.waitForTimeout(100);
assert.equal(await evaluate('document.querySelector("#typing").selectionEnd - document.querySelector("#typing").selectionStart'), 27);
await page.mouse.click(initialBox.x + 70, initialBox.y + 138, { button: 'right' });
await page.getByRole('menuitem', { name: 'Copy link address', exact: true }).waitFor();
await page.keyboard.press('Escape');
assert.equal(await page.getByRole('menu', { name: 'Browser page actions' }).count(), 0);
await page.mouse.click(initialBox.x + 70, initialBox.y + 138, { button: 'right' });
await page.getByRole('menuitem', { name: 'Copy link address', exact: true }).click();
await page.mouse.click(initialBox.x + 100, initialBox.y + 60);
await page.keyboard.press('Control+a'); await page.keyboard.press('Control+v');
await page.waitForTimeout(100);
assert.equal(await evaluate('document.querySelector("#typing").value'), 'https://example.com/');
await evaluate(`document.body.innerHTML='<canvas width="1000" height="700"></canvas>'; const c=document.querySelector('canvas').getContext('2d'); let n=0; window.testAnimate=true; function draw(){ c.fillStyle='#fff';c.fillRect(0,0,1000,700);c.fillStyle='#5482ff';c.fillRect(n++*5%900,200,80,80);if(window.testAnimate)requestAnimationFrame(draw); } draw();true;`);
await page.locator('.surface img').waitFor();
await page.evaluate(() => { window.decodedFrames = 0; document.querySelector('.surface img').addEventListener('load', () => window.decodedFrames++); });
await page.waitForTimeout(3000);
const decodedFps = await page.evaluate(() => window.decodedFrames / 3);
assert.ok(decodedFps >= 24, `The host image surface must decode at least 24 FPS: ${decodedFps}`);
const beforeWheels = commands.filter(call => call.command === 'input' && call.args.input.type === 'mouseWheel').length;
await surface.evaluate(node => {
const bounds = node.getBoundingClientRect();
for (let index = 0; index < 500; index++) node.dispatchEvent(new WheelEvent('wheel', {
bubbles: true, cancelable: true, clientX: bounds.x + 100, clientY: bounds.y + 100, deltaY: index < 250 ? 80 : -80,
}));
});
await page.waitForTimeout(200);
const wheelBurstCalls = commands.filter(call => call.command === 'input' && call.args.input.type === 'mouseWheel').length - beforeWheels;
assert.ok(wheelBurstCalls <= 3, `Animated pages must not accumulate wheel input: ${wheelBurstCalls}`);
await evaluate('window.testAnimate=false;true;');
await evaluate(`document.body.innerHTML='<div style="width:4000px;height:6000px;background:linear-gradient(45deg,white,steelblue)"><h1>Native scroll fixture</h1></div>'; true;`);
await page.locator('.surface img').waitFor();
@@ -94,7 +135,7 @@ try {
const scrolled = await evaluate('({x:scrollX,y:scrollY})');
assert.ok(scrolled.x > 50 && scrolled.y > 100, `Middle-button motion must scroll real Chromium: ${JSON.stringify({ scrolled, anchor: await page.locator('.scroll-anchor').count(), wheels: commands.filter(c => c.command === 'input' && c.args.input.type === 'mouseWheel'), errors })}`);
await page.keyboard.press('Escape');
await page.waitForTimeout(150);
await page.waitForTimeout(350);
const stopped = await evaluate('scrollY');
await page.waitForTimeout(200);
assert.equal(await evaluate('scrollY'), stopped);
@@ -131,8 +172,8 @@ try {
await page.waitForFunction(() => document.querySelectorAll('[data-browser-state="ready"]').length >= 2);
assert.equal((await rpc('state')).tabs.length, 2, 'The center new-tab path must still open a browser tab.');
assert.deepEqual(errors, []);
await writeFile('output/browser-interaction.json', JSON.stringify({ decodedFps, scrolled, pointerBurstCalls: motionCount, passed: ['Native middle-button scrolling on both axes', 'Escape, click, drag release and focus loss stop scrolling', 'Pointer bursts coalesce', 'Both themes and narrow layout', 'Toolbar plus removed and center new-tab retained'] }, null, 2));
console.log('PASS browser UI with real Electron pages, autoscroll cleanup, pointer coalescing and center new-tab action');
await writeFile(`output/browser-interaction-${process.env.BROWSER_TEST_SCALE || 1}x.json`, JSON.stringify({ decodedFps, scrolled, pointerBurstCalls: motionCount, wheelBurstCalls, passed: ['Native text entry, clipboard, composition and context menus', 'Native middle-button scrolling on both axes', 'Escape, click, drag release and focus loss stop scrolling', 'Pointer and wheel bursts coalesce during animation', 'Both themes and narrow layout', 'Toolbar plus removed and center new-tab retained'] }, null, 2));
console.log('PASS browser UI with real Electron typing, clipboard, composition, page menus, autoscroll, pointer coalescing and center new-tab action');
} finally {
await browser.close();
await rpc('shutdown').catch(() => {}); child.kill();