chromium/third_party/blink/web_tests/wpt_internal/attribution-reporting/aggregatable-debug-report.sub.https.html

<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<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 expectedSourceDebugKey = '246';
  const expectedTriggerDebugKey = '357';

  registerAttributionSrcByImg(createRedirectChain([
    {
      cookie: attributionDebugCookie,
      source: {
        aggregation_keys: {
          campaignCounts: '0x159',
          geoValue: '0x5',
        },
        debug_key: expectedSourceDebugKey,
        destination: 'https://{{host}}',
      },
    },
    {
      trigger: {
        aggregatable_trigger_data: [
          {
            key_piece: '0x400',
            source_keys: ['campaignCounts'],
          },
          {
            key_piece: '0xA80',
            source_keys: ['geoValue', 'nonMatchingKey'],
          }
        ],
        aggregatable_values: {
          campaignCounts: 32768,
          geoValue: 1664,
        },
        debug_key: expectedTriggerDebugKey,
      },
    },
  ]));

  const payload = await pollAggregatableReports();
  assert_equals(payload.reports.length, 1);
  const report = JSON.parse(payload.reports[0].body);
  assert_equals(report.source_debug_key, expectedSourceDebugKey);
  assert_equals(report.trigger_debug_key, expectedTriggerDebugKey);
  const shared_info = JSON.parse(report.shared_info);
  assert_own_property(shared_info, 'debug_mode');
  assert_equals(shared_info.debug_mode, 'enabled');
  const aggregation_service_payload = report.aggregation_service_payloads[0];
  assert_own_property(aggregation_service_payload, 'debug_cleartext_payload');

  const debugPayload = await pollAttributionSuccessDebugAggregatableReports();
  assert_equals(debugPayload.reports.length, 1);
  const debugReport = JSON.parse(debugPayload.reports[0].body);
  assert_equals(debugReport.source_debug_key, expectedSourceDebugKey);
  assert_equals(debugReport.trigger_debug_key, expectedTriggerDebugKey);
  const debug_shared_info = JSON.parse(debugReport.shared_info);
  assert_own_property(debug_shared_info, 'debug_mode');
  assert_equals(debug_shared_info.debug_mode, 'enabled');
  const debug_aggregation_service_payload = debugReport.aggregation_service_payloads[0];
  assert_own_property(debug_aggregation_service_payload, 'debug_cleartext_payload');
}, 'Debug report is received if source and trigger debug keys are set.');
</script>