mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Permission API
This commit is contained in:
parent
e394334739
commit
5ca3ee9474
10 changed files with 449 additions and 3 deletions
|
@ -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;
|
||||
};
|
||||
|
|
47
components/script/dom/webidls/PermissionStatus.webidl
Normal file
47
components/script/dom/webidls/PermissionStatus.webidl
Normal 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;
|
||||
};
|
14
components/script/dom/webidls/Permissions.webidl
Normal file
14
components/script/dom/webidls/Permissions.webidl
Normal 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);
|
||||
};
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue