Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: LayoutTests/http/tests/permissions/chromium/resources/test-request-multiple.js

Issue 1352863003: permissions: add layout tests for multiple requests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@fix-request-test
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/permissions/chromium/test-request-multiple-sharedworker.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 if (self.importScripts) {
2 importScripts('../../resources/helpers.js');
3 importScripts('testrunner-helpers.js');
4
5 if (get_current_scope() == 'ServiceWorker')
6 importScripts('../../../serviceworker/resources/worker-testharness.js');
7 else
8 importScripts('../../../resources/testharness.js');
9 }
10
11 var tests = [
12 {
13 test: async_test('Test empty array in ' + get_current_scope() + ' scope.'),
14 fn: function(callback) {
15 navigator.permissions.request([]).then(function(result) {
16 assert_array_equals(result, []);
17 callback();
18 }, function(error) {
19 assert_unreached(error);
20 callback();
21 });
22 }
23 }, {
24 test: async_test('Test single permission with update in ' + get_current_scop e() + ' scope.'),
25 fn: function(callback) {
26 navigator.permissions.request([{name:'geolocation'}]).then(function(resu lt) {
27 assert_equals(result.length, 1);
28 assert_true(result[0] instanceof PermissionStatus);
29 assert_equals(result[0].state, 'denied');
30 return setPermission('geolocation', 'granted', location.origin, loca tion.origin);
31 }).then(function() {
32 return navigator.permissions.request([{name:'geolocation'}]);
33 }).then(function(result) {
34 assert_equals(result.length, 1);
35 assert_true(result[0] instanceof PermissionStatus);
36 assert_equals(result[0].state, 'granted');
37 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.
38 }).catch(function(error) {
39 assert_unreached(error);
40 callback();
41 });
42 }
43 }, {
44 test: async_test('Test two permissions with update in ' + get_current_scope( ) + ' scope.'),
45 fn: function(callback) {
46 navigator.permissions.request([{name:'geolocation'}, {name:'notification s'}]).then(function(result) {
47 assert_equals(result.length, 2);
48 for (var i = 0; i < result.length; i++) {
49 assert_true(result[i] instanceof PermissionStatus);
50 assert_equals(result[i].state, 'denied');
51 }
52 return setPermission('geolocation', 'granted', location.origin, loca tion.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.
53 }).then(function() {
54 return navigator.permissions.request([{name:'geolocation'}, {name:'n otifications'}]);
55 }).then(function(result) {
56 assert_equals(result.length, 2);
57 for (var i = 0; i < result.length; i++)
58 assert_true(result[i] instanceof PermissionStatus);
59 assert_equals(result[0].state, 'granted');
60 assert_equals(result[1].state, 'denied');
61 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.
62 }).catch(function(error) {
63 assert_unreached(error);
64 callback();
65 });
66 }
67 }, {
68 test: async_test('Test duplicate permissions with update in ' + get_current_ scope() + ' scope.'),
69 fn: function(callback) {
70 navigator.permissions.request([{name:'geolocation'}, {name:'geolocation' }]).then(function(result) {
71 assert_equals(result.length, 2);
72 for (var i = 0; i < result.length; i++) {
73 assert_true(result[i] instanceof PermissionStatus);
74 assert_equals(result[i].state, 'denied');
75 }
76 return setPermission('geolocation', 'granted', location.origin, loca tion.origin);
77 }).then(function() {
78 return navigator.permissions.request([{name:'geolocation'}, {name:'g eolocation'}]);
79 }).then(function(result) {
80 assert_equals(result.length, 2);
81 for (var i = 0; i < result.length; i++) {
82 assert_true(result[i] instanceof PermissionStatus);
83 assert_equals(result[i].state, 'granted');
84 }
85 callback();
86 }).catch(function(error) {
87 assert_unreached(error);
88 callback();
89 });
90 }
91 }];
92
93 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
94 tests[i].test.step(function() {
95 tests[i].fn(function() {
96 tests[i].test.done();
97 resetPermissions().then(function() {
98 if (i + 1 < tests.length) {
99 runTest(i + 1);
100 } else {
101 done();
102 }
103 }).catch(function(error) {
104 assert_unreached(error);
105 });
106 });
107 });
108 }
109 runTest(0);
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/permissions/chromium/test-request-multiple-sharedworker.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698