Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /resource-timing/response-status-code.cross-origin-redirect.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<meta name="timeout" content="long">
<title>This test validates the response status of resources for Cross-Origin Redirects.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/entry-invariants.js"></script>
<script src="resources/resource-loaders.js"></script>
<script src="/common/get-host-info.sub.js"></script>
</head>
<body>
<script>
const {REMOTE_ORIGIN} = get_host_info();
const SAME_ORIGIN = location.origin;
const status_codes = [
200, 203,
400, 401, 403, 404,
500, 501, 502, 503,
];
// Response status for iframes is 0 when cross origin redirects are present
// Same-Origin => Cross-Origin => Same-Origin => Same-Origin redirect chain
for(const loader of [
load.iframe,
load.frame_object,
load.null_object
]) {
for(const status of status_codes) {
const destUrl =
`${SAME_ORIGIN}/resource-timing/resources/multi_redirect.py` +
`?page_origin=${SAME_ORIGIN}` +
`&cross_origin=${REMOTE_ORIGIN}` +
`&final_resource=` +
`/resource-timing/resources/empty.js?pipe=status(${status})`;
attribute_test(
loader, new URL(destUrl),
entry => {
assert_equals(entry.responseStatus, 0,
`response status should be 0 for iframes having cross origin`
+ ` redirects`);
}
);
}
}
</script>
</body>
</html>