Index: third_party/WebKit/LayoutTests/http/tests/permissions/chromium/resources/test-request-multiple.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/permissions/chromium/resources/test-request-multiple.js b/third_party/WebKit/LayoutTests/http/tests/permissions/chromium/resources/test-request-multiple.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e4a175a4675c817e3af384f72593c2ded41a6b47 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/permissions/chromium/resources/test-request-multiple.js |
@@ -0,0 +1,137 @@ |
+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'); |
+ return setPermission('geolocation', 'denied', location.origin, location.origin); |
mlamouri (slow - plz ping)
2015/09/24 11:12:42
nit: add a comment saying "// Cleanup."
Lalit Maganti
2015/09/24 11:24:35
Done.
|
+ }).then(callback).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); |
+ }).then(function() { |
+ return setPermission('notifications', 'prompt', location.origin, location.origin); |
mlamouri (slow - plz ping)
2015/09/24 11:12:42
could you check the intermediary state here? (ie.
Lalit Maganti
2015/09/24 11:24:35
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, 'prompt'); |
+ return setPermission('geolocation', 'denied', location.origin, location.origin); |
mlamouri (slow - plz ping)
2015/09/24 11:12:42
ditto
Lalit Maganti
2015/09/24 11:24:35
Done.
|
+ }).then(function() { |
+ return setPermission('notifications', 'denied', location.origin, location.origin); |
mlamouri (slow - plz ping)
2015/09/24 11:12:42
Actually, could you do above:
return Promise.all
Lalit Maganti
2015/09/24 11:24:35
Done.
Lalit Maganti
2015/09/24 12:43:39
Realised that Promise.all does not work with the w
|
+ }).then(callback).catch(function(error) { |
+ assert_unreached(error); |
+ callback(); |
+ }); |
+ } |
+}, { |
+ test: async_test('Test two permissions (inverted) with update in ' + get_current_scope() + ' scope.'), |
+ fn: function(callback) { |
+ navigator.permissions.request([{name:'notifications'}, {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('notifications', 'granted', location.origin, location.origin); |
+ }).then(function() { |
+ return setPermission('geolocation', 'prompt', location.origin, location.origin); |
mlamouri (slow - plz ping)
2015/09/24 11:12:42
could you check the intermediary state here? (ie.
Lalit Maganti
2015/09/24 11:24:35
Done.
|
+ }).then(function() { |
+ return navigator.permissions.request([{name:'notifications'}, {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[0].state, 'granted'); |
+ assert_equals(result[1].state, 'prompt'); |
+ return setPermission('notifications', 'denied', location.origin, location.origin); |
+ }).then(function() { |
+ return setPermission('geolocation', 'denied', location.origin, location.origin); |
+ }).then(callback).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'); |
+ } |
+ return setPermission('geolocation', 'denied', location.origin, location.origin); |
+ }).then(callback).catch(function(error) { |
+ assert_unreached(error); |
+ callback(); |
+ }); |
+ } |
+}]; |
+ |
+function runTest(i) { |
+ tests[i].test.step(function() { |
+ tests[i].fn(function() { |
+ tests[i].test.done(); |
+ if (i + 1 < tests.length) { |
+ runTest(i + 1); |
+ } else { |
+ done(); |
+ } |
+ }); |
+ }); |
+} |
+runTest(0); |