From 6e0cde5b24053c76fc1948a6355175a3d78e9f54 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 2 Aug 2016 17:12:17 +0900 Subject: [PATCH] All native objects have prototype now --- lib/browser/api/app.js | 4 ++-- lib/browser/api/auto-updater/auto-updater-native.js | 2 +- lib/browser/api/power-monitor.js | 2 +- lib/browser/api/protocol.js | 4 ++-- lib/browser/api/screen.js | 2 +- lib/browser/api/session.js | 2 +- lib/browser/api/system-preferences.js | 2 +- lib/browser/api/web-contents.js | 4 ++-- lib/renderer/api/web-frame.js | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/browser/api/app.js b/lib/browser/api/app.js index a63ef241bb..2a537a6eb3 100644 --- a/lib/browser/api/app.js +++ b/lib/browser/api/app.js @@ -10,7 +10,7 @@ const electron = require('electron') const {deprecate, Menu} = electron const {EventEmitter} = require('events') -Object.setPrototypeOf(app, EventEmitter.prototype) +Object.setPrototypeOf(app.__proto__, EventEmitter.prototype) let appPath = null @@ -78,5 +78,5 @@ for (let name of events) { // Wrappers for native classes. process.atomBinding('download_item')._setWrapDownloadItem((downloadItem) => { // downloadItem is an EventEmitter. - Object.setPrototypeOf(downloadItem, EventEmitter.prototype) + Object.setPrototypeOf(downloadItem.__proto__, EventEmitter.prototype) }) diff --git a/lib/browser/api/auto-updater/auto-updater-native.js b/lib/browser/api/auto-updater/auto-updater-native.js index 1fff05dbd6..4f34f141e1 100644 --- a/lib/browser/api/auto-updater/auto-updater-native.js +++ b/lib/browser/api/auto-updater/auto-updater-native.js @@ -1,6 +1,6 @@ const EventEmitter = require('events').EventEmitter const autoUpdater = process.atomBinding('auto_updater').autoUpdater -Object.setPrototypeOf(autoUpdater, EventEmitter.prototype) +Object.setPrototypeOf(autoUpdater.__proto__, EventEmitter.prototype) module.exports = autoUpdater diff --git a/lib/browser/api/power-monitor.js b/lib/browser/api/power-monitor.js index 87c0069da3..3e93df5a18 100644 --- a/lib/browser/api/power-monitor.js +++ b/lib/browser/api/power-monitor.js @@ -1,6 +1,6 @@ const {EventEmitter} = require('events') const {powerMonitor} = process.atomBinding('power_monitor') -Object.setPrototypeOf(powerMonitor, EventEmitter.prototype) +Object.setPrototypeOf(powerMonitor.__proto__, EventEmitter.prototype) module.exports = powerMonitor diff --git a/lib/browser/api/protocol.js b/lib/browser/api/protocol.js index 9d8394f767..88cf594788 100644 --- a/lib/browser/api/protocol.js +++ b/lib/browser/api/protocol.js @@ -9,7 +9,7 @@ Object.setPrototypeOf(module.exports, new Proxy({}, { if (!app.isReady()) return const protocol = session.defaultSession.protocol - if (!protocol.hasOwnProperty(property)) return + if (!protocol.__proto__.hasOwnProperty(property)) return // Returning a native function directly would throw error. return (...args) => protocol[property](...args) @@ -18,7 +18,7 @@ Object.setPrototypeOf(module.exports, new Proxy({}, { ownKeys () { if (!app.isReady()) return [] - return Object.getOwnPropertyNames(session.defaultSession.protocol) + return Object.getOwnPropertyNames(session.defaultSession.protocol.__proto__) }, getOwnPropertyDescriptor (target) { diff --git a/lib/browser/api/screen.js b/lib/browser/api/screen.js index 25e3c37d3d..6bba99b553 100644 --- a/lib/browser/api/screen.js +++ b/lib/browser/api/screen.js @@ -1,6 +1,6 @@ const {EventEmitter} = require('events') const {screen} = process.atomBinding('screen') -Object.setPrototypeOf(screen, EventEmitter.prototype) +Object.setPrototypeOf(screen.__proto__, EventEmitter.prototype) module.exports = screen diff --git a/lib/browser/api/session.js b/lib/browser/api/session.js index d82e6d0154..0e463cf709 100644 --- a/lib/browser/api/session.js +++ b/lib/browser/api/session.js @@ -17,6 +17,6 @@ Object.defineProperties(exports, { // Wraps native Session class. _setWrapSession(function (session) { // Session is an EventEmitter. - Object.setPrototypeOf(session, EventEmitter.prototype) + Object.setPrototypeOf(session.__proto__, EventEmitter.prototype) app.emit('session-created', session) }) diff --git a/lib/browser/api/system-preferences.js b/lib/browser/api/system-preferences.js index 6ba1750507..74c2734f18 100644 --- a/lib/browser/api/system-preferences.js +++ b/lib/browser/api/system-preferences.js @@ -1,6 +1,6 @@ const {EventEmitter} = require('events') const {systemPreferences} = process.atomBinding('system_preferences') -Object.setPrototypeOf(systemPreferences, EventEmitter.prototype) +Object.setPrototypeOf(systemPreferences.__proto__, EventEmitter.prototype) module.exports = systemPreferences diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 04edb8d6c6..a67cf916bd 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -97,7 +97,7 @@ const webFrameMethodsWithResult = [ // Add JavaScript wrappers for WebContents class. const wrapWebContents = function (webContents) { // webContents is an EventEmitter. - Object.setPrototypeOf(webContents, EventEmitter.prototype) + Object.setPrototypeOf(webContents.__proto__, EventEmitter.prototype) // Every remote callback from renderer process would add a listenter to the // render-view-deleted event, so ignore the listenters warning. @@ -252,7 +252,7 @@ binding._setWrapWebContents(wrapWebContents) // Add JavaScript wrappers for Debugger class. const wrapDebugger = function (webContentsDebugger) { // debugger is an EventEmitter. - Object.setPrototypeOf(webContentsDebugger, EventEmitter.prototype) + Object.setPrototypeOf(webContentsDebugger.__proto__, EventEmitter.prototype) } debuggerBinding._setWrapDebugger(wrapDebugger) diff --git a/lib/renderer/api/web-frame.js b/lib/renderer/api/web-frame.js index 81855c391f..c6393292ef 100644 --- a/lib/renderer/api/web-frame.js +++ b/lib/renderer/api/web-frame.js @@ -5,7 +5,7 @@ const EventEmitter = require('events').EventEmitter const webFrame = process.atomBinding('web_frame').webFrame // webFrame is an EventEmitter. -Object.setPrototypeOf(webFrame, EventEmitter.prototype) +Object.setPrototypeOf(webFrame.__proto__, EventEmitter.prototype) // Lots of webview would subscribe to webFrame's events. webFrame.setMaxListeners(0)