libservo: Flesh out permissions API (#35396)

- Update the script crate to better reflect the modern Permission
  specifcation -- removing the necessity for an `Insecure` variant of
  the permissions prompt.
- Have all allow/deny type requests in the internal API use an
  `AllowOrDeny` enum for clarity.
- Expose `PermissionsRequest` and `PermissionFeature` data types to the
  API and use them in the delegate method.
- Update both servoshell implementations to use the API.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2025-02-10 16:50:33 +01:00 committed by GitHub
parent b72932bc88
commit f51a5661f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 211 additions and 207 deletions

View file

@ -81,7 +81,9 @@ use crate::dom::bindings::codegen::Bindings::ImageBitmapBinding::{
};
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
use crate::dom::bindings::codegen::Bindings::PerformanceBinding::Performance_Binding::PerformanceMethods;
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState;
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::{
PermissionName, PermissionState,
};
use crate::dom::bindings::codegen::Bindings::VoidFunctionBinding::VoidFunction;
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use crate::dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScopeMethods;
@ -273,7 +275,7 @@ pub(crate) struct GlobalScope {
creation_url: Option<ServoUrl>,
/// A map for storing the previous permission state read results.
permission_state_invocation_results: DomRefCell<HashMap<String, PermissionState>>,
permission_state_invocation_results: DomRefCell<HashMap<PermissionName, PermissionState>>,
/// The microtask queue associated with this global.
///
@ -1965,7 +1967,7 @@ impl GlobalScope {
pub(crate) fn permission_state_invocation_results(
&self,
) -> &DomRefCell<HashMap<String, PermissionState>> {
) -> &DomRefCell<HashMap<PermissionName, PermissionState>> {
&self.permission_state_invocation_results
}
@ -2918,7 +2920,12 @@ impl GlobalScope {
self.https_state.set(https_state);
}
/// <https://html.spec.whatwg.org/multipage/#secure-context>
pub(crate) fn is_secure_context(&self) -> bool {
// This differs from the specification, but it seems that
// `inherited_secure_context` implements more-or-less the exact same logic, in a
// different manner. Workers inherit whether or not their in a secure context and
// worklets do as well (they can only be created in secure contexts).
if Some(false) == self.inherited_secure_context {
return false;
}