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

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 up issues 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 function permissionNameToPermissionObject(permissionName) {
mlamouri (slow - plz ping) 2015/08/21 17:15:23 It would be good if we could make sure this is not
Lalit Maganti 2015/08/21 18:30:19 Done.
2 switch (permissionName) {
3 case "midi":
4 return {name: "midi"}
5 case "midi-sysex":
6 return {name: "midi", sysex: true}
7 case "push-messaging":
8 return {name: "push", userVisibleOnly: true}
9 case "notifications":
10 return {name: "midi"}
mlamouri (slow - plz ping) 2015/08/21 17:15:23 midi?
Lalit Maganti 2015/08/21 18:30:19 Done.
11 case "geolocation":
12 return {name: "geolocation", sysex: true}
mlamouri (slow - plz ping) 2015/08/21 17:15:23 sysex?
Lalit Maganti 2015/08/21 18:30:19 Done.
13 case "protected-media-identifier":
14 default:
15 // We can't deal with these two yet.
mlamouri (slow - plz ping) 2015/08/21 17:15:23 These 'two'?
Lalit Maganti 2015/08/21 18:30:19 Done.
16 return {name: "midi"}
mlamouri (slow - plz ping) 2015/08/21 17:15:23 Can you actually throw in that case?
Lalit Maganti 2015/08/21 18:30:19 Done.
17 }
18 }
19
20 function setPermission(testRunner, permissionName, newState) {
mlamouri (slow - plz ping) 2015/08/21 17:15:23 Can we use testRunner directly instead of taking i
Lalit Maganti 2015/08/21 18:30:19 Done.
21 return new Promise(function(resolver, reject) {
22 navigator.permissions.query(permissionNameToPermissionObject(permissionName) ).then(function(result) {
23 if (result.state == newState) {
24 resolver()
25 return;
26 }
27
28 result.onchange = function() {
29 result.onchange = null;
30 resolver();
31 };
32
33 testRunner.setPermission(permissionName, newState, location.origin, loca tion.origin);
34 });
35 });
36 }
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