Skip to content

Commit a20793d

Browse files
yaoxiachromiummoz-wptsync-bot
authored andcommitted
Bug 1925059 [wpt PR 48650] - [shared storage] Implement interestGroup(), a=testonly
Automatic update from web-platform-tests [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: WICG/shared-storage#180 Spec PR(s): 1) WICG/turtledove#1299 2) WICG/shared-storage#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 <dcheng@chromium.org> Commit-Queue: Yao Xiao <yaoxia@chromium.org> Cr-Commit-Position: refs/heads/main@{#1369483} -- wpt-commits: eb87bbbacf996ab46607538a72ea0adaee229e7a wpt-pr: 48650
1 parent 19fc588 commit a20793d

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!doctype html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<script src="/common/utils.js"></script>
5+
<script src="/shared-storage/resources/util.js"></script>
6+
<script src="/fenced-frame/resources/utils.js"></script>
7+
8+
<body>
9+
<script>
10+
'use strict';
11+
12+
promise_test(async t => {
13+
const ig = {
14+
owner: window.location.origin,
15+
name: 'default name',
16+
lifetimeMs: 100000
17+
};
18+
19+
await navigator.joinAdInterestGroup(ig);
20+
await sharedStorage.worklet.addModule('resources/simple-module.js');
21+
22+
const ancestor_key = token();
23+
let url0 = generateURL("/shared-storage/resources/frame0.html",
24+
[ancestor_key]);
25+
let url1 = generateURL("/shared-storage/resources/frame1.html",
26+
[ancestor_key]);
27+
28+
let select_url_result = await sharedStorage.selectURL(
29+
"verify-interest-groups", [{url: url0}, {url: url1}],
30+
{data: {'expectedOwner': ig.owner, 'expectedName': ig.name},
31+
resolveToConfig: true});
32+
assert_true(validateSelectURLResult(select_url_result, true));
33+
attachFencedFrame(select_url_result, 'opaque-ads');
34+
const result = await nextValueFromServer(ancestor_key);
35+
36+
// This indicates that `interestGroups()` returns expected result.
37+
assert_equals(result, "frame1_loaded");
38+
}, 'Basic test for `interestGroups()` in the shared storage worklet');
39+
40+
</script>
41+
</body>

testing/web-platform/tests/shared-storage/resources/simple-module.js

+27
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,35 @@ class VerifyKeyNotFound {
5050
}
5151
}
5252

53+
class VerifyInterestGroups {
54+
async run(urls, data) {
55+
if (data &&
56+
data.hasOwnProperty('expectedOwner') &&
57+
data.hasOwnProperty('expectedName')) {
58+
59+
const groups = await interestGroups();
60+
61+
if (groups.length !== 1) {
62+
return -1;
63+
}
64+
65+
if (groups[0]["owner"] !== data['expectedOwner']) {
66+
return -1;
67+
}
68+
69+
if (groups[0]["name"] !== data['expectedName']) {
70+
return -1;
71+
}
72+
73+
return 1;
74+
}
75+
return -1;
76+
}
77+
}
78+
5379
register('test-url-selection-operation', TestURLSelectionOperation);
5480
register('increment-global-variable-and-return-original-value-operation',
5581
IncrementGlobalVariableAndReturnOriginalValueOperation);
5682
register('verify-key-value', VerifyKeyValue);
5783
register('verify-key-not-found', VerifyKeyNotFound);
84+
register('verify-interest-groups', VerifyInterestGroups);

0 commit comments

Comments
 (0)