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,14 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
// Only prevent unload on the first window close
var unloadPrevented = false;
window.onbeforeunload = function() {
if (!unloadPrevented) {
unloadPrevented = true;
return '';
}
}
</script>
</body>
</html>

View file

@ -0,0 +1,17 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
function installBeforeUnload(removeAfterNTimes) {
let count = 0
window.addEventListener('beforeunload', function handler(e) {
setTimeout(() => console.log('beforeunload'))
if (++count <= removeAfterNTimes) {
e.preventDefault();
e.returnValue = '';
}
})
console.log('installed')
}
</script>
</body>
</html>

View file

@ -0,0 +1,14 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
// Only prevent unload on the first window close
var unloadPrevented = false;
window.onbeforeunload = function() {
if (!unloadPrevented) {
unloadPrevented = true;
return false;
}
}
</script>
</body>
</html>

View file

@ -0,0 +1,9 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
window.onbeforeunload = function() {
}
</script>
</body>
</html>

View file

@ -0,0 +1,13 @@
const { contextBridge, ipcRenderer } = require('electron');
console.info(contextBridge);
let bound = false;
try {
contextBridge.exposeInMainWorld('test', {});
bound = true;
} catch {
// Ignore
}
ipcRenderer.send('context-bridge-bound', bound);

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<body>
<script>
try {
window.str = 'some-modified-text';
window.obj.prop = 'obj-modified-prop';
window.arr.splice(2, 0, 5);
} catch (e) { }
console.log(window.str);
console.log(window.obj.prop);
console.log(window.arr);
</script>
</body>
</html>

View file

@ -0,0 +1,20 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');
let win;
app.whenReady().then(function () {
win = new BrowserWindow({
webPreferences: {
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
}
});
win.loadFile('index.html');
win.webContents.on('console-message', (event, level, message) => {
console.log(message);
});
win.webContents.on('did-finish-load', () => app.quit());
});

View file

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

View file

@ -0,0 +1,5 @@
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('str', 'some-text');
contextBridge.exposeInMainWorld('obj', { prop: 'obj-prop' });
contextBridge.exposeInMainWorld('arr', [1, 2, 3, 4]);

View file

@ -0,0 +1 @@
<html></html>

View file

@ -0,0 +1,18 @@
const { app, webContents, protocol, session } = require('electron');
protocol.registerSchemesAsPrivileged([
{ scheme: 'test', privileges: { standard: true, secure: true } }
]);
app.whenReady().then(function () {
const ses = session.fromPartition('persist:test-standard-shutdown');
const web = webContents.create({ session: ses });
ses.protocol.registerStringProtocol('test', (request, callback) => {
callback('Hello World!');
});
web.loadURL('test://abc/hello.txt');
web.on('did-finish-load', () => app.quit());
});

View file

@ -1 +0,0 @@
// Nothing to do here

View file

@ -1,4 +0,0 @@
{
"name": "some-module",
"main": "./main2.js"
}

View file

@ -0,0 +1,8 @@
const { app, ipcMain } = require('electron');
app.whenReady().then(() => {
process.stdout.write(JSON.stringify(ipcMain.eventNames()));
process.stdout.end();
app.quit();
});

View file

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

View file

@ -0,0 +1,22 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
const {ipcRenderer} = require('electron')
let echo
let requireError
try {
echo = require('@electron-ci/echo')
} catch (error) {
requireError = error
}
if (requireError != null) {
ipcRenderer.send('answer', `Require echo failed: ${requireError.message}`)
} else {
ipcRenderer.send('answer', typeof echo)
}
</script>
</body>
</html>

31
spec/fixtures/api/net-log/main.js vendored Normal file
View file

@ -0,0 +1,31 @@
const { app, net, session } = require('electron');
if (process.env.TEST_DUMP_FILE) {
app.commandLine.appendSwitch('log-net-log', process.env.TEST_DUMP_FILE);
}
function request () {
return new Promise((resolve) => {
const req = net.request(process.env.TEST_REQUEST_URL);
req.on('response', () => {
resolve();
});
req.end();
});
}
app.whenReady().then(async () => {
const netLog = session.defaultSession.netLog;
if (process.env.TEST_DUMP_FILE_DYNAMIC) {
await netLog.startLogging(process.env.TEST_DUMP_FILE_DYNAMIC);
}
await request();
if (process.env.TEST_MANUAL_STOP) {
await netLog.stopLogging();
}
app.quit();
});

View file

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

View file

@ -0,0 +1,6 @@
const { ipcRenderer, webFrame } = require('electron');
ipcRenderer.send('answer', {
argv: process.argv
});
window.close();

2382
spec/fixtures/api/print-to-pdf.html vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,13 @@
const { app, safeStorage, ipcMain } = require('electron');
const { promises: fs } = require('fs');
const path = require('path');
const pathToEncryptedString = path.resolve(__dirname, '..', 'encrypted.txt');
const readFile = fs.readFile;
app.whenReady().then(async () => {
const encryptedString = await readFile(pathToEncryptedString);
const decrypted = safeStorage.decryptString(encryptedString);
console.log(decrypted);
app.quit();
});

View file

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

View file

@ -0,0 +1,12 @@
const { app, safeStorage, ipcMain } = require('electron');
const { promises: fs } = require('fs');
const path = require('path');
const pathToEncryptedString = path.resolve(__dirname, '..', 'encrypted.txt');
const writeFile = fs.writeFile;
app.whenReady().then(async () => {
const encrypted = safeStorage.encryptString('plaintext');
const encryptedString = await writeFile(pathToEncryptedString, encrypted);
app.quit();
});

View file

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

107
spec/fixtures/api/sandbox.html vendored Normal file
View file

@ -0,0 +1,107 @@
<html>
<script type="text/javascript" charset="utf-8">
function timeout(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms)
})
}
async function invokeGc () {
// it seems calling window.gc once does not guarantee garbage will be
// collected, so we repeat 10 times with interval of 100 ms
for (let i = 0; i < 10; i++) {
window.gc()
await timeout(100)
}
}
const [,test] = window.location.href.split('?')
if (window.opener && test !== 'reload-remote') {
window.callback = () => {
opener.require('electron').ipcRenderer.send('answer', document.body.innerHTML)
}
} else {
const tests = {
'reload-remote-child': () => {
open(`${location.protocol}//${location.pathname}?reload-remote`)
},
'reload-remote': async () => {
const {ipcRenderer, remote} = require('electron')
const p = ipcRenderer.sendSync('get-remote-module-path')
const Hello = remote.require(p)
if (!ipcRenderer.sendSync('reloaded')) {
ipcRenderer.send('reload')
return
}
await invokeGc()
ipcRenderer.send('answer', new Hello().say())
},
'webcontents-stop': () => {
stop()
},
'webcontents-events': () => {
addEventListener('load', () => {
location.hash = 'in-page-navigate'
setTimeout(() => {
location.reload()
}, 50)
})
},
'exit-event': () => {
const {ipcRenderer} = require('electron')
const currentLocation = location.href.slice();
process.on('exit', () => {
ipcRenderer.send('answer', currentLocation)
})
location.assign('http://www.google.com')
},
'window-open': () => {
addEventListener('load', () => {
const popup = open(window.location.href, 'popup!', 'top=60,left=50,width=500,height=600')
popup.addEventListener('DOMContentLoaded', () => {
popup.document.write('<h1>scripting from opener</h1>')
popup.callback()
}, false)
})
},
'window-open-external': () => {
const {ipcRenderer} = require('electron')
addEventListener('load', () => {
ipcRenderer.once('open-the-popup', (event, url) => {
popup = open(url, '', 'top=65,left=55,width=505,height=605')
})
ipcRenderer.once('touch-the-popup', () => {
let errorMessage = null
try {
const childDoc = popup.document
} catch (error) {
errorMessage = error.message
}
ipcRenderer.send('answer', errorMessage)
})
ipcRenderer.send('opener-loaded')
})
},
'verify-ipc-sender': () => {
const {ipcRenderer} = require('electron')
const popup = open()
ipcRenderer.once('verified', () => {
ipcRenderer.send('parent-answer')
})
popup.ipcRenderer.once('verified', () => {
popup.ipcRenderer.send('child-answer')
})
ipcRenderer.send('parent-ready')
popup.ipcRenderer.send('child-ready')
}
}
addEventListener('unload', () => {
if (window.popup)
popup.close()
}, false)
if (tests.hasOwnProperty(test))
tests[test]()
}
</script>
</html>

View file

@ -0,0 +1,9 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
var ipcRenderer = require('electron').ipcRenderer;
ipcRenderer.sendSync('send-sync-message', 'message');
</script>
</body>
</html>

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<body>
<script>
navigator.serviceWorker.register('sw.js', {
scope: location.pathname.split('/').slice(0, 2).join('/') + '/'
})
</script>
</body>
</html>

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<body>
<script>
navigator.serviceWorker.register('sw-logs.js', {
scope: location.pathname.split('/').slice(0, 2).join('/') + '/'
})
</script>
</body>
</html>

View file

@ -0,0 +1,6 @@
self.addEventListener('install', function (event) {
console.log('log log');
console.info('info log');
console.warn('warn log');
console.error('error log');
});

View file

@ -0,0 +1,3 @@
self.addEventListener('install', function (event) {
console.log('Installed');
});

View file

@ -0,0 +1,16 @@
const { app, BrowserWindow } = require('electron');
let win;
app.whenReady().then(function () {
win = new BrowserWindow({});
win.setMenu(null);
setTimeout(() => {
if (win.isMenuBarVisible()) {
console.log('Window has a menu');
} else {
console.log('Window has no menu');
}
app.quit();
});
});

View file

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

View file

@ -0,0 +1,19 @@
const { app, BrowserWindow } = require('electron');
let win;
// This test uses "app.once('ready')" while the |test-menu-null| test uses
// "app.whenReady()", the 2 APIs have slight difference on timing to cover
// more cases.
app.once('ready', function () {
win = new BrowserWindow({});
win.setMenuBarVisibility(false);
setTimeout(() => {
if (win.isMenuBarVisible()) {
console.log('Window has a menu');
} else {
console.log('Window has no menu');
}
app.quit();
});
});

View file

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

27
spec/fixtures/api/webrequest.html vendored Normal file
View file

@ -0,0 +1,27 @@
<script>
var url = new URL(location.href)
const port = new URLSearchParams(url.search).get("port")
const ipcRenderer = require('electron').ipcRenderer
let count = 0
function checkFinish() {
count++
if (count === 2) {
ipcRenderer.send('websocket-success')
}
}
var conn = new WebSocket(`ws://127.0.0.1:${port}/websocket`)
conn.onopen = data => conn.send('foo')
conn.onmessage = wsMsg
function wsMsg(msg) {
if (msg.data === 'bar') {
checkFinish()
} else {
ipcRenderer.send('fail')
}
}
fetch(`http://127.0.0.1:${port}/`).then(() => {
checkFinish()
})
</script>

View file

@ -0,0 +1,13 @@
const { ipcRenderer, webFrame } = require('electron');
setImmediate(function () {
if (window.location.toString() === 'bar://page/') {
const windowOpenerIsNull = window.opener == null;
ipcRenderer.send('answer', {
nodeIntegration: webFrame.getWebPreference('nodeIntegration'),
typeofProcess: typeof global.process,
windowOpenerIsNull
});
window.close();
}
});