<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<meta name="variant" content="?input=no_keys">
<meta name="variant" content="?input=filters_match">
<meta name="variant" content="?input=filters_not_match">
<meta name="variant" content="?input=negated_filters_match">
<meta name="variant" content="?input=negated_filters_not_match">
<meta name="variant" content="?input=different_deduplication_key">
<meta name="variant" content="?input=null_deduplication_key">
<meta name="variant" content="?input=multiple_deduplication_keys">
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/attribution-reporting/resources/helpers.js"></script>
<script>
attribution_reporting_promise_test(async t => {
const searchParams = new URLSearchParams(location.search);
const input = searchParams.get('input');
const inputJSON =
await fetch(`resources/aggregatable_deduplication_keys/${input}.json`)
.then((response) => response.json());
const host = 'https://{{host}}';
const source = {
source_event_id: generateSourceEventId(),
destination: host,
aggregation_keys: {
campaignCounts: '0x159',
},
debug_key: '456',
filter_data: {
'x': ['y', 'z'],
}
};
const trigger = {
aggregatable_trigger_data: [{
key_piece: '0x400',
source_keys: ['campaignCounts'],
}],
aggregatable_values: {
campaignCounts: 32768,
},
aggregatable_deduplication_keys: [{
'deduplication_key': '666',
}],
debug_reporting: true,
};
registerAttributionSrcByImg(createRedirectChain([
{ source, cookie: attributionDebugCookie },
{ trigger },
]));
const payload = await pollAggregatableReports();
assert_equals(payload.reports.length, 1);
const report = JSON.parse(payload.reports[0].body);
assert_own_property(report, 'shared_info');
const shared_info = JSON.parse(report.shared_info);
assert_equals(shared_info.attribution_destination, host);
trigger.aggregatable_deduplication_keys = inputJSON.aggregatable_deduplication_keys;
registerAttributionSrc({
trigger,
cookie: attributionDebugCookie,
});
if (inputJSON.expect_deduplicated) {
const debugPayload = await pollVerboseDebugReports();
assert_equals(debugPayload.reports.length, 1);
const debugReport = JSON.parse(debugPayload.reports[0].body);
assert_equals(debugReport.length, 1);
assert_equals(debugReport[0].type, 'trigger-aggregate-deduplicated');
assert_own_property(debugReport[0], 'body');
const debugReportBody = debugReport[0].body;
assert_equals(debugReportBody.attribution_destination, host);
assert_equals(debugReportBody.source_event_id, source.source_event_id);
assert_equals(debugReportBody.source_site, host);
assert_equals(debugReportBody.source_debug_key, '456');
assert_not_own_property(debugReportBody, 'trigger_debug_key');
return;
}
const payload2 = await pollAggregatableReports();
assert_equals(payload2.reports.length, 1);
}, 'Aggregatable deduplication keys');
</script>