// This is a helper file used for the attribution-reporting-*.https.html tests.
// To use this, make sure you import these scripts:
//
//
//
//
//
//
async function runDefaultEnabledFeaturesTest(t, should_load, fenced_origin,
generator_api="fledge", allow="") {
const fencedframe = await attachFencedFrameContext({
generator_api: generator_api,
attributes: [["allow", allow]],
origin: fenced_origin});
if (!should_load) {
const fencedframe_blocked = new Promise(r => t.step_timeout(r, 1000));
const fencedframe_loaded = fencedframe.execute(() => {});
assert_equals(await Promise.any([
fencedframe_blocked.then(() => "blocked"),
fencedframe_loaded.then(() => "loaded"),
]), "blocked", "The fenced frame should not be loaded.");
return;
}
await fencedframe.execute((generator_api) => {
assert_true(
document.featurePolicy.allowsFeature('attribution-reporting'),
"Attribution reporting should be allowed if the fenced " +
"frame loaded using FLEDGE or shared storage.");
if (generator_api == "fledge") {
assert_true(
document.featurePolicy.allowsFeature('shared-storage'),
"Shared Storage should be allowed if the fenced " +
"frame loaded using FLEDGE.");
assert_true(
document.featurePolicy.allowsFeature('private-aggregation'),
"Private Aggregation should be allowed if the fenced " +
"frame loaded using FLEDGE.");
} else {
assert_true(
document.featurePolicy.allowsFeature('shared-storage'),
"Shared Storage should be allowed if the fenced " +
"frame loaded using Shared Storage.");
assert_false(
document.featurePolicy.allowsFeature('private-aggregation'),
"Private Aggregation should be disabled if the fenced " +
"frame loaded using Shared Storage.");
}
}, [generator_api]);
}