<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<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>
<body>
<script>
attribution_reporting_promise_test(async t => {
const source = {
source_event_id: generateSourceEventId(),
debug_reporting: true,
destination: 'https://{{host}}',
};
registerAttributionSrc({
cookie: attributionDebugCookie,
source,
method: 'a',
});
await waitForSourceToBeRegistered(source.source_event_id);
registerAttributionSrcByImg(createRedirectChain([
{trigger: {event_trigger_data: [{trigger_data: '3'}]}},
{trigger: {event_trigger_data: [{trigger_data: '4'}]}},
{trigger: {event_trigger_data: [{trigger_data: '5'}]}},
]));
const reports = [];
while (reports.length < 3) {
const payload = await pollEventLevelReports();
payload.reports.forEach(report => {
reports.push(JSON.parse(report.body));
});
}
assert_equals(reports.length, 3);
reports.sort((a, b) => {
if (a.trigger_data < b.trigger_data) return -1;
if (a.trigger_data > b.trigger_data) return 1;
return 0;
});
assert_equals(reports[0].trigger_data, '3');
assert_equals(reports[1].trigger_data, '4');
assert_equals(reports[2].trigger_data, '5');
registerAttributionSrc({
trigger: {
event_trigger_data: [{
trigger_data: '7'
}],
debug_reporting: true,
},
cookie: attributionDebugCookie,
});
const payload = await pollVerboseDebugReports();
assert_equals(payload.reports.length, 1);
const debugReport = JSON.parse(payload.reports[0].body);
assert_equals(debugReport.length, 1);
assert_equals(debugReport[0].type, 'trigger-event-excessive-reports');
assert_own_property(debugReport[0], 'body');
assert_equals(debugReport[0].body.trigger_data, '7');
}, 'Navigation sources can be attributed 3 times.');
</script>