<!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/window-location.sub.html
-->
<html lang="en">
  <meta charset="utf-8">
  <meta name="timeout" content="long">
  <title>HTTP headers on request for navigation via the HTML Location API</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, navigate, userActivated) {
    const win = window.open();

    return new Promise((resolve) => {
        addEventListener('message', function(event) {
          if (event.source === win) {
            resolve();
          }
        });

        if (userActivated) {
          test_driver.bless('enable user activation', () => {
            navigate(win, url);
          });
        } else {
          navigate(win, url);
        }
      })
      .then(() => win.close());
  }

  const responseParams = {
    mime: 'text/html',
    body: `<script>opener.postMessage('done', '*')</${''}script>`
  };

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy same-origin destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy same-origin destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy same-origin destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy same-origin destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy same-site destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy same-site destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy same-site destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy same-site destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy cross-site destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy cross-site destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy cross-site destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - Not sent to non-trustworthy cross-site destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy same-origin destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy same-origin destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy same-origin destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy same-origin destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy same-site destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy same-site destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy same-site destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy same-site destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy cross-site destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy cross-site destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy cross-site destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-mode');
        });
  }, 'sec-fetch-mode - Not sent to non-trustworthy cross-site destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy same-origin destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy same-origin destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy same-origin destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy same-origin destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy same-site destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy same-site destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy same-site destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy same-site destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy cross-site destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy cross-site destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy cross-site destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-dest');
        });
  }, 'sec-fetch-dest - Not sent to non-trustworthy cross-site destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy same-origin destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy same-origin destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy same-origin destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy same-origin destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy same-site destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy same-site destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy same-site destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpSameSite'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy same-site destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy cross-site destination - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy cross-site destination - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy cross-site destination - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpCrossSite'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-user');
        });
  }, 'sec-fetch-user - Not sent to non-trustworthy cross-site destination - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpsOrigin', 'httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - HTTPS downgrade (header not sent) - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpsOrigin', 'httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - HTTPS downgrade (header not sent) - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpsOrigin', 'httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - HTTPS downgrade (header not sent) - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpsOrigin', 'httpOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_not_own_property(headers, 'sec-fetch-site');
        });
  }, 'sec-fetch-site - HTTPS downgrade (header not sent) - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin', 'httpsOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - HTTPS upgrade - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin', 'httpsOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - HTTPS upgrade - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin', 'httpsOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - HTTPS upgrade - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpOrigin', 'httpsOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - HTTPS upgrade - location.replace');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpsOrigin', 'httpOrigin', 'httpsOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - HTTPS downgrade-upgrade - location');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpsOrigin', 'httpOrigin', 'httpsOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.href = path;
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - HTTPS downgrade-upgrade - location.href');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpsOrigin', 'httpOrigin', 'httpsOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.assign(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - HTTPS downgrade-upgrade - location.assign');

  promise_test(() => {
    const key = '{{uuid()}}';
    const url = makeRequestURL(key, ['httpsOrigin', 'httpOrigin', 'httpsOrigin'], responseParams);

    const navigate = (win, path) => {
      win.location.replace(path);
    };
    return induceRequest(url, navigate, false)
      .then(() => retrieve(key))
      .then((headers) => {
          assert_own_property(headers, 'sec-fetch-site');
          assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
        });
  }, 'sec-fetch-site - HTTPS downgrade-upgrade - location.replace');
  </script>
  </body>
</html>
