| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Permissions API: test midi sysex on insecure origins.</title> | 4 <title>Permissions API: test midi sysex on insecure origins.</title> |
| 5 <script src='../resources/testharness.js'></script> | 5 <script src='../resources/testharness.js'></script> |
| 6 <script src='../resources/testharnessreport.js'></script> | 6 <script src='../resources/testharnessreport.js'></script> |
| 7 <script src='../resources/get-host-info.js'></script> | 7 <script src='../resources/get-host-info.js'></script> |
| 8 </head> | 8 </head> |
| 9 <body> | 9 <body> |
| 10 <script> | 10 <script> |
| 11 // Midi SysEx is not available on insecure origins. This is testing that the | 11 // Midi SysEx is not available on insecure origins. This is testing that the |
| 12 // Permissions API matches navigator.requestMIDIAccess() behaviour. | 12 // Permissions API matches navigator.requestMIDIAccess() behaviour. |
| 13 // In the context of Chromium's LayoutTests, this test is a dummy test because | 13 // In the context of Chromium's LayoutTests, this test is a dummy test because |
| 14 // the Permissions API and requestMIDIAccess calls are using a mock | 14 // the Permissions API and requestMIDIAccess calls are using a mock |
| 15 // implementation of the backend. However, the test can be used in different | 15 // implementation of the backend. However, the test can be used in different |
| 16 // context. | 16 // context. |
| 17 if (window.location.origin != get_host_info().UNAUTHENTICATED_ORIGIN) { | 17 if (window.location.origin != get_host_info().UNAUTHENTICATED_ORIGIN) { |
| 18 window.location = get_host_info().UNAUTHENTICATED_ORIGIN + window.location.p
athname; | 18 window.location = get_host_info().UNAUTHENTICATED_ORIGIN + window.location.p
athname; |
| 19 } else { | 19 } else { |
| 20 async_test(function() { | 20 async_test(function() { |
| 21 navigator.requestMIDIAccess({sysex:true}).then(this.step_func(function() { | 21 navigator.requestMIDIAccess({sysex:true}).then(this.step_func(function() { |
| 22 assert_unreached('requesting midi access should fail'); | 22 assert_unreached('requesting midi access should fail'); |
| 23 this.done(); | 23 this.done(); |
| 24 })).catch(this.step_func(function(e) { | 24 })).catch(this.step_func(function(e) { |
| 25 assert_equals(e.name, 'SecurityError') | 25 assert_equals(e.name, 'SecurityError') |
| 26 return navigator.permissions.query({name:'midi', sysex:true}); | 26 return navigator.permissions.query({name:'midi', sysex:true}); |
| 27 })).then(this.step_func(function(p) { | 27 })).then(this.step_func(function(p) { |
| 28 assert_equals(p.status, "denied"); | 28 assert_equals(p.state, "denied"); |
| 29 this.done(); | 29 this.done(); |
| 30 })); | 30 })); |
| 31 }, 'requesting midi access and querying them should both return deny.'); | 31 }, 'requesting midi access and querying them should both return deny.'); |
| 32 } | 32 } |
| 33 </script> | 33 </script> |
| 34 </body> | 34 </body> |
| 35 </html> | 35 </html> |
| OLD | NEW |