<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<meta name="variant" content="?input=valid_cookie">
<meta name="variant" content="?input=valid_cookie&source_only">
<meta name="variant" content="?input=valid_cookie&trigger_only">
<meta name="variant" content="?input=missing_cookie">
<meta name="variant" content="?input=cookie_without_secure">
<meta name="variant" content="?input=cookie_without_httponly">
<meta name="variant" content="?input=cookie_without_samesite">
<meta name="variant" content="?input=cookie_with_narrow_path">
<meta name="variant" content="?input=field_with_wrong_type">
<meta name="variant" content="?input=field_with_invalid_format">
<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/debug_key/${input}.json`)
.then((response) => response.json());
const forSourceOnly = searchParams.get('source_only') !== null;
const forTriggerOnly = searchParams.get('trigger_only') !== null;
registerAttributionSrcByImg(createRedirectChain([
{
cookie: inputJSON.cookie,
source: {
debug_key: forTriggerOnly ? undefined : inputJSON.debug_key,
destination: 'https://{{host}}',
},
},
{
trigger: {
debug_key: forSourceOnly ? undefined : inputJSON.debug_key,
event_trigger_data: [{}],
},
},
]));
const payload = await pollEventLevelReports();
assert_equals(payload.reports.length, 1);
const report = JSON.parse(payload.reports[0].body);
if (forSourceOnly || forTriggerOnly || !inputJSON.key_expected) {
assert_not_own_property(report, 'source_debug_key');
assert_not_own_property(report, 'trigger_debug_key');
} else {
assert_equals(report['source_debug_key'], inputJSON.debug_key);
assert_equals(report['trigger_debug_key'], inputJSON.debug_key);
}
}, 'Debug keys');
</script>