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