Index: LayoutTests/http/tests/permissions/chromium/resources/test-request-multiple.js |
diff --git a/LayoutTests/http/tests/permissions/chromium/resources/test-request-multiple.js b/LayoutTests/http/tests/permissions/chromium/resources/test-request-multiple.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..62863cff08abf48b1ee6546afd2810c2ff7780c1 |
--- /dev/null |
+++ b/LayoutTests/http/tests/permissions/chromium/resources/test-request-multiple.js |
@@ -0,0 +1,109 @@ |
+if (self.importScripts) { |
+ importScripts('../../resources/helpers.js'); |
+ importScripts('testrunner-helpers.js'); |
+ |
+ if (get_current_scope() == 'ServiceWorker') |
+ importScripts('../../../serviceworker/resources/worker-testharness.js'); |
+ else |
+ importScripts('../../../resources/testharness.js'); |
+} |
+ |
+var tests = [ |
+{ |
+ test: async_test('Test empty array in ' + get_current_scope() + ' scope.'), |
+ fn: function(callback) { |
+ navigator.permissions.request([]).then(function(result) { |
+ assert_array_equals(result, []); |
+ callback(); |
+ }, function(error) { |
+ assert_unreached(error); |
+ callback(); |
+ }); |
+ } |
+}, { |
+ test: async_test('Test single permission with update in ' + get_current_scope() + ' scope.'), |
+ fn: function(callback) { |
+ navigator.permissions.request([{name:'geolocation'}]).then(function(result) { |
+ assert_equals(result.length, 1); |
+ assert_true(result[0] instanceof PermissionStatus); |
+ assert_equals(result[0].state, 'denied'); |
+ return setPermission('geolocation', 'granted', location.origin, location.origin); |
+ }).then(function() { |
+ return navigator.permissions.request([{name:'geolocation'}]); |
+ }).then(function(result) { |
+ assert_equals(result.length, 1); |
+ assert_true(result[0] instanceof PermissionStatus); |
+ assert_equals(result[0].state, 'granted'); |
+ callback(); |
mlamouri (slow - plz ping)
2015/09/23 14:24:28
Could you call navigator.permissions.revoke():
n
Lalit Maganti
2015/09/24 09:26:43
Done.
|
+ }).catch(function(error) { |
+ assert_unreached(error); |
+ callback(); |
+ }); |
+ } |
+}, { |
+ test: async_test('Test two permissions with update in ' + get_current_scope() + ' scope.'), |
+ fn: function(callback) { |
+ navigator.permissions.request([{name:'geolocation'}, {name:'notifications'}]).then(function(result) { |
+ assert_equals(result.length, 2); |
+ for (var i = 0; i < result.length; i++) { |
+ assert_true(result[i] instanceof PermissionStatus); |
+ assert_equals(result[i].state, 'denied'); |
+ } |
+ return setPermission('geolocation', 'granted', location.origin, location.origin); |
mlamouri (slow - plz ping)
2015/09/23 14:24:28
Could you set notifications to 'prompt'?
Lalit Maganti
2015/09/24 09:26:43
Done.
|
+ }).then(function() { |
+ return navigator.permissions.request([{name:'geolocation'}, {name:'notifications'}]); |
+ }).then(function(result) { |
+ assert_equals(result.length, 2); |
+ for (var i = 0; i < result.length; i++) |
+ assert_true(result[i] instanceof PermissionStatus); |
+ assert_equals(result[0].state, 'granted'); |
+ assert_equals(result[1].state, 'denied'); |
+ callback(); |
mlamouri (slow - plz ping)
2015/09/23 14:24:28
Could you add another test with geolocation/notifi
Lalit Maganti
2015/09/24 09:26:43
Done.
|
+ }).catch(function(error) { |
+ assert_unreached(error); |
+ callback(); |
+ }); |
+ } |
+}, { |
+ test: async_test('Test duplicate permissions with update in ' + get_current_scope() + ' scope.'), |
+ fn: function(callback) { |
+ navigator.permissions.request([{name:'geolocation'}, {name:'geolocation'}]).then(function(result) { |
+ assert_equals(result.length, 2); |
+ for (var i = 0; i < result.length; i++) { |
+ assert_true(result[i] instanceof PermissionStatus); |
+ assert_equals(result[i].state, 'denied'); |
+ } |
+ return setPermission('geolocation', 'granted', location.origin, location.origin); |
+ }).then(function() { |
+ return navigator.permissions.request([{name:'geolocation'}, {name:'geolocation'}]); |
+ }).then(function(result) { |
+ assert_equals(result.length, 2); |
+ for (var i = 0; i < result.length; i++) { |
+ assert_true(result[i] instanceof PermissionStatus); |
+ assert_equals(result[i].state, 'granted'); |
+ } |
+ callback(); |
+ }).catch(function(error) { |
+ assert_unreached(error); |
+ callback(); |
+ }); |
+ } |
+}]; |
+ |
+function runTest(i) { |
Lalit Maganti
2015/09/17 20:01:05
Should probably factor this out into the helper fi
Lalit Maganti
2015/09/24 09:26:43
Maybe not since reset was removed
|
+ tests[i].test.step(function() { |
+ tests[i].fn(function() { |
+ tests[i].test.done(); |
+ resetPermissions().then(function() { |
+ if (i + 1 < tests.length) { |
+ runTest(i + 1); |
+ } else { |
+ done(); |
+ } |
+ }).catch(function(error) { |
+ assert_unreached(error); |
+ }); |
+ }); |
+ }); |
+} |
+runTest(0); |