summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/fetch-cross-origin-redirect.https.html
blob: 1605e224ab43b2fa11579f9c64d9706e6a188f9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!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>