aggregatable-debug-report.sub.https.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!doctype html>
  2. <meta charset=utf-8>
  3. <meta name=timeout content=long>
  4. <script src="/resources/testharness.js"></script>
  5. <script src="/resources/testharnessreport.js"></script>
  6. <script src="resources/helpers.js"></script>
  7. <script>
  8. attribution_reporting_promise_test(async t => {
  9. const cookie = 'ar_debug=1;Secure;HttpOnly;SameSite=None;Path=/';
  10. const source_debug_key = '246';
  11. const trigger_debug_key = '357';
  12. await registerAttributionSrc(t, {
  13. source: {
  14. destination: `https://{{host}}`,
  15. aggregation_keys: {
  16. campaignCounts: "0x159",
  17. geoValue: "0x5",
  18. },
  19. debug_key: source_debug_key,
  20. },
  21. cookie,
  22. });
  23. await registerAttributionSrc(t, {
  24. trigger: {
  25. debug_key: trigger_debug_key,
  26. aggregatable_trigger_data: [
  27. {
  28. key_piece: '0x400',
  29. source_keys: ['campaignCounts'],
  30. },
  31. {
  32. key_piece: '0xA80',
  33. source_keys: ['geoValue', 'nonMatchingKey'],
  34. }
  35. ],
  36. aggregatable_values: {
  37. campaignCounts: 32768,
  38. geoValue: 1664,
  39. },
  40. },
  41. cookie,
  42. });
  43. const payload = await pollAggregatableReports();
  44. assert_equals(payload.reports.length, 1);
  45. const report = JSON.parse(payload.reports[0].body);
  46. assert_equals(report.source_debug_key, source_debug_key);
  47. assert_equals(report.trigger_debug_key, trigger_debug_key);
  48. const shared_info = JSON.parse(report.shared_info);
  49. assert_own_property(shared_info, 'debug_mode');
  50. assert_equals(shared_info.debug_mode, 'enabled');
  51. const aggregation_service_payload = report.aggregation_service_payloads[0];
  52. assert_own_property(aggregation_service_payload, 'debug_cleartext_payload');
  53. const debugPayload = await pollAggregatableDebugReports();
  54. assert_equals(debugPayload.reports.length, 1);
  55. const debugReport = JSON.parse(debugPayload.reports[0].body);
  56. assert_equals(debugReport.source_debug_key, source_debug_key);
  57. assert_equals(debugReport.trigger_debug_key, trigger_debug_key);
  58. const debug_shared_info = JSON.parse(debugReport.shared_info);
  59. assert_own_property(debug_shared_info, 'debug_mode');
  60. assert_equals(debug_shared_info.debug_mode, 'enabled');
  61. const debug_aggregation_service_payload = debugReport.aggregation_service_payloads[0];
  62. assert_own_property(debug_aggregation_service_payload, 'debug_cleartext_payload');
  63. }, 'Debug report is received if source and trigger debug keys are set.');
  64. </script>