Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 if (self.importScripts) { | 1 if (self.importScripts) { |
| 2 importScripts('helpers.js'); | 2 importScripts('helpers.js'); |
| 3 | 3 |
| 4 if (get_current_scope() == 'ServiceWorker') | 4 if (get_current_scope() == 'ServiceWorker') |
| 5 importScripts('../../serviceworker/resources/worker-testharness.js'); | 5 importScripts('../../serviceworker/resources/worker-testharness.js'); |
| 6 else | 6 else |
| 7 importScripts('../../resources/testharness.js'); | 7 importScripts('../../resources/testharness.js'); |
| 8 } | 8 } |
| 9 | 9 |
| 10 async_test(function(test) { | 10 async_test(function(test) { |
| 11 navigator.permissions.query('geolocation').then(function(result) { | 11 navigator.permissions.query({name:'geolocation'}).then(function(result) { |
| 12 // TODO(mlamouri): test values when some instrumentation are done. | 12 // TODO(mlamouri): test values when some instrumentation are available. |
| 13 assert_true(result instanceof PermissionStatus); | 13 assert_true(result instanceof PermissionStatus); |
| 14 test.done(); | 14 test.done(); |
| 15 }).catch(function() { | 15 }).catch(function() { |
| 16 assert_unreached('navigator.permissions.query() should not fail.') | 16 assert_unreached('querying geolocation permission should not fail.') |
| 17 }); | 17 }); |
| 18 }, 'Check the navigator.permissions.query() normal behavior in ' + get_current_s cope() + ' scope.'); | 18 }, 'Test geolocation permission in ' + get_current_scope() + ' scope.'); |
| 19 | 19 |
| 20 async_test(function(test) { | 20 async_test(function(test) { |
| 21 navigator.permissions.query('unknown-keyword').then(function() { | 21 navigator.permissions.query({name:'midi'}).then(function(result) { |
| 22 assert_unreached('navigator.permissions.query() should not succeed (for now).') | 22 // By default, the permission is granted if "sysex" option isn't set or |
| 23 }, function(e) { | 23 // set to false. |
| 24 assert_true(e instanceof TypeError); | 24 assert_equals(result.status, "granted"); |
| 25 assert_equals('TypeError', e.name); | 25 return navigator.permissions.query({name:'midi', sysex: false}); |
|
whywhat
2015/03/31 14:51:44
nit: add a blank line before each return to split
mlamouri (slow - plz ping)
2015/03/31 20:24:46
Done.
| |
| 26 }).then(function() { | 26 }).then(function(result) { |
| 27 // By default, the permission is granted if "sysex" option isn't set or | |
| 28 // set to false. | |
| 29 assert_equals(result.status, "granted"); | |
| 30 return navigator.permissions.query({name:'midi', sysex: true}); | |
| 31 }).then(function(result) { | |
| 32 // TODO(mlamouri): test values when some instrumentation are available. | |
| 33 assert_true(result instanceof PermissionStatus); | |
| 27 test.done(); | 34 test.done(); |
| 35 }).catch(function() { | |
| 36 assert_unreached('querying midi permission should not fail.') | |
| 28 }); | 37 }); |
| 29 }, 'Check the navigator.permissions.query() with wrong keyword in ' + get_curren t_scope() + ' scope.'); | 38 }, 'Test midi permission in ' + get_current_scope() + ' scope.'); |
| 39 | |
| 40 async_test(function(test) { | |
| 41 navigator.permissions.query({name:'notifications'}).then(function(result) { | |
| 42 // TODO(mlamouri): test values when some instrumentation are available. | |
| 43 assert_true(result instanceof PermissionStatus); | |
| 44 test.done(); | |
| 45 }).catch(function() { | |
| 46 assert_unreached('querying notifications permission should not fail.') | |
| 47 }); | |
| 48 }, 'Test notifications permission in ' + get_current_scope() + ' scope.'); | |
| 49 | |
| 50 async_test(function(test) { | |
| 51 navigator.permissions.query({name:'push'}).then(function(result) { | |
| 52 // By default, the permission is rejected if "userVisible" option isn't | |
| 53 // set or set to true. | |
| 54 assert_equals(result.status, "denied"); | |
| 55 return navigator.permissions.query({name:'push', userVisible: true}); | |
| 56 }).then(function(result) { | |
| 57 // By default, the permission is rejected if "userVisible" option isn't | |
| 58 // set or set to true. | |
| 59 assert_equals(result.status, "denied"); | |
| 60 return navigator.permissions.query({name:'push', userVisible: true}); | |
| 61 }).then(function(result) { | |
| 62 // TODO(mlamouri): test values when some instrumentation are available. | |
| 63 assert_true(result instanceof PermissionStatus); | |
| 64 test.done(); | |
| 65 }).catch(function() { | |
| 66 assert_unreached('querying push permission should not fail.') | |
| 67 }); | |
| 68 }, 'Test push permission in ' + get_current_scope() + ' scope.'); | |
| 30 | 69 |
| 31 done(); | 70 done(); |
| OLD | NEW |