fix: BrowserWindow.fromWebContents should work in browser-window-created (#33257)

This commit is contained in:
Jeremy Rose 2022-03-16 16:23:14 -07:00 committed by GitHub
parent b2c5623a13
commit e904486076
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -1816,6 +1816,18 @@ describe('BrowserWindow module', () => {
expect(BrowserWindow.fromWebContents(webviewContents)!.id).to.equal(w.id);
await p;
});
it('is usable immediately on browser-window-created', async () => {
const w = new BrowserWindow({ show: false });
w.loadURL('about:blank');
w.webContents.executeJavaScript('window.open(""); null');
const [win, winFromWebContents] = await new Promise((resolve) => {
app.once('browser-window-created', (e, win) => {
resolve([win, BrowserWindow.fromWebContents(win.webContents)]);
});
});
expect(winFromWebContents).to.equal(win);
});
});
describe('BrowserWindow.openDevTools()', () => {