test: convert functions to async & eliminate duplicates (#37316)

test: convert functions to async

Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
Milan Burda 2023-02-20 12:30:57 +01:00 committed by GitHub
parent 969665eaa2
commit f97d68c4bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 225 additions and 343 deletions

View file

@ -176,17 +176,16 @@ describe('webContents.setWindowOpenHandler', () => {
await emittedOnce(browserWindow.webContents, 'did-create-window');
});
it('can change webPreferences of child windows', (done) => {
it('can change webPreferences of child windows', async () => {
browserWindow.webContents.setWindowOpenHandler(() => ({ action: 'allow', overrideBrowserWindowOptions: { webPreferences: { defaultFontSize: 30 } } }));
browserWindow.webContents.on('did-create-window', async (childWindow) => {
await childWindow.webContents.executeJavaScript("document.write('hello')");
const size = await childWindow.webContents.executeJavaScript("getComputedStyle(document.querySelector('body')).fontSize");
expect(size).to.equal('30px');
done();
});
const didCreateWindow = emittedOnce(browserWindow.webContents, 'did-create-window');
browserWindow.webContents.executeJavaScript("window.open('about:blank', '', 'show=no') && true");
const [childWindow] = await didCreateWindow;
await childWindow.webContents.executeJavaScript("document.write('hello')");
const size = await childWindow.webContents.executeJavaScript("getComputedStyle(document.querySelector('body')).fontSize");
expect(size).to.equal('30px');
});
it('does not hang parent window when denying window.open', async () => {