Add spec for midi without sysex permission
This commit is contained in:
parent
2f26dbf39e
commit
977680d00b
3 changed files with 26 additions and 2 deletions
5
spec/fixtures/pages/permissions/midi-sysex.html
vendored
Normal file
5
spec/fixtures/pages/permissions/midi-sysex.html
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
<script>
|
||||
navigator.requestMIDIAccess({sysex: true}).then(() => {}, (err) => {
|
||||
require('electron').ipcRenderer.sendToHost('message', err.name);
|
||||
});
|
||||
</script>
|
2
spec/fixtures/pages/permissions/midi.html
vendored
2
spec/fixtures/pages/permissions/midi.html
vendored
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue