var fixtures = path.resolve(__dirname, 'fixtures')
var w = null
var url = 'http://127.0.0.1'
- var partitionName = 'temp'
- var protocolName = 'sp'
- const partitionProtocol = session.fromPartition(partitionName).protocol
- const protocol = session.defaultSession.protocol
beforeEach(function () {
if (w != null) {
})
describe('session.protocol', function () {
- beforeEach(function () {
- if (w != null) {
- w.destroy()
- }
+ const partitionName = 'temp'
+ const protocolName = 'sp'
+ const partitionProtocol = session.fromPartition(partitionName).protocol
+ const protocol = session.defaultSession.protocol
+ const handler = function (error, callback) {
+ callback({data: 'test'})
+ }
+
+ beforeEach(function (done) {
+ if (w != null) w.destroy()
w = new BrowserWindow({
show: false,
- width: 400,
- height: 400,
webPreferences: {
partition: partitionName
}
})
+ partitionProtocol.registerStringProtocol(protocolName, handler, function (error) {
+ done(error ? error : undefined)
+ })
})
afterEach(function (done) {
})
it('handles requests from a partition', function (done) {
- var handler = function (error, callback) {
- callback({
- data: 'test'
- })
- }
- partitionProtocol.registerStringProtocol(protocolName, handler, function (error) {
- if (error) {
- return done(error)
- }
- protocol.isProtocolHandled(protocolName, function (result) {
- assert.equal(result, false)
- partitionProtocol.isProtocolHandled(protocolName, function (result) {
- assert.equal(result, true)
- w.webContents.on('did-finish-load', function () {
- done()
- })
- w.loadURL(protocolName + "://fake-host")
+ protocol.isProtocolHandled(protocolName, function (result) {
+ assert.equal(result, false)
+ partitionProtocol.isProtocolHandled(protocolName, function (result) {
+ assert.equal(result, true)
+ w.webContents.on('did-finish-load', function () {
+ done()
})
+ w.loadURL(protocolName + "://fake-host")
})
})
})