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 // FIXME: remove following workaround once testRunner in Chromium has a new inte
rface. | |
12 if (!testRunner.setMIDISysexPermission) | |
13 testRunner.setMIDISysexPermission = testRunner.setMIDISysExPermission; | |
14 | |
15 shouldBeDefined("testRunner.setMIDISysexPermission"); | 11 shouldBeDefined("testRunner.setMIDISysexPermission"); |
16 shouldBeDefined("navigator.requestMIDIAccess"); | 12 shouldBeDefined("navigator.requestMIDIAccess"); |
17 | 13 |
18 window.jsTestIsAsync = true; | 14 window.jsTestIsAsync = true; |
19 | 15 |
20 var finishSuccessfully = function () { | 16 var finishSuccessfully = function () { |
21 testPassed("all permission request rests pass successfully."); | 17 testPassed("all permission request rests pass successfully."); |
22 finishJSTest(); | 18 finishJSTest(); |
23 } | 19 } |
24 | 20 |
25 var rejectSysEx = function (next) { | 21 var rejectSysex = function (next) { |
26 testRunner.setMIDISysexPermission(false); | 22 testRunner.setMIDISysexPermission(false); |
27 promise = navigator.requestMIDIAccess({sysex: true}); | 23 promise = navigator.requestMIDIAccess({sysex: true}); |
28 shouldBeDefined("promise"); | 24 shouldBeDefined("promise"); |
29 shouldBeDefined("promise.then"); | 25 shouldBeDefined("promise.then"); |
30 promise.then(function(access) { | 26 promise.then(function(access) { |
31 testFailed("sysex permission request should be rejected."); | 27 testFailed("sysex permission request should be rejected."); |
32 finishJSTest(); | 28 finishJSTest(); |
33 }, function (error) { | 29 }, function (error) { |
34 testPassed("sysex permission request is successfully rejected."); | 30 testPassed("sysex permission request is successfully rejected."); |
35 if (next) | 31 if (next) |
36 next(); | 32 next(); |
37 else | 33 else |
38 finishSuccessfully(); | 34 finishSuccessfully(); |
39 }); | 35 }); |
40 } | 36 } |
41 | 37 |
42 var acceptSysEx = function (next) { | 38 var acceptSysex = function (next) { |
43 testRunner.setMIDISysexPermission(true); | 39 testRunner.setMIDISysexPermission(true); |
44 promise = navigator.requestMIDIAccess({sysex: true}); | 40 promise = navigator.requestMIDIAccess({sysex: true}); |
45 shouldBeDefined("promise"); | 41 shouldBeDefined("promise"); |
46 shouldBeDefined("promise.then"); | 42 shouldBeDefined("promise.then"); |
47 promise.then(function(obtainedAccess) { | 43 promise.then(function(obtainedAccess) { |
48 testPassed("sysex permission request is successfully accepted."); | 44 testPassed("sysex permission request is successfully accepted."); |
49 access = obtainedAccess; | 45 access = obtainedAccess; |
50 shouldBeDefined("access"); | 46 shouldBeDefined("access"); |
51 shouldBeDefined("access.sysexEnabled"); | 47 shouldBeDefined("access.sysexEnabled"); |
52 shouldBeTrue("access.sysexEnabled"); | 48 shouldBeTrue("access.sysexEnabled"); |
53 if (next) | 49 if (next) |
54 next(); | 50 next(); |
55 else | 51 else |
56 finishSuccessfully(); | 52 finishSuccessfully(); |
57 }, function (error) { | 53 }, function (error) { |
58 testFailed("sysex permission request should be accepted."); | 54 testFailed("sysex permission request should be accepted."); |
59 finishJSTest(); | 55 finishJSTest(); |
60 }); | 56 }); |
61 } | 57 } |
62 | 58 |
63 rejectSysEx(acceptSysEx); | 59 rejectSysex(acceptSysex); |
64 | 60 |
65 </script> | 61 </script> |
66 </body> | 62 </body> |
67 </html> | 63 </html> |
OLD | NEW |