Merge pull request #7788 from electron/notification-crash

Fix notification crash when using permission handler
This commit is contained in:
Kevin Sawicki 2016-10-31 09:39:38 -07:00 committed by GitHub
commit aa3bc13ca3
3 changed files with 37 additions and 7 deletions

View file

@ -0,0 +1,10 @@
<script>
var n1 = new Notification('Electron Notification.requestPermission test 1')
var n2 = new Notification('Electron Notification.requestPermission test 2')
Notification.requestPermission().then((result) => {
n1.close()
n2.close()
require('electron').ipcRenderer.sendToHost('message', result)
})
</script>

View file

@ -903,8 +903,8 @@ describe('<webview> tag', function () {
it('emits when using navigator.getUserMedia api', function (done) {
webview.addEventListener('ipc-message', function (e) {
assert(e.channel, 'message')
assert(e.args, ['PermissionDeniedError'])
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['PermissionDeniedError'])
done()
})
webview.src = 'file://' + fixtures + '/pages/permissions/media.html'
@ -916,8 +916,8 @@ describe('<webview> tag', function () {
it('emits when using navigator.geolocation api', function (done) {
webview.addEventListener('ipc-message', function (e) {
assert(e.channel, 'message')
assert(e.args, ['ERROR(1): User denied Geolocation'])
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['User denied Geolocation'])
done()
})
webview.src = 'file://' + fixtures + '/pages/permissions/geolocation.html'
@ -929,8 +929,8 @@ describe('<webview> tag', function () {
it('emits when using navigator.requestMIDIAccess api', function (done) {
webview.addEventListener('ipc-message', function (e) {
assert(e.channel, 'message')
assert(e.args, ['SecurityError'])
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['SecurityError'])
done()
})
webview.src = 'file://' + fixtures + '/pages/permissions/midi.html'
@ -946,6 +946,26 @@ describe('<webview> tag', function () {
setUpRequestHandler(webview, 'openExternal', done)
document.body.appendChild(webview)
})
it('emits when using Notification.requestPermission', function (done) {
webview.addEventListener('ipc-message', function (e) {
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['granted'])
done()
})
webview.src = 'file://' + fixtures + '/pages/permissions/notification.html'
webview.partition = 'permissionTest'
webview.setAttribute('nodeintegration', 'on')
session.fromPartition(webview.partition).setPermissionRequestHandler(function (webContents, permission, callback) {
if (webContents.getId() === webview.getId()) {
assert.equal(permission, 'notifications')
setTimeout(function () {
callback(true)
}, 10)
}
})
document.body.appendChild(webview)
})
})
describe('<webview>.getWebContents', function () {

2
vendor/brightray vendored

@ -1 +1 @@
Subproject commit a55f26ec2f53ccd961381234c941564b4fd4403f
Subproject commit bb35b4ada1ab9285251087656a9fdef488796509