Add spec for denying perm requests when handler is cleared
This commit is contained in:
parent
18675cc6c1
commit
2f5acfedcd
1 changed files with 27 additions and 1 deletions
|
@ -13,6 +13,7 @@ const {ipcMain, session, BrowserWindow, net} = remote
|
||||||
describe('session module', function () {
|
describe('session module', function () {
|
||||||
var fixtures = path.resolve(__dirname, 'fixtures')
|
var fixtures = path.resolve(__dirname, 'fixtures')
|
||||||
var w = null
|
var w = null
|
||||||
|
var webview = null
|
||||||
var url = 'http://127.0.0.1'
|
var url = 'http://127.0.0.1'
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
@ -24,6 +25,11 @@ describe('session module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
if (!document.body.contains(webview)) {
|
||||||
|
document.body.appendChild(webview)
|
||||||
|
}
|
||||||
|
webview.remove()
|
||||||
|
|
||||||
return closeWindow(w).then(function () { w = null })
|
return closeWindow(w).then(function () { w = null })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -325,7 +331,7 @@ describe('session module', function () {
|
||||||
downloadServer.listen(0, '127.0.0.1', function () {
|
downloadServer.listen(0, '127.0.0.1', function () {
|
||||||
var port = downloadServer.address().port
|
var port = downloadServer.address().port
|
||||||
ipcRenderer.sendSync('set-download-option', false, false)
|
ipcRenderer.sendSync('set-download-option', false, false)
|
||||||
var webview = new WebView()
|
webview = new WebView()
|
||||||
webview.src = 'file://' + fixtures + '/api/blank.html'
|
webview.src = 'file://' + fixtures + '/api/blank.html'
|
||||||
webview.addEventListener('did-finish-load', function () {
|
webview.addEventListener('did-finish-load', function () {
|
||||||
webview.downloadURL(url + ':' + port + '/')
|
webview.downloadURL(url + ':' + port + '/')
|
||||||
|
@ -718,4 +724,24 @@ describe('session module', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('ses.setPermissionRequestHandler(handler)', () => {
|
||||||
|
it('cancels any pending requests when cleared', (done) => {
|
||||||
|
const ses = session.fromPartition('permissionTest')
|
||||||
|
ses.setPermissionRequestHandler(() => {
|
||||||
|
ses.setPermissionRequestHandler(null)
|
||||||
|
})
|
||||||
|
|
||||||
|
webview = new WebView()
|
||||||
|
webview.addEventListener('ipc-message', function (e) {
|
||||||
|
assert.equal(e.channel, 'message')
|
||||||
|
assert.deepEqual(e.args, ['SecurityError'])
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
webview.src = 'file://' + fixtures + '/pages/permissions/midi-sysex.html'
|
||||||
|
webview.partition = 'permissionTest'
|
||||||
|
webview.setAttribute('nodeintegration', 'on')
|
||||||
|
document.body.appendChild(webview)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue