fix: [wc|bw]-created events do not emit an event object (#19465)
* fix: emit real Event instead of empty object in [wc|bw] * chore: add ability to emit empty events
This commit is contained in:
parent
33d1e87163
commit
aaca9011ae
5 changed files with 17 additions and 2 deletions
|
@ -82,7 +82,8 @@ BrowserWindow.prototype._init = function () {
|
|||
}
|
||||
|
||||
// Notify the creation of the window.
|
||||
app.emit('browser-window-created', {}, this)
|
||||
const event = process.electronBinding('event').createEmpty()
|
||||
app.emit('browser-window-created', event, this)
|
||||
|
||||
Object.defineProperty(this, 'devToolsWebContents', {
|
||||
enumerable: true,
|
||||
|
|
|
@ -413,7 +413,8 @@ WebContents.prototype._init = function () {
|
|||
})
|
||||
}
|
||||
|
||||
app.emit('web-contents-created', {}, this)
|
||||
const event = process.electronBinding('event').createEmpty()
|
||||
app.emit('web-contents-created', event, this)
|
||||
}
|
||||
|
||||
// Deprecations
|
||||
|
|
|
@ -13,12 +13,17 @@ v8::Local<v8::Object> CreateWithSender(v8::Isolate* isolate,
|
|||
return mate::internal::CreateJSEvent(isolate, sender, nullptr, base::nullopt);
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> CreateEmpty(v8::Isolate* isolate) {
|
||||
return mate::internal::CreateEmptyJSEvent(isolate);
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("createWithSender", &CreateWithSender);
|
||||
dict.SetMethod("createEmpty", &CreateEmpty);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -67,6 +67,13 @@ v8::Local<v8::Object> CreateJSEvent(
|
|||
return event;
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> CreateEmptyJSEvent(v8::Isolate* isolate) {
|
||||
mate::Handle<mate::Event> native_event = mate::Event::Create(isolate);
|
||||
v8::Local<v8::Object> event =
|
||||
v8::Local<v8::Object>::Cast(native_event.ToV8());
|
||||
return event;
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> CreateCustomEvent(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::Object> custom_event) {
|
||||
|
|
|
@ -28,6 +28,7 @@ v8::Local<v8::Object> CreateJSEvent(
|
|||
content::RenderFrameHost* sender,
|
||||
base::Optional<electron::mojom::ElectronBrowser::MessageSyncCallback>
|
||||
callback);
|
||||
v8::Local<v8::Object> CreateEmptyJSEvent(v8::Isolate* isolate);
|
||||
v8::Local<v8::Object> CreateCustomEvent(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::Object> event);
|
||||
|
|
Loading…
Reference in a new issue