Permission API

This commit is contained in:
Attila Dusnoki 2017-01-30 11:29:04 +01:00
parent e394334739
commit 5ca3ee9474
10 changed files with 449 additions and 3 deletions

View file

@ -62,3 +62,9 @@ interface NavigatorCookies {
partial interface Navigator {
[SameObject, Pref="dom.webvr.enabled"] readonly attribute VR vr;
};
// https://w3c.github.io/permissions/#navigator-and-workernavigator-extension
[Exposed=(Window)]
partial interface Navigator {
readonly attribute Permissions permissions;
};

View file

@ -0,0 +1,47 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://w3c.github.io/permissions/#permissionstatus
dictionary PermissionDescriptor {
required PermissionName name;
};
enum PermissionState {
"granted",
"denied",
"prompt",
};
enum PermissionName {
"geolocation",
"notifications",
"push",
"midi",
"camera",
"microphone",
"speaker",
"device-info",
"background-sync",
"bluetooth",
"persistent-storage",
};
[Exposed=(Window,Worker)]
interface PermissionStatus : EventTarget {
readonly attribute PermissionState state;
attribute EventHandler onchange;
};
dictionary PushPermissionDescriptor : PermissionDescriptor {
boolean userVisibleOnly = false;
};
dictionary MidiPermissionDescriptor : PermissionDescriptor {
boolean sysex = false;
};
dictionary DevicePermissionDescriptor : PermissionDescriptor {
DOMString deviceId;
};

View file

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://w3c.github.io/permissions/#permissions-interface
[Exposed=(Window,Worker)]
interface Permissions {
Promise<PermissionStatus> query(object permissionDesc);
Promise<PermissionStatus> request(object permissionDesc);
Promise<PermissionStatus> revoke(object permissionDesc);
};

View file

@ -8,3 +8,10 @@ interface WorkerNavigator {};
WorkerNavigator implements NavigatorID;
WorkerNavigator implements NavigatorLanguage;
//WorkerNavigator implements NavigatorOnLine;
// https://w3c.github.io/permissions/#navigator-and-workernavigator-extension
[Exposed=(Worker)]
partial interface WorkerNavigator {
readonly attribute Permissions permissions;
};