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

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

Issue 1045283002: Implement PermissionDescriptor usage in Permissions API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: no find copies Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/modules/modules.gypi » ('j') | Source/modules/permissions/MidiPermissionDescriptor.idl » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/permissions/resources/test-query.js
diff --git a/LayoutTests/http/tests/permissions/resources/test-query.js b/LayoutTests/http/tests/permissions/resources/test-query.js
index 62ee56427baf571d83752199149ec02446f45371..d3029901585fb5abddfc0037f53c2d12351cf71c 100644
--- a/LayoutTests/http/tests/permissions/resources/test-query.js
+++ b/LayoutTests/http/tests/permissions/resources/test-query.js
@@ -8,24 +8,63 @@ if (self.importScripts) {
}
async_test(function(test) {
- navigator.permissions.query('geolocation').then(function(result) {
- // TODO(mlamouri): test values when some instrumentation are done.
- assert_true(result instanceof PermissionStatus);
- test.done();
- }).catch(function() {
- assert_unreached('navigator.permissions.query() should not fail.')
- });
-}, 'Check the navigator.permissions.query() normal behavior in ' + get_current_scope() + ' scope.');
+ navigator.permissions.query({name:'geolocation'}).then(function(result) {
+ // TODO(mlamouri): test values when some instrumentation are available.
+ assert_true(result instanceof PermissionStatus);
+ test.done();
+ }).catch(function() {
+ assert_unreached('querying geolocation permission should not fail.')
+ });
+}, 'Test geolocation permission in ' + get_current_scope() + ' scope.');
+
+async_test(function(test) {
+ navigator.permissions.query({name:'midi'}).then(function(result) {
+ // By default, the permission is granted if "sysex" option isn't set or
+ // set to false.
+ assert_equals(result.status, "granted");
+ return navigator.permissions.query({name:'midi', sysex: false});
whywhat 2015/03/31 14:51:44 nit: add a blank line before each return to split
mlamouri (slow - plz ping) 2015/03/31 20:24:46 Done.
+ }).then(function(result) {
+ // By default, the permission is granted if "sysex" option isn't set or
+ // set to false.
+ assert_equals(result.status, "granted");
+ return navigator.permissions.query({name:'midi', sysex: true});
+ }).then(function(result) {
+ // TODO(mlamouri): test values when some instrumentation are available.
+ assert_true(result instanceof PermissionStatus);
+ test.done();
+ }).catch(function() {
+ assert_unreached('querying midi permission should not fail.')
+ });
+}, 'Test midi permission in ' + get_current_scope() + ' scope.');
+
+async_test(function(test) {
+ navigator.permissions.query({name:'notifications'}).then(function(result) {
+ // TODO(mlamouri): test values when some instrumentation are available.
+ assert_true(result instanceof PermissionStatus);
+ test.done();
+ }).catch(function() {
+ assert_unreached('querying notifications permission should not fail.')
+ });
+}, 'Test notifications permission in ' + get_current_scope() + ' scope.');
async_test(function(test) {
- navigator.permissions.query('unknown-keyword').then(function() {
- assert_unreached('navigator.permissions.query() should not succeed (for now).')
- }, function(e) {
- assert_true(e instanceof TypeError);
- assert_equals('TypeError', e.name);
- }).then(function() {
+ navigator.permissions.query({name:'push'}).then(function(result) {
+ // By default, the permission is rejected if "userVisible" option isn't
+ // set or set to true.
+ assert_equals(result.status, "denied");
+ return navigator.permissions.query({name:'push', userVisible: true});
+ }).then(function(result) {
+ // By default, the permission is rejected if "userVisible" option isn't
+ // set or set to true.
+ assert_equals(result.status, "denied");
+ return navigator.permissions.query({name:'push', userVisible: true});
+ }).then(function(result) {
+ // TODO(mlamouri): test values when some instrumentation are available.
+ assert_true(result instanceof PermissionStatus);
test.done();
+ }).catch(function() {
+ assert_unreached('querying push permission should not fail.')
});
-}, 'Check the navigator.permissions.query() with wrong keyword in ' + get_current_scope() + ' scope.');
+}, 'Test push permission in ' + get_current_scope() + ' scope.');
done();
« no previous file with comments | « no previous file | Source/modules/modules.gypi » ('j') | Source/modules/permissions/MidiPermissionDescriptor.idl » ('J')

Powered by Google App Engine
This is Rietveld 408576698