Fix lint errors of using __proto__

This commit is contained in:
Cheng Zhao 2016-08-02 21:02:28 +09:00
parent edb573d69e
commit 8c0a033b6f
3 changed files with 10 additions and 8 deletions

View file

@ -220,11 +220,14 @@ void WebFrame::BuildPrototype(
namespace {
using atom::api::WebFrame;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("webFrame", atom::api::WebFrame::Create(isolate));
dict.Set("webFrame", WebFrame::Create(isolate));
dict.Set("WebFrame", WebFrame::GetConstructor(isolate)->GetFunction());
}
} // namespace

View file

@ -9,7 +9,7 @@ Object.setPrototypeOf(module.exports, new Proxy({}, {
if (!app.isReady()) return
const protocol = session.defaultSession.protocol
if (!protocol.__proto__.hasOwnProperty(property)) return
if (!Object.getPrototypeOf(protocol).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.__proto__)
return Object.getOwnPropertyNames(Object.getPrototypeOf(session.defaultSession.protocol))
},
getOwnPropertyDescriptor (target) {

View file

@ -1,11 +1,10 @@
'use strict'
const EventEmitter = require('events').EventEmitter
const {EventEmitter} = require('events')
const {webFrame, WebFrame} = process.atomBinding('web_frame')
const webFrame = process.atomBinding('web_frame').webFrame
// webFrame is an EventEmitter.
Object.setPrototypeOf(webFrame.__proto__, EventEmitter.prototype)
// WebFrame is an EventEmitter.
Object.setPrototypeOf(WebFrame.prototype, EventEmitter.prototype)
// Lots of webview would subscribe to webFrame's events.
webFrame.setMaxListeners(0)