fix(permissions): make profile snapshots authoritative
This commit is contained in:
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::ServoLiveSitePermission;
|
||||
|
||||
pub(super) const LIVE_PROTOCOL_VERSION: u32 = 2;
|
||||
pub(super) const LIVE_PROTOCOL_VERSION: u32 = 3;
|
||||
pub(super) const MAX_FRAME_DIMENSION: u32 = 16_384;
|
||||
pub(super) const MAX_FRAME_BYTE_COUNT: usize = 256 * 1024 * 1024;
|
||||
|
||||
@@ -29,6 +29,7 @@ pub(super) enum LiveRequest {
|
||||
hover_x: Option<u32>,
|
||||
hover_y: Option<u32>,
|
||||
typed_text: Option<String>,
|
||||
site_permission_generation: u64,
|
||||
site_permissions: Vec<ServoLiveSitePermission>,
|
||||
ready_surface_ids: Vec<u64>,
|
||||
pending_surface_ids: Vec<u64>,
|
||||
@@ -54,6 +55,16 @@ pub(super) struct LiveResponse {
|
||||
pub(super) surface_handle: Option<LiveSurfaceHandle>,
|
||||
#[serde(default)]
|
||||
pub(super) current_surface_id: Option<u64>,
|
||||
#[serde(default)]
|
||||
pub(super) permission_consumptions: Vec<LivePermissionConsumption>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub(super) struct LivePermissionConsumption {
|
||||
pub(super) profile_id: String,
|
||||
pub(super) origin: String,
|
||||
pub(super) feature: String,
|
||||
pub(super) grant_revision: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize)]
|
||||
@@ -98,7 +109,7 @@ fn default_device_pixel_ratio() -> f32 {
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
|
||||
use super::{LIVE_PROTOCOL_VERSION, LiveRequest};
|
||||
use super::{LIVE_PROTOCOL_VERSION, LiveRequest, ServoLiveSitePermission};
|
||||
|
||||
#[test]
|
||||
fn handshake_request_serializes_protocol_version() -> Result<(), serde_json::Error> {
|
||||
@@ -138,4 +149,21 @@ mod tests {
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn site_permission_serializes_revision() -> Result<(), serde_json::Error> {
|
||||
let permission =
|
||||
ServoLiveSitePermission::new("https://example.com", "camera", "allow-once", 7);
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_value(permission)?,
|
||||
json!({
|
||||
"origin": "https://example.com",
|
||||
"feature": "camera",
|
||||
"state": "allow-once",
|
||||
"revision": 7,
|
||||
}),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user