Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for redirects after a CORS-preflight #5107

Merged
merged 2 commits into from
Mar 13, 2017

Conversation

ferjm
Copy link
Member

@ferjm ferjm commented Mar 9, 2017

This PR tries to address the changes on the Fetch spec introduced to allow redirects after CORS-preflitghts.

I took the opportunity to do some code clean up as well.

@wpt-pr-bot
Copy link
Collaborator

Notifying @annevk, @hillbrad, @jdm, @odinho, and @zqzhang. (Learn how reviewing works.)

@w3c-bots
Copy link

w3c-bots commented Mar 9, 2017

View the complete job log.

Firefox (nightly channel)

Testing web-platform-tests at revision c531fe0
Using browser at version BuildID 20170306110339; SourceStamp 966464a68a2cb3ca1125808e34abb5c1d34e3797
Starting 10 test iterations
All results were stable

All results

2 tests ran
/cors/preflight-failure.htm
Subtest Results Messages
TIMEOUT
Should throw error if preflight respond with 100 TIMEOUT Test timed out
Should throw error if preflight respond with 101 PASS
Should throw error if preflight respond with 300 PASS
Should throw error if preflight respond with 301 PASS
Should throw error if preflight respond with 302 PASS
Should throw error if preflight respond with 303 PASS
Should throw error if preflight respond with 304 PASS
Should throw error if preflight respond with 305 PASS
Should throw error if preflight respond with 306 PASS
Should throw error if preflight respond with 307 PASS
Should throw error if preflight respond with 308 PASS
Should throw error if preflight respond with 400 PASS
Should throw error if preflight respond with 401 PASS
Should throw error if preflight respond with 402 PASS
Should throw error if preflight respond with 403 PASS
Should throw error if preflight respond with 404 PASS
Should throw error if preflight respond with 405 PASS
Should throw error if preflight respond with 406 PASS
Should throw error if preflight respond with 407 PASS
Should throw error if preflight respond with 408 PASS
Should throw error if preflight respond with 409 PASS
Should throw error if preflight respond with 410 PASS
Should throw error if preflight respond with 411 PASS
Should throw error if preflight respond with 412 PASS
Should throw error if preflight respond with 413 PASS
Should throw error if preflight respond with 414 PASS
Should throw error if preflight respond with 415 PASS
Should throw error if preflight respond with 416 PASS
Should throw error if preflight respond with 417 PASS
Should throw error if preflight respond with 500 PASS
Should throw error if preflight respond with 501 PASS
Should throw error if preflight respond with 502 PASS
Should throw error if preflight respond with 503 PASS
Should throw error if preflight respond with 504 PASS
Should throw error if preflight respond with 505 PASS
/cors/redirect-preflight.htm
Subtest Results Messages
OK
Should allow redirect 301 after succesful (200) preflight FAIL assert_equals: Successfull redirect expected 200 but got 0
Should allow redirect 302 after succesful (200) preflight FAIL assert_equals: Successfull redirect expected 200 but got 0
Should allow redirect 303 after succesful (200) preflight FAIL assert_equals: Successfull redirect expected 200 but got 0
Should allow redirect 307 after succesful (200) preflight FAIL assert_equals: Successfull redirect expected 200 but got 0
Should allow redirect 308 after succesful (200) preflight FAIL assert_equals: Successfull redirect expected 200 but got 0

@w3c-bots
Copy link

w3c-bots commented Mar 9, 2017

View the complete job log.

Chrome (unstable channel)

Testing web-platform-tests at revision c531fe0
Using browser at version 58.0.3029.14 dev
Starting 10 test iterations
All results were stable

All results

2 tests ran
/cors/preflight-failure.htm
Subtest Results Messages
OK
Should throw error if preflight respond with 100 PASS
Should throw error if preflight respond with 101 PASS
Should throw error if preflight respond with 300 PASS
Should throw error if preflight respond with 301 PASS
Should throw error if preflight respond with 302 PASS
Should throw error if preflight respond with 303 PASS
Should throw error if preflight respond with 304 PASS
Should throw error if preflight respond with 305 PASS
Should throw error if preflight respond with 306 PASS
Should throw error if preflight respond with 307 PASS
Should throw error if preflight respond with 308 PASS
Should throw error if preflight respond with 400 PASS
Should throw error if preflight respond with 401 PASS
Should throw error if preflight respond with 402 PASS
Should throw error if preflight respond with 403 PASS
Should throw error if preflight respond with 404 PASS
Should throw error if preflight respond with 405 PASS
Should throw error if preflight respond with 406 PASS
Should throw error if preflight respond with 407 PASS
Should throw error if preflight respond with 408 PASS
Should throw error if preflight respond with 409 PASS
Should throw error if preflight respond with 410 PASS
Should throw error if preflight respond with 411 PASS
Should throw error if preflight respond with 412 PASS
Should throw error if preflight respond with 413 PASS
Should throw error if preflight respond with 414 PASS
Should throw error if preflight respond with 415 PASS
Should throw error if preflight respond with 416 PASS
Should throw error if preflight respond with 417 PASS
Should throw error if preflight respond with 500 PASS
Should throw error if preflight respond with 501 PASS
Should throw error if preflight respond with 502 PASS
Should throw error if preflight respond with 503 PASS
Should throw error if preflight respond with 504 PASS
Should throw error if preflight respond with 505 PASS
/cors/redirect-preflight.htm
Subtest Results Messages
OK
Should allow redirect 301 after succesful (200) preflight PASS
Should allow redirect 302 after succesful (200) preflight PASS
Should allow redirect 303 after succesful (200) preflight PASS
Should allow redirect 307 after succesful (200) preflight PASS
Should allow redirect 308 after succesful (200) preflight PASS

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing we might want to do is to turn these into asynchronous XMLHttpRequest so they don't end up blocking each other. Given the cache busting that should be fine...

assert_throws(null, function() { client.send(null) });

},
'Redirect ' + code + ' on preflight')
}, 'Redirect ' + code + ' on preflight');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So these tests are not actually checking redirects as much as they are checking that a non-2xx status code on preflights causes failure?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

The spec says in steps 6 and 7 of CORS preflight fetch:

(6) If a CORS check for request and response returns success and response’s status is an ok status, run these substeps [...]. (7) Otherwise, return a network error.

There is no explicit mention about 3XX redirection status codes. So maybe this is not the best place for this test? Is this what you are suggesting with your comment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mostly curious. At some point we should probably test other status codes too... I don't really know how much effort you want to put into cleaning up the test suite though. Seems fine to me if you just do it as you come across stuff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I've been slowly making my way through the web-platform-tests backlog for Fetch and friends, but still lots that can be done.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to help with the clean up :). It should be easy to test failures for all non-2XX status codes on preflights, so I'll do it in this PR, along with the change to async XHR. Thanks for the feedback!

@ferjm
Copy link
Member Author

ferjm commented Mar 10, 2017

Sure. I'll turn the tests into async XHRs.

@w3c-bots
Copy link

w3c-bots commented Mar 11, 2017

These tests are now available on w3c-test.org

@annevk
Copy link
Member

annevk commented Mar 13, 2017

Sigh. I think to fix the build error you need to rebase on latest master and force push. Not sure what else can be it.

@annevk
Copy link
Member

annevk commented Mar 13, 2017

Never mind, the problem is #4540.

@jgraham jgraham merged commit 146779a into web-platform-tests:master Mar 13, 2017
@annevk
Copy link
Member

annevk commented Mar 13, 2017

See whatwg/fetch#204 (comment) for bugs I ended up filing and overall status of this feature.

@ferjm ferjm deleted the cors-redirect-preflight branch March 13, 2017 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants