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

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

Issue 1241133002: blink: permissions: cleanup and add tests for revoke (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@permissions-revoke
Patch Set: Rebase on upstream patch Created 5 years, 5 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-revoke-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 tests = [
mlamouri (slow - plz ping) 2015/07/21 10:53:29 var tests
Lalit Maganti 2015/07/21 16:10:30 Done.
12 {
13 test: async_test('Test PermissionDescription WebIDL rules in ' + get_current _scope() + ' scope.'),
14 fn: function(callback) {
15 // Revoking a random permission name should fail.
16 navigator.permissions.revoke({name:'foobar'}).then(function(result) {
17 assert_unreached('revocing a random permission should fail');
mlamouri (slow - plz ping) 2015/07/21 10:53:29 nit: revoking
Lalit Maganti 2015/07/21 16:10:30 Done.
18 }, function(error) {
19 assert_equals(error.name, 'TypeError');
20
21 // Querying a permission without a name should fail.
22 return navigator.permissions.query({});
23 }).then(function(result) {
24 assert_unreached('revoking a permission without a name should fail') ;
25 }, function(error) {
26 assert_equals(error.name, 'TypeError');
27 callback();
28 });
29 }
30 },
31 {
32 test: async_test('Test geolocation permission in ' + get_current_scope() + ' scope.'),
33 fn: function(callback) {
34 setPermission('geolocation', 'granted', location.origin, location.origin). then(function() {
35 navigator.permissions.revoke({name:'geolocation'}).then(function(resul t) {
36 assert_true(result instanceof PermissionStatus);
37 assert_equals(result.status, 'denied');
mlamouri (slow - plz ping) 2015/07/21 10:53:29 Could you use .state instead of .status. Also, cou
Lalit Maganti 2015/07/21 16:10:30 Done.
38 callback();
39 }).catch(function() {
40 assert_unreached('revoking geolocation permission should not fail. ')
41 });
42 });
43 }
44 },
45 {
46 test: async_test('Test midi permission in ' + get_current_scope() + ' scope. '),
47 fn: function(callback) {
48 setPermission('midi-sysex', 'granted', location.origin, location.origin) .then(function() {
49 navigator.permissions.revoke({name:'geolocation'}).then(function(res ult) {
mlamouri (slow - plz ping) 2015/07/21 10:53:29 You might want to revoke 'midi-sysex' ;)
Lalit Maganti 2015/07/21 16:10:30 Revoke actually expects 'midi' but done.
50 assert_true(result instanceof PermissionStatus);
51 assert_equals(result.status, 'denied');
52 callback();
53 }).catch(function() {
54 assert_unreached('revoking geolocation permission should not fai l.')
55 });
56 });
57 }
58 },
59 {
60 test: async_test('Test push permission in ' + get_current_scope() + ' scope. '),
61 fn: function(callback) {
62 setPermission('push-messaging', 'granted', location.origin, location.ori gin).then(function() {
63 navigator.permissions.revoke({name:'push'}).catch(function(e) {
64 // By default, the permission query is rejected if "userVisibleO nly" option
65 // isn't set or set to true.
66 assert_equals(e.name, "NotSupportedError");
67
68 // Test for userVisibleOnly=false.
69 return navigator.permissions.revoke({name:'push', userVisibleOnl y: false});
70 }).catch(function(e) {
71 // By default, the permission query is rejected if "userVisibleO nly" option
72 // isn't set or set to true.
73 assert_equals(e.name, "NotSupportedError");
74
75 // Test for userVisibleOnly=true.
76 return navigator.permissions.revoke({name:'push', userVisibleOnl y: true});
77 }).then(function(result) {
78 assert_true(result instanceof PermissionStatus);
79 assert_equals(result.status, 'denied');
80 callback();
81 }).catch(function() {
82 assert_unreached('querying push permission should not fail.')
83 });
84 });
85 }
86 },
87 {
88 test: async_test('Test notifications permission in ' + get_current_scope() + ' scope.'),
89 fn: function(callback) {
90 setPermission('notifications', 'granted', location.origin, location.orig in).then(function() {
91 navigator.permissions.revoke({name:'notifications'}).then(function(r esult) {
92 assert_true(result instanceof PermissionStatus);
93 assert_equals(result.status, 'denied');
94 callback();
95 }).catch(function() {
96 assert_unreached('querying notifications permission should not f ail.')
97 });
98 });
99 }
100 }];
101
102 function runTest(i) {
103 tests[i].test.step(function() {
104 tests[i].fn(function() {
105 tests[i].test.done();
106 if (i + 1 < tests.length) {
107 runTest(i + 1);
108 } else {
109 done();
mlamouri (slow - plz ping) 2015/07/21 10:53:29 In other tests done() is run when the test file is
Lalit Maganti 2015/07/21 16:10:30 As discussed offline.
110 }
111 });
112 });
113 }
114 runTest(0);
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/permissions/chromium/test-revoke-sharedworker.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698