'use strict'; const test = require('node:test'); const assert = require('node:assert/strict'); const fs = require('fs'); const path = require('path'); test('central notifications render external messages as text', () => { const root = path.resolve(__dirname, '../..'); const state = fs.readFileSync(path.join(root, 'renderer', 'modules', 'state.js'), 'utf8'); const toastFunction = state.slice(state.indexOf('function showToast'), state.indexOf('// ── Navigation')); const friendly = state.slice(state.indexOf('function friendlyMessage'), state.indexOf('function showToast')); // The body must be written as text, and the text must be a coerced string. // showToast now displays the translated message, so the coercion moved into // friendlyMessage; both halves of the chain are asserted here. assert.match(toastFunction, /const message = friendlyMessage\(msg\);/); assert.match(toastFunction, /body\.textContent = message;/); assert.match(friendly, /String\(text \?\? ''\)/); assert.doesNotMatch(toastFunction, /innerHTML/); assert.doesNotMatch(friendly, /innerHTML/); }); test('the retired console service is absent from active product surfaces', () => { const root = path.resolve(__dirname, '../..'); const token = ['void', 'shell'].join(''); const files = [ 'main.js', 'preload.js', 'renderer/index.html', 'renderer/pork-web-shim.js', 'src/server/create-registry.js', 'src/server/register-functional-modules.js', 'src/services/console-profile-service.js', 'build/lang/en.json', 'build/lang/fr.json', ]; const rendererModules = fs.readdirSync(path.join(root, 'renderer', 'modules')).filter(file => file.endsWith('.js')).map(file => `renderer/modules/${file}`); const contents = [...files, ...rendererModules].map(file => fs.readFileSync(path.join(root, file), 'utf8').toLowerCase()).join('\n'); assert.equal(contents.includes(token), false); assert.equal(fs.existsSync(path.join(root, 'renderer', 'modules', `${token}.js`)), false); assert.equal(fs.existsSync(path.join(root, 'build', 'garlic', `${token}.elf`)), false); assert.equal(fs.existsSync(path.join(root, 'build', 'garlic', 'ps5_autoloader', `${token}.elf`)), false); }); test('active renderer modules use accessible in-app dialogs', () => { const root = path.resolve(__dirname, '../..'); const contents = fs.readdirSync(path.join(root, 'renderer', 'modules')) .filter(file => file.endsWith('.js')) .map(file => fs.readFileSync(path.join(root, 'renderer', 'modules', file), 'utf8')) .join('\n'); assert.doesNotMatch(contents, /(?:window\.)?(?:confirm|prompt|alert)\s*\(/); assert.match(contents, /showExactConfirmation\(/); }); test('the primary application shell has no inline script event handlers', () => { const root = path.resolve(__dirname, '../..'); const html = fs.readFileSync(path.join(root, 'renderer', 'index.html'), 'utf8'); const activeModules = ['backups.js', 'backporks.js', 'cheats.js', 'games.js', 'media.js', 'modal.js', 'pfs-ripper.js'] .map(file => fs.readFileSync(path.join(root, 'renderer', 'modules', file), 'utf8')).join('\n'); assert.doesNotMatch(html, /]*\bsrc=)[^>]*>/i); assert.doesNotMatch(html, /\son(?:click|error|load|change|submit|keydown)\s*=/i); assert.doesNotMatch(activeModules, /\son(?:click|error|load|change|submit|keydown)\s*=/i); }); test('PS5 payload sessions only start from explicit user controls', () => { const root = path.resolve(__dirname, '../..'); const html = fs.readFileSync(path.join(root, 'renderer', 'index.html'), 'utf8'); const arsenal = fs.readFileSync(path.join(root, 'renderer', 'modules', 'elf-arsenal.js'), 'utf8'); const saveManager = fs.readFileSync(path.join(root, 'renderer', 'modules', 'savemgr.js'), 'utf8'); assert.match(arsenal, /ea-embed-start[^]*addEventListener\('click'/); assert.doesNotMatch(arsenal, /autoStart/); assert.match(html, /id="btn-sm-start-session"/); assert.match(saveManager, /btn-sm-start-session[^]*addEventListener\('click'/); assert.doesNotMatch(saveManager, /smFetchSaves\([^)]*autoStart/); }); test('ELF Arsenal uses the native Chimera client instead of embedding the fragile upstream page', () => { const root = path.resolve(__dirname, '../..'); const arsenal = fs.readFileSync(path.join(root, 'renderer', 'modules', 'elf-arsenal.js'), 'utf8'); assert.doesNotMatch(arsenal, /createElement\(['"]iframe['"]\)|