Bug 157370

Summary: CORS check is sometimes incorrectly failing for media loads
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: MediaAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, commit-queue, eric.carlson, jer.noble, mcatanzaro
Priority: P1 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=158921
Attachments:
Description Flags
WIP Patch
none
Patch none

Description Chris Dumez 2016-05-04 21:45:41 PDT
CORS check is sometimes incorrectly failing for media loads. This happens when our media library issues a conditional request and when the sever responds with a "304 Not Modified" response which does not have the "Access-Control-Allow-Origin: *" header. Apache for example does not provide such header for 304 responses.
Comment 1 Chris Dumez 2016-05-04 21:46:18 PDT
<rdar://problem/26071607>
Comment 2 Chris Dumez 2016-05-04 21:48:21 PDT
Created attachment 278156 [details]
WIP Patch
Comment 3 Alex Christensen 2016-05-05 10:30:11 PDT
Comment on attachment 278156 [details]
WIP Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278156&action=review

> Source/WebCore/loader/MediaResourceLoader.cpp:73
> +    if (updatedRequest.isConditional() && corsPolicy == PotentiallyCrossOriginEnabled) {

We shouldn't need to check if a request is conditional.  Just make it unconditional, which won't do anything if it is not conditional.  This will reduce iterating.
We also don't need to make a new ResourceRequest for non-cors requests.
Comment 4 Chris Dumez 2016-05-05 10:32:22 PDT
Comment on attachment 278156 [details]
WIP Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278156&action=review

>> Source/WebCore/loader/MediaResourceLoader.cpp:73
>> +    if (updatedRequest.isConditional() && corsPolicy == PotentiallyCrossOriginEnabled) {
> 
> We shouldn't need to check if a request is conditional.  Just make it unconditional, which won't do anything if it is not conditional.  This will reduce iterating.
> We also don't need to make a new ResourceRequest for non-cors requests.

Yes, I thought about calling makeUnconditional() directly as well. I have it done locally already.

It is true we do not have to copy the request in the non-CORS case, it is just easier to write this way.
Comment 5 Chris Dumez 2016-05-05 15:07:06 PDT
Created attachment 278193 [details]
Patch
Comment 6 WebKit Commit Bot 2016-05-05 16:26:28 PDT
Comment on attachment 278193 [details]
Patch

Clearing flags on attachment: 278193

Committed r200493: <http://trac.webkit.org/changeset/200493>
Comment 7 WebKit Commit Bot 2016-05-05 16:26:36 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Michael Catanzaro 2016-06-19 17:47:41 PDT
This test is timing out for GTK, see bug #158921.