OLD | NEW |
(Empty) | |
| 1 if (this.document === undefined) { |
| 2 importScripts("/resources/testharness.js"); |
| 3 importScripts("../resources/utils.js"); |
| 4 importScripts("/common/get-host-info.sub.js") |
| 5 } |
| 6 |
| 7 function corsRedirectCredentials(desc, redirectUrl, redirectLocation, redirectSt
atus, locationCredentials) { |
| 8 var url = redirectUrl |
| 9 var urlParameters = "?redirect_status=" + redirectStatus; |
| 10 urlParameters += "&location=" + redirectLocation.replace("://", "://" + locati
onCredentials + "@"); |
| 11 |
| 12 var requestInit = {"mode": "cors", "redirect": "follow"}; |
| 13 |
| 14 promise_test(t => { |
| 15 const result = fetch(url + urlParameters, requestInit) |
| 16 if(locationCredentials === "") { |
| 17 return result; |
| 18 } else { |
| 19 return promise_rejects(t, new TypeError(), result); |
| 20 } |
| 21 }, desc); |
| 22 } |
| 23 |
| 24 var redirPath = dirname(location.pathname) + RESOURCES_DIR + "redirect.py"; |
| 25 var preflightPath = dirname(location.pathname) + RESOURCES_DIR + "preflight.py"; |
| 26 |
| 27 var host_info = get_host_info(); |
| 28 |
| 29 var localRedirect = host_info.HTTP_ORIGIN + redirPath; |
| 30 var remoteRedirect = host_info.HTTP_ORIGIN_WITH_DIFFERENT_PORT + redirPath; |
| 31 |
| 32 var localLocation = host_info.HTTP_ORIGIN + preflightPath; |
| 33 var remoteLocation = host_info.HTTP_ORIGIN_WITH_DIFFERENT_PORT + preflightPath; |
| 34 var remoteLocation2 = host_info.HTTP_REMOTE_ORIGIN + preflightPath; |
| 35 |
| 36 for (var code of [301, 302, 303, 307, 308]) { |
| 37 corsRedirectCredentials("Redirect " + code + " from same origin to remote with
out user and password", localRedirect, remoteLocation, code, ""); |
| 38 |
| 39 corsRedirectCredentials("Redirect " + code + " from same origin to remote with
user and password", localRedirect, remoteLocation, code, "user:password"); |
| 40 corsRedirectCredentials("Redirect " + code + " from same origin to remote with
user", localRedirect, remoteLocation, code, "user:"); |
| 41 corsRedirectCredentials("Redirect " + code + " from same origin to remote with
password", localRedirect, remoteLocation, code, ":password"); |
| 42 |
| 43 corsRedirectCredentials("Redirect " + code + " from remote to same origin with
user and password", remoteRedirect, localLocation, code, "user:password"); |
| 44 corsRedirectCredentials("Redirect " + code + " from remote to same origin with
user", remoteRedirect, localLocation, code, "user:"); |
| 45 corsRedirectCredentials("Redirect " + code + " from remote to same origin with
password", remoteRedirect, localLocation, code, ":password"); |
| 46 |
| 47 corsRedirectCredentials("Redirect " + code + " from remote to same remote with
user and password", remoteRedirect, remoteLocation, code, "user:password"); |
| 48 corsRedirectCredentials("Redirect " + code + " from remote to same remote with
user", remoteRedirect, remoteLocation, code, "user:"); |
| 49 corsRedirectCredentials("Redirect " + code + " from remote to same remote with
password", remoteRedirect, remoteLocation, code, ":password"); |
| 50 |
| 51 corsRedirectCredentials("Redirect " + code + " from remote to another remote w
ith user and password", remoteRedirect, remoteLocation2, code, "user:password"); |
| 52 corsRedirectCredentials("Redirect " + code + " from remote to another remote w
ith user", remoteRedirect, remoteLocation2, code, "user:"); |
| 53 corsRedirectCredentials("Redirect " + code + " from remote to another remote w
ith password", remoteRedirect, remoteLocation2, code, ":password"); |
| 54 } |
| 55 |
| 56 done(); |
OLD | NEW |