<!DOCTYPE html>
<meta charset="utf-8">
<title>Test cross-origin fetch redirects have the right values.</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="https://www.w3.org/TR/resource-timing-2/#sec-performanceresourcetiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/entry-invariants.js"></script>
<script src="resources/resource-loaders.js"></script>
<script>

const {REMOTE_ORIGIN, ORIGIN} = get_host_info();
const redirect = "/common/redirect.py?" +
                 "location=/resource-timing/resources/empty_script.js";
const cross_origin_redirect = REMOTE_ORIGIN + redirect;
const same_origin_redirect = ORIGIN + redirect;

attribute_test(
  url => fetch(url, {mode: "no-cors", credentials: "include"}),
  new URL(cross_origin_redirect).href,
  invariants.assert_cross_origin_redirected_resource,
  "Test fetching through a cross-origin redirect URL"
);

attribute_test(
  url => fetch(url, {mode: "no-cors", credentials: "include"}),
  new URL(same_origin_redirect).href,
  invariants.assert_same_origin_redirected_resource,
  "Test fetching through a same-origin redirect URL"
);

</script>
