db7c92fd57
* 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
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
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);
|
|
});
|
|
});
|