Skip to content

Commit

Permalink
chore: add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak1556 committed Mar 16, 2022
1 parent a9dda01 commit f4fa04a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
@@ -0,0 +1,17 @@
<html>
<body>
<script>
const fs = require('fs');
const { ipcRenderer } = require('electron');

async function readFile(path) {
await fs.promises.readFile(path);
}

ipcRenderer.on('reload', (_, path) => {
readFile(path);
window.location.reload();
});
</script>
</body>
</html>
28 changes: 28 additions & 0 deletions spec-main/fixtures/crash-cases/fs-promises-renderer-crash/index.js
@@ -0,0 +1,28 @@
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');

app.whenReady().then(() => {
let reloadCount = 0;
const win = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});

win.loadFile('index.html');

win.webContents.on('render-process-gone', () => {
process.exit(1);
});

win.webContents.on('did-finish-load', () => {
if (reloadCount > 2) {
setImmediate(() => app.quit());
} else {
reloadCount += 1;
win.webContents.send('reload', path.join(__dirname, '..', '..', 'cat.pdf'));
}
});
});

0 comments on commit f4fa04a

Please sign in to comment.