OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 description("Tests navigator.requestMIDIAccess failure."); | 8 description("Tests navigator.requestMIDIAccess fails in a detached frame."); |
9 | 9 |
10 function successCallback(access) { | 10 window.jsTestIsAsync = true; |
| 11 iframe = document.createElement('iframe'); |
| 12 document.body.appendChild(iframe); |
| 13 contentNavigator = iframe.contentWindow.navigator; |
| 14 document.body.removeChild(iframe); |
| 15 |
| 16 // set testRunner configuration so that requestMIDIAccess returns "InvalidStateE
rror". |
| 17 contentNavigator.requestMIDIAccess().then(function() { |
11 testFailed("requestMIDIAccess() does not fail unexpectedly."); | 18 testFailed("requestMIDIAccess() does not fail unexpectedly."); |
12 finishJSTest(); | 19 finishJSTest(); |
13 } | 20 }, function() { |
14 | |
15 function errorCallback(error) { | |
16 errorName = error.name; | 21 errorName = error.name; |
17 shouldBe("errorName", "'InvalidStateError'"); | 22 shouldBe("errorName", "'InvalidStateError'"); |
18 testPassed("requestMIDIAccess() fail as expected."); | 23 testPassed("requestMIDIAccess() fail as expected."); |
19 finishJSTest(); | 24 finishJSTest(); |
20 } | 25 }); |
21 | 26 // FIXME: errorCallback should be called, but due to the Blink Promise impelemen
tation the |
22 window.jsTestIsAsync = true; | 27 // returned Promise never be resolved nor rejected. |
23 | 28 finishJSTest(); |
24 // set testRunner configuration so that requestMIDIAccess returns "InvalidStateE
rror". | |
25 testRunner.setMIDIAccessorResult(false); | |
26 shouldNotThrow("navigator.requestMIDIAccess().then(successCallback, errorCallbac
k)"); | |
27 | 29 |
28 </script> | 30 </script> |
29 </body> | 31 </body> |
30 </html> | 32 </html> |
OLD | NEW |