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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 var PermissionsHelper = (function() {
2 function nameToObject(permissionName) {
3 switch (permissionName) {
4 case "midi":
5 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.
6 case "midi-sysex":
7 return {name: "midi", sysex: true}
8 case "push-messaging":
9 return {name: "push", userVisibleOnly: true}
10 case "notifications":
11 return {name: "notifications"}
12 case "geolocation":
13 return {name: "geolocation"}
14 default:
15 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
16 }
17 }
18
19 return {
20 setPermission: function(name, state) {
21 return new Promise(function(resolver, reject) {
22 navigator.permissions.query(nameToObject(name)).then(function(result) {
23 if (result.state == state) {
24 resolver()
25 return;
26 }
27
28 result.onchange = function() {
29 result.onchange = null;
30 resolver();
31 };
32
33 testRunner.setPermission(name, state, location.origin, location.orig in);
34 });
35 });
36 }
37 }
38 })();
OLDNEW
« 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