<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<meta name="variant" content="?input=filters_implicit_matching_event_source_type">
<meta name="variant" content="?input=filters_implicit_matching_navigation_source_type">
<meta name="variant" content="?input=filters_empty_filter_data">
<meta name="variant" content="?input=filters_single_filter_with_multiple_values">
<meta name="variant" content="?input=filters_multiple_filters">
<meta name="variant" content="?input=filters_no_matching">
<meta name="variant" content="?input=filters_lookback_window">
<meta name="variant" content="?input=not_filters_implicit_matching_event_source_type">
<meta name="variant" content="?input=not_filters_implicit_matching_navigation_source_type">
<meta name="variant" content="?input=not_filters_empty_filter_data">
<meta name="variant" content="?input=not_filters_single_filter_with_multiple_values">
<meta name="variant" content="?input=not_filters_multiple_filters">
<meta name="variant" content="?input=not_filters_no_matching">
<meta name="variant" content="?input=combination">
<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/event_level_trigger_filter_data/${input}.json`)
.then((response) => response.json());
const source = {
source_event_id: generateSourceEventId(),
debug_reporting: true,
destination: 'https://{{host}}',
filter_data: inputJSON.source_filter_data,
};
registerAttributionSrc({
source,
method: inputJSON.method === undefined ? 'open' : inputJSON.method,
cookie: attributionDebugCookie,
});
await waitForSourceToBeRegistered(source.source_event_id);
// We wait 2s to test that a trigger with a 1s lookback_window is not going
// to match.
if (input === 'filters_lookback_window') {
await new Promise(resolve => setTimeout(resolve, 2000));
}
registerAttributionSrc({
trigger: {
event_trigger_data: inputJSON.event_trigger_data,
debug_reporting: inputJSON.debug_reporting,
},
cookie: inputJSON.cookie,
});
if (inputJSON.expected_trigger_data) {
const payload = await pollEventLevelReports();
assert_equals(payload.reports.length, 1);
const report = JSON.parse(payload.reports[0].body);
assert_equals(report.trigger_data, inputJSON.expected_trigger_data);
return;
}
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-no-matching-configurations');
}, 'Event level trigger filter data');
</script>