-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: libuv hang on Windows * test: add a hang test * fix: contextIsolation issue Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
- Loading branch information
1 parent
f553395
commit bb031bf
Showing
7 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const { app, BrowserWindow, ipcMain } = require('electron'); | ||
const path = require('path'); | ||
|
||
async function createWindow () { | ||
const mainWindow = new BrowserWindow({ | ||
show: false, | ||
webPreferences: { | ||
contextIsolation: true, | ||
preload: path.join(__dirname, 'preload.js') | ||
} | ||
}); | ||
|
||
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters