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

Unified Diff: LayoutTests/resources/permissions-helper.js

Issue 1305043004: Add permissions helper class to carry out promise based testing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix comments on review Created 5 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/resources/permissions-helper.js
diff --git a/LayoutTests/resources/permissions-helper.js b/LayoutTests/resources/permissions-helper.js
new file mode 100644
index 0000000000000000000000000000000000000000..ed978dfc59c38ff26651b21b80a09bbd67116c30
--- /dev/null
+++ b/LayoutTests/resources/permissions-helper.js
@@ -0,0 +1,38 @@
+var PermissionsHelper = (function() {
+ function nameToObject(permissionName) {
+ switch (permissionName) {
+ case "midi":
+ return {name: "midi"}
mlamouri (slow - plz ping) 2015/08/22 10:19:29 nit: add ; same for all the following return stat
Lalit Maganti 2015/08/24 09:18:23 Done.
+ case "midi-sysex":
+ return {name: "midi", sysex: true}
+ case "push-messaging":
+ return {name: "push", userVisibleOnly: true}
+ case "notifications":
+ return {name: "notifications"}
+ case "geolocation":
+ return {name: "geolocation"}
+ default:
+ throw "Invalid "
mlamouri (slow - plz ping) 2015/08/22 10:19:29 nit: could you throw something that would be more
Lalit Maganti 2015/08/24 09:18:23 I really shouldn't write CLs late on Friday :) Do
+ }
+ }
+
+ return {
+ setPermission: function(name, state) {
+ return new Promise(function(resolver, reject) {
+ navigator.permissions.query(nameToObject(name)).then(function(result) {
+ if (result.state == state) {
+ resolver()
+ return;
+ }
+
+ result.onchange = function() {
+ result.onchange = null;
+ resolver();
+ };
+
+ testRunner.setPermission(name, state, location.origin, location.origin);
+ });
+ });
+ }
+ }
+})();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698