Adding redirect count tests in case of cross origin redirections#4102
Adding redirect count tests in case of cross origin redirections#4102youennf wants to merge 1 commit intoweb-platform-tests:masterfrom
Conversation
|
Could you rebase this? I'll review. |
0cff7cc to
c1f2a66
Compare
Firefox (nightly channel)Testing web-platform-tests at revision d4b422b All results5 tests ran/fetch/api/redirect/redirect-count-cross-origin.html
/fetch/api/redirect/redirect-count.html
/fetch/api/redirect/redirect-count-cross-origin-worker.html
/fetch/api/redirect/redirect-count-worker.html
/fetch/api/redirect/redirect-schemes.html
|
Chrome (unstable channel)Testing web-platform-tests at revision d4b422b All results5 tests ran/fetch/api/redirect/redirect-count-cross-origin.html
/fetch/api/redirect/redirect-count.html
/fetch/api/redirect/redirect-count-cross-origin-worker.html
/fetch/api/redirect/redirect-count-worker.html
/fetch/api/redirect/redirect-schemes.html
|
|
These look good. They also provide tests for #204, right? |
|
I guess it's not testing that since cors/redirect-preflight.htm passes in Safari TP and is obviously wrong per allowing redirects after preflights. How does requirePreflight in your test work then? |
|
Link (#204) is probably not the right one. Some of these tests should trigger using preflight after redirections. Not sure why you say cors/redirect-preflight.htm is wrong. Can you elaborate? |
|
Sorry, I meant whatwg/fetch#204. We changed CORS to allow redirects after a successful preflight, which would typically (not if you redirect to yourself I suppose) result in another preflight for the new destination. That's why that test is wrong. Unfortunately when we made the change in Fetch we didn't have the policy of updating tests, but I'm trying to clean all that up now. |
annevk
left a comment
There was a problem hiding this comment.
Having looked at these tests once more I found several mistakes and I also still don't really understand the max1/max2 parameters and how they actually end up doing anything.
The other questions still stand of course.
| urlParameters += allow_headers; | ||
| urlParameters += "&location=" + encodeURIComponent(redirectLocation + "?token=" + uuid_token + "&max_age=0&max_count=" + (maxCount1 + maxCount2) + allow_headers); | ||
|
|
||
| var maxCount = maxCount1 + maxCount2; |
There was a problem hiding this comment.
This should move up so you don't need to do this addition twice.
| urlParameters += "&redirect_status=" + redirectStatus; | ||
| urlParameters += "&max_count=" + maxCount1; | ||
| urlParameters += allow_headers; | ||
| urlParameters += "&location=" + encodeURIComponent(redirectLocation + "?token=" + uuid_token + "&max_age=0&max_count=" + (maxCount1 + maxCount2) + allow_headers); |
There was a problem hiding this comment.
It seems you're adding allow_headers and max_age twice. Also max_age is never used in the Python resource.
There was a problem hiding this comment.
They are added to the first looped URL and the second looped URL.
Might need to check though whether this is working using a web inspector.
There was a problem hiding this comment.
Sorry, yeah, that probably works.
There was a problem hiding this comment.
But max_age should probably still be removed.
| var url = redirectUrl; | ||
| promise_test(function(test) { | ||
| return fetch(RESOURCES_DIR + "clean-stash.py?token=" + uuid_token).then(function(resp) { | ||
| assert_equals(resp.status, 200, "Clean stash response's status is 200"); |
There was a problem hiding this comment.
It's always 200, no? The only difference seems to be whether the contents are "1" or "0".
There was a problem hiding this comment.
It is just a safety check that the overall test env is correct.
| importScripts("/common/get-host-info.sub.js"); | ||
| } | ||
|
|
||
| function redirectCount(desc, redirectUrl, redirectLocation, redirectStatus, maxCount1, maxCount2, requirePreflight) |
There was a problem hiding this comment.
redirectUrl and redirectLocation could probably be removed since they're always the same.
There was a problem hiding this comment.
They should not always be the same.
The principle of the test is that we will redirect macCount1 times on redirectUrl.
On the last redirect to redirectUrl, we should be redirected to redirectLocation (bad name probably)
And we again are redirected macCount2 on redirectLocation.
There was a problem hiding this comment.
But you always pass the same values as arguments here. There is no method call to redirectCount where they have a different value as far as I can tell.
There was a problem hiding this comment.
redirect-count.py is expected to do that (is_final_redirection check or something like that)
There was a problem hiding this comment.
Maybe you're misunderstanding my feedback. My point was that they don't have to be arguments to the redirectCount() function as the redirectCount() function is never invoked with different values for them. Surely redirect-count.py is not invoking JavaScript?
| redirectCount("Redirect 21 times, last redirection to cross-origin with preflight", redirUrl, crossOriginRedirUrl, 301, 20, 1, true); | ||
|
|
||
| redirectCount("Redirect 20 times, going to cross-origin after 10 with preflight", redirUrl, crossOriginRedirUrl, 303, 10, 10, true); | ||
| redirectCount("Redirect 21 times, going to cross-origin after 10 with preflight", redirUrl, crossOriginRedirUrl, 303, 10, 11, true); |
| redirectCount("Redirect 20 times, going to cross-origin after 10 with preflight", redirUrl, crossOriginRedirUrl, 303, 10, 10, true); | ||
| redirectCount("Redirect 21 times, going to cross-origin after 10 with preflight", redirUrl, crossOriginRedirUrl, 303, 10, 11, true); | ||
|
|
||
| done(); |
There was a problem hiding this comment.
Can you explain this call? I never quite understood that in the Fetch API tests.
There was a problem hiding this comment.
Isn't it needed for worker-environment tests?
| headers.append(("Access-Control-Allow-Headers", request.GET['allow_headers'])) | ||
| stashed_data['preflight'] = "1" | ||
| #Preflight is not redirected: return 200 | ||
| if not "redirect_preflight" in request.GET: |
There was a problem hiding this comment.
Is redirect_preflight ever passed?
There was a problem hiding this comment.
Do not remember. I can check to remove it.
| urlParameters += "&location=" + encodeURIComponent(redirectLocation + "?token=" + uuid_token + "&max_age=0&max_count=" + (maxCount1 + maxCount2) + allow_headers); | ||
|
|
||
| var maxCount = maxCount1 + maxCount2; | ||
| var url = redirectUrl; |
There was a problem hiding this comment.
This seems rather redundant renaming?
|
Also, let's start using the .any.js convention as per #5129. |
|
@youennf, this PR is one of a few that's been inactive for over a year. Do you plan to take this up again? |
Splitting redirect.py in two so that the scripts are easier to understand