From ae2d83e3b5019f56127ea44feaf3e5cc021fd3c1 Mon Sep 17 00:00:00 2001 From: Yao Xiao Date: Wed, 16 Oct 2024 10:26:29 -0700 Subject: [PATCH] [shared storage] Implement interestGroup() Add interestGroups() to the shared storage worklet, to return the Protected Audience interest groups associated with the shared storage origin's owner, with some additional metadata. Implement this behind a runtime feature, which is implicitly controlled by a Finch flag. Explainer PR: https://github.com/WICG/shared-storage/pull/180 Spec PR(s): 1) https://github.com/WICG/turtledove/pull/1299 2) https://github.com/WICG/shared-storage/pull/203 Bug: 367992703 Binary-Size: Size increase is unavoidable. Fuchsia-Binary-Size: Size increase is unavoidable. Change-Id: I5fc5767fa53a91f021d64a871a6dd9cb88f4431c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5696046 Reviewed-by: Daniel Cheng Commit-Queue: Yao Xiao Cr-Commit-Position: refs/heads/main@{#1369483} --- .../interest-groups.tentative.https.sub.html | 41 +++++++++++++++++++ shared-storage/resources/simple-module.js | 27 ++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 shared-storage/interest-groups.tentative.https.sub.html diff --git a/shared-storage/interest-groups.tentative.https.sub.html b/shared-storage/interest-groups.tentative.https.sub.html new file mode 100644 index 00000000000000..2889500be232ee --- /dev/null +++ b/shared-storage/interest-groups.tentative.https.sub.html @@ -0,0 +1,41 @@ + + + + + + + + + + diff --git a/shared-storage/resources/simple-module.js b/shared-storage/resources/simple-module.js index 11b650811dcc9c..2c241476421926 100644 --- a/shared-storage/resources/simple-module.js +++ b/shared-storage/resources/simple-module.js @@ -50,8 +50,35 @@ class VerifyKeyNotFound { } } +class VerifyInterestGroups { + async run(urls, data) { + if (data && + data.hasOwnProperty('expectedOwner') && + data.hasOwnProperty('expectedName')) { + + const groups = await interestGroups(); + + if (groups.length !== 1) { + return -1; + } + + if (groups[0]["owner"] !== data['expectedOwner']) { + return -1; + } + + if (groups[0]["name"] !== data['expectedName']) { + return -1; + } + + return 1; + } + return -1; + } +} + register('test-url-selection-operation', TestURLSelectionOperation); register('increment-global-variable-and-return-original-value-operation', IncrementGlobalVariableAndReturnOriginalValueOperation); register('verify-key-value', VerifyKeyValue); register('verify-key-not-found', VerifyKeyNotFound); +register('verify-interest-groups', VerifyInterestGroups);