锁定桌面通知载荷截断契约
桌面通知单测覆盖共享长度边界截断 桌面壳配置检查反查通知截断测试
This commit is contained in:
@@ -2495,6 +2495,9 @@ for (const snippet of [
|
||||
'PermissionState::Prompt | PermissionState::PromptWithRationale',
|
||||
'desktop_notification_delivered_to_system_result',
|
||||
'json!({"action": HOST_BRIDGE_LOCAL_NOTIFICATION_DELIVERED_TO_SYSTEM_ACTION})',
|
||||
'local_notification_payload_truncates_to_shared_contract_limits',
|
||||
'"a".repeat(HOST_BRIDGE_LOCAL_NOTIFICATION_TITLE_MAX_LENGTH)',
|
||||
'"b".repeat(HOST_BRIDGE_LOCAL_NOTIFICATION_BODY_MAX_LENGTH)',
|
||||
'"notification permission denied"',
|
||||
'app.notification().builder()',
|
||||
]) {
|
||||
|
||||
@@ -158,6 +158,21 @@ mod tests {
|
||||
assert_eq!(body.as_deref(), Some("作品已准备好 可以试玩"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_notification_payload_truncates_to_shared_contract_limits() {
|
||||
let mut request = request("notification.showLocal");
|
||||
request.payload = Some(json!({
|
||||
"title": "a".repeat(90),
|
||||
"body": "b".repeat(250)
|
||||
}));
|
||||
|
||||
let (title, body) = local_notification_payload(&request).expect("payload");
|
||||
let expected_body = "b".repeat(HOST_BRIDGE_LOCAL_NOTIFICATION_BODY_MAX_LENGTH);
|
||||
|
||||
assert_eq!(title, "a".repeat(HOST_BRIDGE_LOCAL_NOTIFICATION_TITLE_MAX_LENGTH));
|
||||
assert_eq!(body.as_deref(), Some(expected_body.as_str()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_notification_success_result_reports_system_delivery() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user