Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /resource-timing/fetch-cross-origin-redirect.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Test cross-origin fetch redirects have the right values.</title>
<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>