simple-aggregatable-report.sub.https.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 source = {
  10. destination: `https://{{host}}`,
  11. aggregation_keys: {
  12. campaignCounts: "0x159",
  13. geoValue: "0x5",
  14. }
  15. };
  16. const trigger = {
  17. aggregatable_trigger_data: [
  18. {
  19. key_piece: '0x400',
  20. source_keys: ['campaignCounts'],
  21. },
  22. {
  23. key_piece: '0xA80',
  24. source_keys: ['geoValue', 'nonMatchingKey'],
  25. }
  26. ],
  27. aggregatable_values: {
  28. campaignCounts: 32768,
  29. geoValue: 1664,
  30. },
  31. };
  32. await registerAttributionSrc(t, {source, cookie: 'foo=bar;Secure;HttpOnly;Path=/'});
  33. await registerAttributionSrc(t, {trigger});
  34. const payload = await pollAggregatableReports();
  35. assert_equals(payload.reports.length, 1);
  36. const report = JSON.parse(payload.reports[0].body);
  37. const headers = payload.reports[0].headers;
  38. assert_own_property(report, 'shared_info');
  39. const shared_info = JSON.parse(report.shared_info);
  40. assert_own_property(shared_info, 'api');
  41. assert_equals(shared_info.api, 'attribution-reporting');
  42. assert_own_property(shared_info, 'report_id');
  43. assert_own_property(shared_info, 'reporting_origin');
  44. assert_own_property(shared_info, 'scheduled_report_time');
  45. assert_own_property(shared_info, 'version');
  46. assert_own_property(shared_info, 'attribution_destination');
  47. assert_equals(shared_info.attribution_destination, source.destination);
  48. assert_not_own_property(report, 'source_debug_key');
  49. assert_not_own_property(report, 'trigger_debug_key');
  50. assert_own_property(report, 'aggregation_service_payloads');
  51. assert_equals(report.aggregation_service_payloads.length, 1);
  52. const aggregation_service_payload = report.aggregation_service_payloads[0];
  53. assert_own_property(aggregation_service_payload, 'payload');
  54. assert_own_property(aggregation_service_payload, 'key_id');
  55. assert_not_own_property(aggregation_service_payload, 'debug_cleartext_payload');
  56. validateReportHeaders(headers);
  57. }, 'Ensure aggregatable attribution report is received.');
  58. </script>