fix: don't handle browser messages before document element is created (#19718)
* fix: don't handle browser messages before document element is created * fix: bind ElectronApiServiceImpl later DidCreateDocumentElement is called before the ElectronApiServiceImpl gets bound. * chore: add comment
This commit is contained in:
parent
398c5d553d
commit
04dbd5c53f
5 changed files with 90 additions and 35 deletions
|
@ -3,7 +3,7 @@ import { AddressInfo } from 'net'
|
|||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
import * as path from 'path'
|
||||
import * as http from 'http'
|
||||
import { BrowserWindow, webContents } from 'electron'
|
||||
import { BrowserWindow, ipcMain, webContents } from 'electron'
|
||||
import { emittedOnce } from './events-helpers';
|
||||
import { closeAllWindows } from './window-helpers';
|
||||
|
||||
|
@ -77,6 +77,26 @@ describe('webContents module', () => {
|
|||
w.webContents.send(null as any)
|
||||
}).to.throw('Missing required channel argument')
|
||||
})
|
||||
|
||||
it('does not block node async APIs when sent before document is ready', (done) => {
|
||||
// Please reference https://github.com/electron/electron/issues/19368 if
|
||||
// this test fails.
|
||||
ipcMain.once('async-node-api-done', () => {
|
||||
done()
|
||||
})
|
||||
const w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
sandbox: false,
|
||||
contextIsolation: false
|
||||
}
|
||||
})
|
||||
w.loadFile(path.join(fixturesPath, 'pages', 'send-after-node.html'))
|
||||
setTimeout(() => {
|
||||
w.webContents.send("test")
|
||||
}, 50)
|
||||
})
|
||||
})
|
||||
|
||||
describe('webContents.executeJavaScript', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue