mirror of
https://github.com/electron/electron.git
synced 2026-01-25 23:38:18 -05:00
Do not access default session before app is ready
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const {session} = require('electron')
|
||||
const {app, session} = require('electron')
|
||||
|
||||
// Global protocol APIs.
|
||||
module.exports = process.atomBinding('protocol')
|
||||
@@ -6,10 +6,18 @@ module.exports = process.atomBinding('protocol')
|
||||
// Fallback protocol APIs of default session.
|
||||
Object.setPrototypeOf(module.exports, new Proxy({}, {
|
||||
get (target, property) {
|
||||
return (...args) => session.defaultSession.protocol[property](...args)
|
||||
if (!app.isReady()) return
|
||||
|
||||
const protocol = session.defaultSession.protocol
|
||||
if (!protocol.hasOwnProperty(property)) return
|
||||
|
||||
// Returning a native function directly would throw error.
|
||||
return (...args) => protocol[property](...args)
|
||||
},
|
||||
|
||||
ownKeys () {
|
||||
if (!app.isReady()) return []
|
||||
|
||||
return Object.getOwnPropertyNames(session.defaultSession.protocol)
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user