diff --git a/atom/browser/api/event_emitter.cc b/atom/browser/api/event_emitter.cc index 9cf7ba520c0f..46a8e629e3f3 100644 --- a/atom/browser/api/event_emitter.cc +++ b/atom/browser/api/event_emitter.cc @@ -6,6 +6,7 @@ #include "atom/browser/api/event.h" #include "native_mate/arguments.h" +#include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" namespace mate { @@ -15,8 +16,8 @@ namespace { v8::Persistent event_template; void PreventDefault(mate::Arguments* args) { - args->GetThis()->Set(StringToV8(args->isolate(), "defaultPrevented"), - v8::True(args->isolate())); + mate::Dictionary self(args->isolate(), args->GetThis()); + self.Set("defaultPrevented", true); } // Create a pure JavaScript Event object. @@ -38,7 +39,7 @@ EventEmitter::EventEmitter() { v8::Local EventEmitter::CreateEvent(v8::Isolate* isolate, content::WebContents* sender, - IPC::Message* message) const { + IPC::Message* message) { v8::Local event; bool use_native_event = sender && message; @@ -49,6 +50,7 @@ v8::Local EventEmitter::CreateEvent(v8::Isolate* isolate, } else { event = CreateEventObject(isolate); } + mate::Dictionary(isolate, event).Set("sender", GetWrapper(isolate)); return event; } diff --git a/atom/browser/api/event_emitter.h b/atom/browser/api/event_emitter.h index a249ce23f087..43fbd84f61c4 100644 --- a/atom/browser/api/event_emitter.h +++ b/atom/browser/api/event_emitter.h @@ -51,7 +51,7 @@ class EventEmitter : public Wrappable { private: v8::Local CreateEvent(v8::Isolate* isolate, content::WebContents* sender, - IPC::Message* message) const; + IPC::Message* message); DISALLOW_COPY_AND_ASSIGN(EventEmitter); }; diff --git a/atom/browser/api/lib/web-contents.coffee b/atom/browser/api/lib/web-contents.coffee index c07c54103385..b2232b72cda6 100644 --- a/atom/browser/api/lib/web-contents.coffee +++ b/atom/browser/api/lib/web-contents.coffee @@ -33,12 +33,10 @@ wrapWebContents = (webContents) -> # Dispatch IPC messages to the ipc module. webContents.on 'ipc-message', (event, packed) -> [channel, args...] = packed - Object.defineProperty event, 'sender', value: webContents ipc.emit channel, event, args... webContents.on 'ipc-message-sync', (event, packed) -> [channel, args...] = packed Object.defineProperty event, 'returnValue', set: (value) -> event.sendReply JSON.stringify(value) - Object.defineProperty event, 'sender', value: webContents ipc.emit channel, event, args... webContents.printToPDF = (options, callback) ->