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

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

Issue 1306683007: Permissions API: remove deprecated PermissionStatus.status. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: moar test updates 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/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Querying a random permission name should fail. 11 // Querying a random permission name should fail.
12 navigator.permissions.query({name:'foobar'}).then(function(result) { 12 navigator.permissions.query({name:'foobar'}).then(function(result) {
13 assert_unreached('querying a random permission should fail'); 13 assert_unreached('querying a random permission should fail');
14 }, function(error) { 14 }, function(error) {
15 assert_equals(error.name, 'TypeError'); 15 assert_equals(error.name, 'TypeError');
16 16
17 // Querying a permission without a name should fail. 17 // Querying a permission without a name should fail.
18 return navigator.permissions.query({}); 18 return navigator.permissions.query({});
19 }).then(function(result) { 19 }).then(function(result) {
20 assert_unreached('querying a permission without a name should fail'); 20 assert_unreached('querying a permission without a name should fail');
21 }, function(error) { 21 }, function(error) {
22 assert_equals(error.name, 'TypeError'); 22 assert_equals(error.name, 'TypeError');
23 test.done(); 23 test.done();
24 }); 24 });
25 }, 'Test PermissionDescription WebIDL rules in ' + get_current_scope() + ' scope .'); 25 }, 'Test PermissionDescription WebIDL rules in ' + get_current_scope() + ' scope .');
26 26
27 async_test(function(test) { 27 async_test(function(test) {
28 navigator.permissions.query({name:'geolocation'}).then(function(result) { 28 navigator.permissions.query({name:'geolocation'}).then(function(result) {
29 assert_true(result instanceof PermissionStatus); 29 assert_true(result instanceof PermissionStatus);
30 assert_equals(result.status, 'denied'); 30 assert_equals(result.state, 'denied');
31 test.done(); 31 test.done();
32 }).catch(function() { 32 }).catch(function() {
33 assert_unreached('querying geolocation permission should not fail.') 33 assert_unreached('querying geolocation permission should not fail.')
34 }); 34 });
35 }, 'Test geolocation permission in ' + get_current_scope() + ' scope.'); 35 }, 'Test geolocation permission in ' + get_current_scope() + ' scope.');
36 36
37 async_test(function(test) { 37 async_test(function(test) {
38 navigator.permissions.query({name:'midi'}).then(function(result) { 38 navigator.permissions.query({name:'midi'}).then(function(result) {
39 assert_true(result instanceof PermissionStatus); 39 assert_true(result instanceof PermissionStatus);
40 assert_equals(result.status, 'denied'); 40 assert_equals(result.state, 'denied');
41 41
42 // Test for sysex=false. 42 // Test for sysex=false.
43 return navigator.permissions.query({name:'midi', sysex: false}); 43 return navigator.permissions.query({name:'midi', sysex: false});
44 }).then(function(result) { 44 }).then(function(result) {
45 assert_true(result instanceof PermissionStatus); 45 assert_true(result instanceof PermissionStatus);
46 assert_equals(result.status, 'denied'); 46 assert_equals(result.state, 'denied');
47 47
48 // Test for sysex=true. 48 // Test for sysex=true.
49 return navigator.permissions.query({name:'midi', sysex: true}); 49 return navigator.permissions.query({name:'midi', sysex: true});
50 }).then(function(result) { 50 }).then(function(result) {
51 assert_true(result instanceof PermissionStatus); 51 assert_true(result instanceof PermissionStatus);
52 assert_equals(result.status, 'denied'); 52 assert_equals(result.state, 'denied');
53 test.done(); 53 test.done();
54 }).catch(function() { 54 }).catch(function() {
55 assert_unreached('querying midi permission should not fail.') 55 assert_unreached('querying midi permission should not fail.')
56 }); 56 });
57 }, 'Test midi permission in ' + get_current_scope() + ' scope.'); 57 }, 'Test midi permission in ' + get_current_scope() + ' scope.');
58 58
59 async_test(function(test) { 59 async_test(function(test) {
60 navigator.permissions.query({name:'notifications'}).then(function(result) { 60 navigator.permissions.query({name:'notifications'}).then(function(result) {
61 assert_true(result instanceof PermissionStatus); 61 assert_true(result instanceof PermissionStatus);
62 assert_equals(result.status, 'denied'); 62 assert_equals(result.state, 'denied');
63 test.done(); 63 test.done();
64 }).catch(function() { 64 }).catch(function() {
65 assert_unreached('querying notifications permission should not fail.') 65 assert_unreached('querying notifications permission should not fail.')
66 }); 66 });
67 }, 'Test notifications permission in ' + get_current_scope() + ' scope.'); 67 }, 'Test notifications permission in ' + get_current_scope() + ' scope.');
68 68
69 async_test(function(test) { 69 async_test(function(test) {
70 navigator.permissions.query({name:'push'}).catch(function(e) { 70 navigator.permissions.query({name:'push'}).catch(function(e) {
71 // By default, the permission query is rejected if "userVisibleOnly" opt ion 71 // By default, the permission query is rejected if "userVisibleOnly" opt ion
72 // isn't set or set to true. 72 // isn't set or set to true.
73 assert_equals(e.name, "NotSupportedError"); 73 assert_equals(e.name, "NotSupportedError");
74 74
75 // Test for userVisibleOnly=false. 75 // Test for userVisibleOnly=false.
76 return navigator.permissions.query({name:'push', userVisibleOnly: false} ); 76 return navigator.permissions.query({name:'push', userVisibleOnly: false} );
77 }).catch(function(e) { 77 }).catch(function(e) {
78 // By default, the permission query is rejected if "userVisibleOnly" opt ion 78 // By default, the permission query is rejected if "userVisibleOnly" opt ion
79 // isn't set or set to true. 79 // isn't set or set to true.
80 assert_equals(e.name, "NotSupportedError"); 80 assert_equals(e.name, "NotSupportedError");
81 81
82 // Test for userVisibleOnly=true. 82 // Test for userVisibleOnly=true.
83 return navigator.permissions.query({name:'push', userVisibleOnly: true}) ; 83 return navigator.permissions.query({name:'push', userVisibleOnly: true}) ;
84 }).then(function(result) { 84 }).then(function(result) {
85 assert_true(result instanceof PermissionStatus); 85 assert_true(result instanceof PermissionStatus);
86 assert_equals(result.status, 'denied'); 86 assert_equals(result.state, 'denied');
87 test.done(); 87 test.done();
88 }).catch(function() { 88 }).catch(function() {
89 assert_unreached('querying push permission should not fail.') 89 assert_unreached('querying push permission should not fail.')
90 }); 90 });
91 }, 'Test push permission in ' + get_current_scope() + ' scope.'); 91 }, 'Test push permission in ' + get_current_scope() + ' scope.');
92 92
93 done(); 93 done();
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698