simple-event-level-report.sub.https.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. const uuidPattern = /^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;
  9. attribution_reporting_promise_test(async t => {
  10. const source = {
  11. source_event_id: '9153495207648170476',
  12. destination: `https://{{host}}`,
  13. };
  14. const trigger = {event_trigger_data: [{trigger_data: '2'}]};
  15. await registerAttributionSrc(t, {source, cookie: 'foo=bar;Secure;HttpOnly;Path=/'});
  16. await registerAttributionSrc(t, {trigger});
  17. const payload = await pollEventLevelReports();
  18. assert_equals(payload.reports.length, 1);
  19. const report = JSON.parse(payload.reports[0].body);
  20. // The trigger data is sanitized to "0" because event sources are limited to 1
  21. // bit.
  22. assert_equals(report.trigger_data, '0');
  23. assert_equals(report.source_event_id, source.source_event_id);
  24. assert_equals(report.source_type, 'event');
  25. assert_equals(report.attribution_destination, source.destination);
  26. assert_between_inclusive(report.randomized_trigger_rate, 0.0, 1.0);
  27. assert_own_property(report, 'report_id');
  28. assert_equals(typeof report.report_id, 'string');
  29. assert_regexp_match(report.report_id, uuidPattern);
  30. assert_not_own_property(report, 'source_debug_key');
  31. assert_not_own_property(report, 'trigger_debug_key');
  32. validateReportHeaders(payload.reports[0].headers);
  33. }, 'Ensure attribution report is received.');
  34. </script>