Add spec for midi without sysex permission

This commit is contained in:
Kevin Sawicki 2016-12-19 15:11:17 -08:00 committed by Birunthan Mohanathas
parent 2f26dbf39e
commit 977680d00b
3 changed files with 26 additions and 2 deletions

View file

@ -0,0 +1,5 @@
<script>
navigator.requestMIDIAccess({sysex: true}).then(() => {}, (err) => {
require('electron').ipcRenderer.sendToHost('message', err.name);
});
</script>

View file

@ -1,5 +1,5 @@
<script>
navigator.requestMIDIAccess({sysex: true}).then(() => {}, (err) => {
navigator.requestMIDIAccess({sysex: false}).then(() => {}, (err) => {
require('electron').ipcRenderer.sendToHost('message', err.name);
});
</script>

View file

@ -928,6 +928,12 @@ describe('<webview> tag', function () {
function setUpRequestHandler (webview, requestedPermission, completed) {
var listener = function (webContents, permission, callback) {
if (webContents.getId() === webview.getId()) {
// requestMIDIAccess with sysex requests both midi and midiSysex so
// grant the first midi one and then reject the midiSysex one
if (requestedPermission == 'midiSysex' && permission == 'midi') {
return callback(true)
}
assert.equal(permission, requestedPermission)
callback(false)
if (completed) completed()
@ -962,7 +968,7 @@ describe('<webview> tag', function () {
document.body.appendChild(webview)
})
it('emits when using navigator.requestMIDIAccess api', function (done) {
it('emits when using navigator.requestMIDIAccess without sysex api', function (done) {
webview.addEventListener('ipc-message', function (e) {
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['SecurityError'])
@ -971,6 +977,19 @@ describe('<webview> tag', function () {
webview.src = 'file://' + fixtures + '/pages/permissions/midi.html'
webview.partition = 'permissionTest'
webview.setAttribute('nodeintegration', 'on')
setUpRequestHandler(webview, 'midi')
document.body.appendChild(webview)
})
it('emits when using navigator.requestMIDIAccess with sysex api', function (done) {
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')
setUpRequestHandler(webview, 'midiSysex')
document.body.appendChild(webview)
})