blob: 77256064645df5cf55b3995fbb817d23974aff03 [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: retrieve response's body progressively</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/js-test-resources/testharness.js"></script>
<script src="/js-test-resources/testharnessreport.js"></script>
</head>
<body>
<div id="test"></div>
<script>
var redirectUrl = "./resources/redirect-with-cache.php?url=/js-test-resources/testharness.js&";
function redirectMode(test, redirect, urlSuffix) {
var requestInit = {"redirect": redirect};
requestInit.headers = [["enablecaching", "true"]];
if (redirect === "manual") {
return fetch(redirectUrl + urlSuffix, requestInit).then(function(response) {
assert_equals(response.type, "opaqueredirect", "Response type is opaqueredirect");
assert_equals(response.status, 0, "Response status is 0");
});
}
else {
return fetch(redirectUrl + urlSuffix, requestInit).then(function(response) {
assert_equals(response.type, "basic", "Response type is basic");
assert_equals(response.status, 200, "Response status is 200");
});
}
}
promise_test(function(test) {
return redirectMode(test, "manual", "test1").then(() => {
return redirectMode(test, "follow", "test1");
});
}, "Manual redirect fetch should not disrupt follow redirect fetch of the same resource");
promise_test(function(test) {
return redirectMode(test, "follow", "test2").then(() => {
return redirectMode(test, "manual", "test2");
});
}, "Follow redirect fetch should not disrupt manual redirect fetch of the same resource");
promise_test(function(test) {
return Promise.all([
redirectMode(test, "follow", "test3"),
redirectMode(test, "manual", "test3")
]);
}, "Being loaded resources with different redirect mode should not break each other");
</script>
</body>
</html>