| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../resources/js-test.js"></script> |
| <script src="../http/tests/resources/permissions-helper.js"></script> |
| <script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script> |
| <script src="file:///gen/media/midi/midi_service.mojom.js"></script> |
| <script src="../http/tests/webmidi/mock-midiservice.js"></script> |
| </head> |
| <body> |
| <script> |
| description("Tests navigator.requestMIDIAccess failure."); |
| |
| shouldBeDefined("PermissionsHelper.setPermission"); |
| |
| function successCallback(access) { |
| testFailed("requestMIDIAccess() does not fail unexpectedly."); |
| finishJSTest(); |
| } |
| |
| function errorCallback(error) { |
| errorName = error.name; |
| shouldBe("errorName", "'InvalidStateError'"); |
| testPassed("requestMIDIAccess() fail as expected."); |
| finishJSTest(); |
| } |
| |
| window.jsTestIsAsync = true; |
| |
| // Set default permission behavior that grants non-sysex requests. |
| PermissionsHelper.setPermission('midi', 'granted').then(function() { |
| mockMIDIService.setStartSessionResult(midi.mojom.Result.INITIALIZATION_ERROR); |
| navigator.requestMIDIAccess().then(successCallback, errorCallback); |
| }); |
| |
| |
| </script> |
| </body> |
| </html> |