diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 05fe450786d1..939124633be7 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -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, diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index f7b8997a2098..8f1be8bfddd3 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -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 diff --git a/shell/browser/api/atom_api_event.cc b/shell/browser/api/atom_api_event.cc index c2e871438613..966e6925112d 100644 --- a/shell/browser/api/atom_api_event.cc +++ b/shell/browser/api/atom_api_event.cc @@ -13,12 +13,17 @@ v8::Local CreateWithSender(v8::Isolate* isolate, return mate::internal::CreateJSEvent(isolate, sender, nullptr, base::nullopt); } +v8::Local CreateEmpty(v8::Isolate* isolate) { + return mate::internal::CreateEmptyJSEvent(isolate); +} + void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("createWithSender", &CreateWithSender); + dict.SetMethod("createEmpty", &CreateEmpty); } } // namespace diff --git a/shell/browser/api/event_emitter.cc b/shell/browser/api/event_emitter.cc index c5ea6d04df73..50d3914fbbb2 100644 --- a/shell/browser/api/event_emitter.cc +++ b/shell/browser/api/event_emitter.cc @@ -67,6 +67,13 @@ v8::Local CreateJSEvent( return event; } +v8::Local CreateEmptyJSEvent(v8::Isolate* isolate) { + mate::Handle native_event = mate::Event::Create(isolate); + v8::Local event = + v8::Local::Cast(native_event.ToV8()); + return event; +} + v8::Local CreateCustomEvent(v8::Isolate* isolate, v8::Local object, v8::Local custom_event) { diff --git a/shell/browser/api/event_emitter.h b/shell/browser/api/event_emitter.h index ac39ee21c8bd..d548f7052c3c 100644 --- a/shell/browser/api/event_emitter.h +++ b/shell/browser/api/event_emitter.h @@ -28,6 +28,7 @@ v8::Local CreateJSEvent( content::RenderFrameHost* sender, base::Optional callback); +v8::Local CreateEmptyJSEvent(v8::Isolate* isolate); v8::Local CreateCustomEvent(v8::Isolate* isolate, v8::Local object, v8::Local event);