Compare commits

...

7 Commits

Author SHA1 Message Date
Noah Gregory
affe598a14 fix: address failing safeDialogs tests 2026-03-11 17:16:44 -04:00
Noah Gregory
10b2ab5d18 style: make linter actually happy 2026-03-11 17:03:40 -04:00
Noah Gregory
04efaacea9 style: make linter happy 2026-03-11 17:03:40 -04:00
Noah Gregory
884cebe2ae refactor: exit on events instead of on timeout for dialog crash test
Co-authored-by: Robo <hop2deep@gmail.com>
2026-03-11 17:03:40 -04:00
Noah Gregory
e4e7d57b92 test: add crash test case for URL-less dialogs 2026-03-11 17:03:40 -04:00
Noah Gregory
46b92bf2d1 refactor: remove additional URL parsing entirely when showing dialogs 2026-03-11 17:03:40 -04:00
Noah Gregory
7f84770c1d fix: fallback to opaque URL when needed inside dialog callback 2026-03-11 17:03:40 -04:00
3 changed files with 30 additions and 2 deletions

View File

@@ -782,8 +782,7 @@ WebContents.prototype._init = function () {
const originCounts = new Map<string, number>();
const openDialogs = new Set<AbortController>();
this.on('-run-dialog', async (info, callback) => {
const originUrl = new URL(info.frame.url);
const origin = originUrl.protocol === 'file:' ? originUrl.href : originUrl.origin;
const origin = info.frame.origin === 'file://' ? info.frame.url : info.frame.origin;
if ((originCounts.get(origin) ?? 0) < 0) return callback(false, '');
const prefs = this.getLastWebPreferences();

View File

@@ -0,0 +1,7 @@
<html>
<body>
<script>
window.open('javascript:alert()');
</script>
</body>
</html>

View File

@@ -0,0 +1,22 @@
const { app, BrowserWindow } = require('electron');
process.on('uncaughtException', (err) => {
console.error(err);
process.exit(1);
});
process.on('unhandledRejection', (reason) => {
console.error(reason);
process.exit(1);
});
app.on('browser-window-created', (_, window) => {
window.webContents.once('did-frame-navigate', () => {
process.exit(0);
});
});
app.whenReady().then(() => {
const win = new BrowserWindow({ show: false });
win.loadFile('index.html');
});