test: drop now-empty remote runner (#35343)

* test: drop the now-empty remote runner from CI

* move fixtures to spec-main

* remove remote runner

* fix stuff

* remove global-paths hack

* move ts-smoke to spec/

* fix test after merge

* rename spec-main to spec

* no need to ignore spec/node_modules twice

* simplify spec-runner a little

* no need to hash pj/yl twice

* undo lint change to verify-mksnapshot.py

* excessive ..

* update electron_woa_testing.yml

* don't search for test-results-remote.xml

it is never produced now
This commit is contained in:
Jeremy Rose 2022-08-16 12:23:13 -07:00 committed by GitHub
parent e87c4015fe
commit db7c92fd57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
327 changed files with 950 additions and 1707 deletions

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test-color-window</title>
<style>
body {
background: green;
}
</style>
</head>
<body id="body">
<script src="./renderer.js"></script>
</body>
</html>

View file

@ -0,0 +1,61 @@
const { app, BrowserWindow, desktopCapturer, ipcMain } = require('electron');
const getColors = require('get-image-colors');
const colors = {};
// Fetch the test window.
const getWindow = async () => {
const sources = await desktopCapturer.getSources({ types: ['window'] });
const filtered = sources.filter(s => s.name === 'test-color-window');
if (filtered.length === 0) {
throw new Error('Could not find test window');
}
return filtered[0];
};
async function createWindow () {
const mainWindow = new BrowserWindow({
frame: false,
transparent: true,
vibrancy: 'under-window',
webPreferences: {
backgroundThrottling: false,
contextIsolation: false,
nodeIntegration: true
}
});
await mainWindow.loadFile('index.html');
// Get initial green background color.
const window = await getWindow();
const buf = window.thumbnail.toPNG();
const result = await getColors(buf, { count: 1, type: 'image/png' });
colors.green = result[0].hex();
}
ipcMain.on('set-transparent', async () => {
// Get updated background color.
const window = await getWindow();
const buf = window.thumbnail.toPNG();
const result = await getColors(buf, { count: 1, type: 'image/png' });
colors.transparent = result[0].hex();
const { green, transparent } = colors;
console.log({ green, transparent });
process.exit(green === transparent ? 1 : 0);
});
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});

View file

@ -0,0 +1,4 @@
{
"name": "electron-test-background-color-transparent",
"main": "main.js"
}

View file

@ -0,0 +1,9 @@
const { ipcRenderer } = require('electron');
window.setTimeout(async (_) => {
document.body.style.background = 'transparent';
window.setTimeout(async (_) => {
ipcRenderer.send('set-transparent');
}, 2000);
}, 3000);

65
spec/fixtures/apps/crash/main.js vendored Normal file
View file

@ -0,0 +1,65 @@
const { app, BrowserWindow, crashReporter } = require('electron');
const path = require('path');
const childProcess = require('child_process');
app.setVersion('0.1.0');
const url = app.commandLine.getSwitchValue('crash-reporter-url');
const uploadToServer = !app.commandLine.hasSwitch('no-upload');
const setExtraParameters = app.commandLine.hasSwitch('set-extra-parameters-in-renderer');
const addGlobalParam = app.commandLine.getSwitchValue('add-global-param')?.split(':');
crashReporter.start({
productName: 'Zombies',
companyName: 'Umbrella Corporation',
compress: false,
uploadToServer,
submitURL: url,
ignoreSystemCrashHandler: true,
extra: {
mainProcessSpecific: 'mps'
},
globalExtra: addGlobalParam[0] ? { [addGlobalParam[0]]: addGlobalParam[1] } : {}
});
app.whenReady().then(() => {
const crashType = app.commandLine.getSwitchValue('crash-type');
if (crashType === 'main') {
process.crash();
} else if (crashType === 'renderer') {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
if (setExtraParameters) {
w.webContents.executeJavaScript(`
require('electron').crashReporter.addExtraParameter('rendererSpecific', 'rs');
require('electron').crashReporter.addExtraParameter('addedThenRemoved', 'to-be-removed');
require('electron').crashReporter.removeExtraParameter('addedThenRemoved');
`);
}
w.webContents.executeJavaScript('process.crash()');
w.webContents.on('render-process-gone', () => process.exit(0));
} else if (crashType === 'sandboxed-renderer') {
const w = new BrowserWindow({
show: false,
webPreferences: {
sandbox: true,
preload: path.resolve(__dirname, 'sandbox-preload.js'),
contextIsolation: false
}
});
w.loadURL(`about:blank?set_extra=${setExtraParameters ? 1 : 0}`);
w.webContents.on('render-process-gone', () => process.exit(0));
} else if (crashType === 'node') {
const crashesDir = path.join(app.getPath('temp'), `${app.name} Crashes`);
const version = app.getVersion();
const crashPath = path.join(__dirname, 'node-crash.js');
const child = childProcess.fork(crashPath, [url, version, crashesDir], { silent: true });
child.on('exit', () => process.exit(0));
} else {
console.error(`Unrecognized crash type: '${crashType}'`);
process.exit(1);
}
});
setTimeout(() => app.exit(), 30000);

11
spec/fixtures/apps/crash/node-crash.js vendored Normal file
View file

@ -0,0 +1,11 @@
if (process.platform === 'linux') {
process.crashReporter.start({
submitURL: process.argv[2],
productName: 'Zombies',
compress: false,
globalExtra: {
_version: process.argv[3]
}
});
}
process.nextTick(() => process.crash());

4
spec/fixtures/apps/crash/package.json vendored Normal file
View file

@ -0,0 +1,4 @@
{
"name": "electron-test-crash",
"main": "main.js"
}

View file

@ -0,0 +1,10 @@
const { crashReporter } = require('electron');
const params = new URLSearchParams(location.search);
if (params.get('set_extra') === '1') {
crashReporter.addExtraParameter('rendererSpecific', 'rs');
crashReporter.addExtraParameter('addedThenRemoved', 'to-be-removed');
crashReporter.removeExtraParameter('addedThenRemoved');
}
process.crash();

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<script src="./renderer.js"></script>
</body>
</html>

37
spec/fixtures/apps/libuv-hang/main.js vendored Normal file
View file

@ -0,0 +1,37 @@
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
async function createWindow () {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
sandbox: false
}
});
await mainWindow.loadFile('index.html');
}
app.whenReady().then(() => {
createWindow();
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
let count = 0;
ipcMain.handle('reload-successful', () => {
if (count === 2) {
app.quit();
} else {
count++;
return count;
}
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit();
});

View file

@ -0,0 +1,16 @@
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('api', {
ipcRenderer,
run: async () => {
const { promises: fs } = require('fs');
for (let i = 0; i < 10; i++) {
const list = await fs.readdir('.', { withFileTypes: true });
for (const file of list) {
if (file.isFile()) {
await fs.readFile(file.name, 'utf-8');
}
}
}
}
});

View file

@ -0,0 +1,8 @@
const count = localStorage.getItem('count');
const { run, ipcRenderer } = window.api;
run().then(async () => {
const count = await ipcRenderer.invoke('reload-successful');
if (count < 3) location.reload();
}).catch(console.log);

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
<title>Hello World!</title>
</head>
<body>
<a href="./new-window-page.html">Open New Window</a>
</body>
</html>

View file

@ -0,0 +1,64 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');
async function createWindow () {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
x: 100,
y: 100,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: false,
nodeIntegration: true
}
});
await mainWindow.loadFile('index.html');
const rect = await mainWindow.webContents.executeJavaScript('JSON.parse(JSON.stringify(document.querySelector("a").getBoundingClientRect()))');
const x = rect.x + rect.width / 2;
const y = rect.y + rect.height / 2;
function click (x, y, options) {
x = Math.floor(x);
y = Math.floor(y);
mainWindow.webContents.sendInputEvent({
type: 'mouseDown',
button: 'left',
x,
y,
clickCount: 1,
...options
});
mainWindow.webContents.sendInputEvent({
type: 'mouseUp',
button: 'left',
x,
y,
clickCount: 1,
...options
});
}
click(x, y, { modifiers: ['shift'] });
}
app.whenReady().then(() => {
app.on('web-contents-created', (e, wc) => {
wc.on('render-process-gone', (e, details) => {
console.error(details);
process.exit(1);
});
wc.on('did-finish-load', () => {
const title = wc.getTitle();
if (title === 'Window From Link') {
process.exit(0);
}
});
});
createWindow();
});

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
<title>Window From Link</title>
</head>
<body>
I'm a window opened from a link!
</body>
</html>

View file

@ -0,0 +1,4 @@
{
"name": "electron-test-open-new-window-from-link",
"main": "main.js"
}

View file

@ -0,0 +1,3 @@
window.addEventListener('click', e => {
console.log('click', e);
});

View file

@ -0,0 +1,32 @@
const { app } = require('electron');
const http = require('http');
const v8 = require('v8');
if (app.commandLine.hasSwitch('boot-eval')) {
// eslint-disable-next-line no-eval
eval(app.commandLine.getSwitchValue('boot-eval'));
}
app.whenReady().then(() => {
const server = http.createServer((req, res) => {
const chunks = [];
req.on('data', chunk => { chunks.push(chunk); });
req.on('end', () => {
const js = Buffer.concat(chunks).toString('utf8');
(async () => {
try {
const result = await Promise.resolve(eval(js)); // eslint-disable-line no-eval
res.end(v8.serialize({ result }));
} catch (e) {
res.end(v8.serialize({ error: e.stack }));
}
})();
});
}).listen(0, '127.0.0.1', () => {
process.stdout.write(`Listening: ${server.address().port}\n`);
});
});
setTimeout(() => {
process.exit(0);
}, 30000);

View file

@ -0,0 +1,4 @@
{
"name": "electron-test-remote-control",
"main": "main.js"
}

View file

@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<body>
<h1>Hello World!</h1>
<script src="./renderer.js"></script>
</body>
</html>

View file

@ -0,0 +1,34 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
function createWindow () {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
show: false,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
contextIsolation: false
}
});
mainWindow.loadFile('index.html');
}
ipcMain.handle('module-paths', (e, success) => {
process.exit(success ? 0 : 1);
});
app.whenReady().then(() => {
createWindow();
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit();
});

View file

@ -0,0 +1,4 @@
{
"name": "electron-test-self-module-paths",
"main": "main.js"
}

View file

@ -0,0 +1,12 @@
const { ipcRenderer } = require('electron');
const worker = new Worker('worker.js');
worker.onmessage = (event) => {
const workerPaths = event.data.sort().toString();
const rendererPaths = self.module.paths.sort().toString();
const validModulePaths = workerPaths === rendererPaths && workerPaths !== 0;
ipcRenderer.invoke('module-paths', validModulePaths);
worker.terminate();
};

View file

@ -0,0 +1 @@
self.postMessage(self.module.paths);

43
spec/fixtures/apps/set-path/main.js vendored Normal file
View file

@ -0,0 +1,43 @@
const http = require('http');
const { app, ipcMain, BrowserWindow } = require('electron');
if (process.argv.length > 3) {
app.setPath(process.argv[2], process.argv[3]);
}
const html = `
<script>
async function main() {
localStorage.setItem('myCat', 'Tom')
const db = indexedDB.open('db-name', 1)
await new Promise(resolve => db.onsuccess = resolve)
await navigator.serviceWorker.register('sw.js', {scope: './'})
}
main().then(() => {
require('electron').ipcRenderer.send('success')
})
</script>
`;
const js = 'console.log("From service worker")';
app.once('ready', () => {
ipcMain.on('success', () => {
app.quit();
});
const server = http.createServer((request, response) => {
if (request.url === '/') {
response.writeHead(200, { 'Content-Type': 'text/html' });
response.end(html);
} else if (request.url === '/sw.js') {
response.writeHead(200, { 'Content-Type': 'text/javascript' });
response.end(js);
}
}).listen(0, '127.0.0.1', () => {
const serverUrl = 'http://127.0.0.1:' + server.address().port;
const mainWindow = new BrowserWindow({ show: false, webPreferences: { webSecurity: true, nodeIntegration: true, contextIsolation: false } });
mainWindow.loadURL(serverUrl);
});
});

View file

@ -0,0 +1,4 @@
{
"name": "electron-test-set-path",
"main": "main.js"
}

BIN
spec/fixtures/apps/xwindow-icon/icon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

13
spec/fixtures/apps/xwindow-icon/main.js vendored Normal file
View file

@ -0,0 +1,13 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');
app.whenReady().then(() => {
const w = new BrowserWindow({
show: false,
icon: path.join(__dirname, 'icon.png')
});
w.webContents.on('did-finish-load', () => {
app.quit();
});
w.loadURL('about:blank');
});

View file

@ -0,0 +1,4 @@
{
"name": "electron-test-xwindow-icon",
"main": "main.js"
}