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 | 8 |
9 description("Test if sysex permission request is handled."); | 9 description("Test if sysex permission request is handled."); |
10 | 10 |
11 shouldBeDefined("testRunner.setPermission"); | 11 shouldBeDefined("testRunner.setPermission"); |
12 shouldBeDefined("testRunner.setMIDISysexPermission"); | |
13 shouldBeDefined("navigator.requestMIDIAccess"); | 12 shouldBeDefined("navigator.requestMIDIAccess"); |
14 | 13 |
15 window.jsTestIsAsync = true; | 14 window.jsTestIsAsync = true; |
16 | 15 |
17 var finishSuccessfully = function () { | 16 var finishSuccessfully = function () { |
18 testPassed("all permission request rests pass successfully."); | 17 testPassed("all permission request rests pass successfully."); |
19 finishJSTest(); | 18 finishJSTest(); |
20 } | 19 } |
21 | 20 |
22 var rejectSysex = function (next) { | 21 var rejectSysex = function (next) { |
23 testRunner.setPermission('midi-sysex', 'denied', location.origin, location.o
rigin); | 22 testRunner.setPermission('midi-sysex', 'denied', location.origin, location.o
rigin); |
24 testRunner.setMIDISysexPermission(false); | |
25 promise = navigator.requestMIDIAccess({sysex: true}); | 23 promise = navigator.requestMIDIAccess({sysex: true}); |
26 shouldBeDefined("promise"); | 24 shouldBeDefined("promise"); |
27 shouldBeDefined("promise.then"); | 25 shouldBeDefined("promise.then"); |
28 promise.then(function(access) { | 26 promise.then(function(access) { |
29 testFailed("sysex permission request should be rejected."); | 27 testFailed("sysex permission request should be rejected."); |
30 finishJSTest(); | 28 finishJSTest(); |
31 }, function (error) { | 29 }, function (error) { |
32 testPassed("sysex permission request is successfully rejected."); | 30 testPassed("sysex permission request is successfully rejected."); |
33 if (next) | 31 if (next) |
34 next(); | 32 next(); |
35 else | 33 else |
36 finishSuccessfully(); | 34 finishSuccessfully(); |
37 }); | 35 }); |
38 } | 36 } |
39 | 37 |
40 var acceptSysex = function (next) { | 38 var acceptSysex = function (next) { |
41 testRunner.setPermission('midi-sysex', 'granted', location.origin, location.
origin); | 39 testRunner.setPermission('midi-sysex', 'granted', location.origin, location.
origin); |
42 testRunner.setMIDISysexPermission(true); | |
43 promise = navigator.requestMIDIAccess({sysex: true}); | 40 promise = navigator.requestMIDIAccess({sysex: true}); |
44 shouldBeDefined("promise"); | 41 shouldBeDefined("promise"); |
45 shouldBeDefined("promise.then"); | 42 shouldBeDefined("promise.then"); |
46 promise.then(function(obtainedAccess) { | 43 promise.then(function(obtainedAccess) { |
47 testPassed("sysex permission request is successfully accepted."); | 44 testPassed("sysex permission request is successfully accepted."); |
48 access = obtainedAccess; | 45 access = obtainedAccess; |
49 shouldBeDefined("access"); | 46 shouldBeDefined("access"); |
50 shouldBeDefined("access.sysexEnabled"); | 47 shouldBeDefined("access.sysexEnabled"); |
51 shouldBeTrue("access.sysexEnabled"); | 48 shouldBeTrue("access.sysexEnabled"); |
52 if (next) | 49 if (next) |
53 next(); | 50 next(); |
54 else | 51 else |
55 finishSuccessfully(); | 52 finishSuccessfully(); |
56 }, function (error) { | 53 }, function (error) { |
57 testFailed("sysex permission request should be accepted."); | 54 testFailed("sysex permission request should be accepted."); |
58 finishJSTest(); | 55 finishJSTest(); |
59 }); | 56 }); |
60 } | 57 } |
61 | 58 |
62 rejectSysex(acceptSysex); | 59 rejectSysex(acceptSysex); |
63 | 60 |
64 </script> | 61 </script> |
65 </body> | 62 </body> |
66 </html> | 63 </html> |
OLD | NEW |