Open
Description
When the BrowserWindow was created, the previously created BrowserWindow was reused using the formId, which generated a new EventEmitter, but the new EventEmitter did not call setDelegates, resulting in the postMessage of the webview was actually processed by the previously created EventEmitter and not sent to The new EventEmitter, which eventually caused the message to be lost.
function BrowserWindow(options) {
options = options || {}
var identifier = options.identifier || String(NSUUID.UUID().UUIDString())
var threadDictionary = NSThread.mainThread().threadDictionary()
var existingBrowserWindow = BrowserWindow.fromId(identifier)
// if we already have a window opened, reuse it
if (existingBrowserWindow) {
return existingBrowserWindow
}
//...
buildBrowserAPI(browserWindow, panel, webView)
buildWebAPI(browserWindow, panel, webView)
// setDelegates is called here
setDelegates(browserWindow, panel, webView, options)
}
BrowserWindow.fromId = function (identifier) {
var threadDictionary = NSThread.mainThread().threadDictionary()
if (threadDictionary[identifier]) {
return BrowserWindow.fromPanel(threadDictionary[identifier], identifier)
}
return undefined
}
BrowserWindow.fromPanel = function (panel, identifier) {
// A new EventEmitter is created her
var browserWindow = new EventEmitter()
browserWindow.id = identifier
if (!panel || !panel.contentView) {
throw new Error('needs to pass an NSPanel')
}
// ...
// But setDelegates is not called here
buildBrowserAPI(browserWindow, panel, webView)
buildWebAPI(browserWindow, panel, webView)
return browserWindow
}
Metadata
Metadata
Assignees
Labels
No labels