<!DOCTYPE html>
<!--
This test was procedurally generated. Please do not modify it directly.
Sources:
- fetch/metadata/tools/fetch-metadata.conf.yml
- fetch/metadata/tools/templates/element-img.sub.html
-->
<html lang="en">
  <meta charset="utf-8">
  <title>HTTP headers on request for HTML "img" element source</title>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="/fetch/metadata/resources/helper.sub.js"></script>
  <body>
  <script>
  'use strict';

  function induceRequest(url, sourceAttr, attributes) {
    const image = document.createElement('img');

    for (const [ name, value ] of Object.entries(attributes)) {
      image.setAttribute(name, value);
    }

    return new Promise((resolve) => {
        image.setAttribute(sourceAttr, url);
        image.onload = image.onerror = resolve;
      });
  }

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - src - Not sent to non-trustworthy same-origin destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - srcset - Not sent to non-trustworthy same-origin destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpSameSite']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - src - Not sent to non-trustworthy same-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpSameSite']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - srcset - Not sent to non-trustworthy same-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpCrossSite']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - src - Not sent to non-trustworthy cross-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpCrossSite']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - srcset - Not sent to non-trustworthy cross-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - src - Not sent to non-trustworthy same-origin destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - srcset - Not sent to non-trustworthy same-origin destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpSameSite']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - src - Not sent to non-trustworthy same-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpSameSite']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - srcset - Not sent to non-trustworthy same-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpCrossSite']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - src - Not sent to non-trustworthy cross-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpCrossSite']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - srcset - Not sent to non-trustworthy cross-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - src - Not sent to non-trustworthy same-origin destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - srcset - Not sent to non-trustworthy same-origin destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpSameSite']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - src - Not sent to non-trustworthy same-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpSameSite']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - srcset - Not sent to non-trustworthy same-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpCrossSite']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - src - Not sent to non-trustworthy cross-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpCrossSite']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - srcset - Not sent to non-trustworthy cross-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - src - Not sent to non-trustworthy same-origin destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - srcset - Not sent to non-trustworthy same-origin destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpSameSite']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - src - Not sent to non-trustworthy same-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpSameSite']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - srcset - Not sent to non-trustworthy same-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpCrossSite']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - src - Not sent to non-trustworthy cross-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpCrossSite']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - srcset - Not sent to non-trustworthy cross-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-storage-access');
        });
  }, 'sec-fetch-storage-access - src - Not sent to non-trustworthy same-origin destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-storage-access');
        });
  }, 'sec-fetch-storage-access - srcset - Not sent to non-trustworthy same-origin destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpSameSite']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-storage-access');
        });
  }, 'sec-fetch-storage-access - src - Not sent to non-trustworthy same-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpSameSite']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-storage-access');
        });
  }, 'sec-fetch-storage-access - srcset - Not sent to non-trustworthy same-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpCrossSite']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-storage-access');
        });
  }, 'sec-fetch-storage-access - src - Not sent to non-trustworthy cross-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpCrossSite']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-storage-access');
        });
  }, 'sec-fetch-storage-access - srcset - Not sent to non-trustworthy cross-site destination, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpsOrigin', 'httpOrigin']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - src - HTTPS downgrade (header not sent), no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpsOrigin', 'httpOrigin']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - srcset - HTTPS downgrade (header not sent), no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin', 'httpsOrigin']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - src - HTTPS upgrade, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpOrigin', 'httpsOrigin']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - srcset - HTTPS upgrade, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpsOrigin', 'httpOrigin', 'httpsOrigin']),
        'src',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - src - HTTPS downgrade-upgrade, no attributes');

  promise_test(() => {
    const key = '{{uuid()}}';

    return induceRequest(
        makeRequestURL(key, ['httpsOrigin', 'httpOrigin', 'httpsOrigin']),
        'srcset',
        {}
      )
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - srcset - HTTPS downgrade-upgrade, no attributes');
  </script>
  </body>
</html>
