chromium/third_party/blink/web_tests/wpt_internal/attribution-reporting/support-header.sub.https.html

<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<meta name=variant content="?method=a&expected-support=web">
<meta name=variant content="?method=img&expected-support=web">
<meta name=variant content="?method=img&eligible&expected-support=web">
<meta name=variant content="?method=open&expected-support=web">
<meta name=variant content="?method=script&expected-support=web">
<meta name=variant content="?method=script&expected-eligible=event-source, trigger&expected-support=web">
<meta name=variant content="?method=fetch">
<meta name=variant content='?method=fetch&eligible={"eventSourceEligible":true,"triggerEligible":false}&expected-support=web'>
<meta name=variant content="?method=xhr">
<meta name=variant content='?method=xhr&eligible={"eventSourceEligible":true,"triggerEligible":false}&expected-support=web'>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/attribution-reporting/resources/helpers.js"></script>
<body>
<script>
const waitForRequest = async () => {
  const url = blankURL();
  url.searchParams.set('get-requests', 'true');

  for (let i = 0; i < 20; i++) {
    const resp = await fetch(url);
    const payload = await resp.json();
    if (payload !== null && payload.length > 0) {
      return payload;
    }
    await delay(100);
  }
  throw new Error('Timeout polling requests');
};

const searchParams = new URLSearchParams(location.search);
const expected_support =
    searchParams.get('expected-support') === null ? undefined : searchParams.get('expected-support');

promise_test(async t => {
  registerAttributionSrc({
    method: 'variant',
    extraQueryParams: {'store-request': 'true'},
  });

  const requests = await waitForRequest();
  assert_equals(requests.length, 1);

  // TODO(apaseltiner): Check header values once WPT can parse structured dictionaries.
  if (expected_support) {
    assert_own_property(requests[0], 'attribution-reporting-support');
  } else {
    assert_not_own_property(requests[0], 'attribution-reporting-support');
  }
}, 'attributionsrc request has the proper Attribution-Reporting-Support header.');
</script>