chromium/third_party/blink/web_tests/wpt_internal/attribution-reporting/source-matching.sub.https.html

<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<meta name="variant" content="?expect-matched">
<meta name="variant" content="?destination=remote&expect-matched">
<meta name="variant" content="?destination=https%3A%2F%2Fexample.test">
<meta name="variant" content="?reporting-origin">
<script src="/common/get-host-info.sub.js"></script>
<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 remoteOrigin = get_host_info().HTTPS_REMOTE_ORIGIN;
  assert_not_equals(location.origin, remoteOrigin);

  const searchParams = new URLSearchParams(location.search);
  const destinationParam = searchParams.get('destination');
  const sourceDestination = destinationParam === null ? location.origin :
      (destinationParam === 'remote' ? remoteOrigin : destinationParam);
  const sourceReportingOrigin = searchParams.get('reporting-origin') === null ? location.origin : remoteOrigin;
  const expectMatched = searchParams.get('expect-matched') !== null;

  registerAttributionSrcByImg(createRedirectChain([
    {
      reportingOrigin: sourceReportingOrigin,
        source: {
        destination: sourceDestination,
      },
    },
    {
      cookie: attributionDebugCookie,
      trigger: {
        event_trigger_data: [{}],
        debug_reporting: true,
      },
    },
  ]));

  if (expectMatched) {
    const payload = await pollEventLevelReports();
    assert_equals(payload.reports.length, 1);
    return;
  }

  const payload = await pollVerboseDebugReports();
  assert_equals(payload.reports.length, 1);
  const debugReport = JSON.parse(payload.reports[0].body);
  assert_equals(debugReport.length, 1);
  assert_equals(debugReport[0].type, 'trigger-no-matching-source');
}, 'Source matching');
</script>