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

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

Issue 1248703002: blink: permissions: add tests for request (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@permissions-request
Patch Set: Fix tests 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
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 PermissionDescription WebIDL rules in ' + get_current _scope() + ' scope.'),
14 fn: function(callback) {
15 // Requesting a random permission name should fail.
16 navigator.permissions.request({name:'foobar'}).then(function(result) {
17 assert_unreached('requesting a random permission should fail');
18 callback();
mlamouri (slow - plz ping) 2015/07/24 14:31:12 Can you call throw and pass the message then at th
Lalit Maganti 2015/07/30 10:10:14 Done.
19 }, function(error) {
20 assert_equals(error.name, 'TypeError');
21
22 // Querying a permission without a name should fail.
23 return navigator.permissions.request({});
24 }).then(function(result) {
25 assert_unreached('requesting a permission without a name should fail ');
26 callback();
27 }, function(error) {
28 assert_equals(error.name, 'TypeError');
29 callback();
30 });
31 }
32 },
33 {
34 test: async_test('Test geolocation permission in ' + get_current_scope() + ' scope.'),
mlamouri (slow - plz ping) 2015/07/24 14:31:12 'Test basic request behaviour in [...] And add a
Lalit Maganti 2015/07/30 10:10:14 Done.
35 fn: function(callback) {
36 navigator.permissions.request({name:'geolocation'}).then(function(result) {
37 assert_true(result instanceof PermissionStatus);
38 assert_equals(result.state, 'denied');
39
40 result.onchange = function() {
41 assert_equals(result.state, 'granted');
42
43 navigator.permissions.request({name:'geolocation'}).then(function( ) {
44 assert_true(result instanceof PermissionStatus);
45 assert_equals(result.state, 'granted');
46 callback();
47 }).catch(function() {
48 assert_unreached('requesting geolocation permission should not fail.')
49 callback();
50 });
51 };
52
53 setPermission('geolocation', 'granted', location.origin, location.orig in)
54 }).catch(function() {
55 assert_unreached('requesting geolocation permission should not fail.')
56 callback();
57 });
58 }
59 }];
60
61 function runTest(i) {
62 tests[i].test.step(function() {
63 tests[i].fn(function() {
64 tests[i].test.done();
65 if (i + 1 < tests.length) {
66 runTest(i + 1);
67 } else {
68 done();
69 }
70 });
71 });
72 }
73 runTest(0);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698