allow protocol module initialization before app ready.

* ensure registerStandardSchemes can only be called before app ready
 * ensure other protocol methods can only be used after app ready
This commit is contained in:
deepak1556 2016-05-08 00:13:23 +05:30
parent 1ff33b7c81
commit 0f2ae385ed
5 changed files with 66 additions and 25 deletions

View file

@ -818,7 +818,7 @@ describe('protocol module', function () {
})
describe('protocol.registerStandardSchemes', function () {
const standardScheme = 'app'
const standardScheme = remote.getGlobal('standardScheme')
const origin = standardScheme + '://fake-host'
const imageURL = origin + '/test.png'
const filePath = path.join(__dirname, 'fixtures', 'pages', 'b.html')
@ -826,10 +826,6 @@ describe('protocol module', function () {
var w = null
var success = null
before(function () {
protocol.registerStandardSchemes([standardScheme])
})
beforeEach(function () {
w = new BrowserWindow({show: false})
success = false

View file

@ -6,6 +6,7 @@ const app = electron.app
const ipcMain = electron.ipcMain
const dialog = electron.dialog
const BrowserWindow = electron.BrowserWindow
const protocol = electron.protocol
const fs = require('fs')
const path = require('path')
@ -71,6 +72,10 @@ if (global.isCi) {
})
}
// Register app as standard scheme.
global.standardScheme = 'app'
protocol.registerStandardSchemes([global.standardScheme])
app.on('window-all-closed', function () {
app.quit()
})